Forums ProRealTime English forum ProOrder support 1/2 POSITION ON TARGET

Currently, there are 0 users and 1 guest visiting this topic.
View all attachments
Viewing 12 posts - 1 through 12 (of 12 total)
  • #124950 Report

    Hi all

    Within the last couple weeks, i have downloaded ProRealTime and have started to learn how to programme a simple idea i have had.  Ive learn alot since starting and looking through the library of code on here and really helped but I am currently stuck on 2 points and wondered if anyone would be able to help me with these please.

    These are quite basic questions but i just cant figure out how you would write these scenarios in code:

    • If my code opens a position (either long or short) with 2 contracts on an action, how can i set the code to close 1 of the contracts on a profit target and leave the remaining running until another action closes it?  Is that possible?  This would really help to maximise profits but limit risk.
    • Also, how can I get my code to close a position (long or short) if there are say 4 candles in the row that have only moved a maximum of say 2 points in either direction?

    Thanks in advance

    #124957 Report

    Use LIMIT orders. You have to place one at the time you enter the trade (you can only use the closing price to calculate the exit at this point and hope there is no big gap!) so that it is on the market from the moment the 2 positions are opened. After the first bar closes you can calculate the exit price based on the actual price you bought at. Limit orders last only one bar so you then have to keep sending them to the market on every candle.

    You should be aware that at the current time it is not possible to run a strategy either live in demo or in real live trading that uses partial position closure. You can back test ideas though.

    In this example the first position is closed out at 1% profit.


    #124958 Report

    To answer your second question:


    #125005 Report

    Hi Vonasi

    Thanks very much for coming back to me with the above, much appreciated!

    Oh right, is there a reason that we are not currently able to do partial position closure?  Thats a shame….so the code you’ve sent me above for the limit order wouldnt actually work on the live or live demo system, only on back test?

    Thanks again

    #125009 Report


    The PRT platform has the ability to do partial position closure but the broker IG doesn’t allow it via automated trading at the moment. The closest we can get is to use SET STOP and SET PROFIT instructions that allow positions to be closed separately. All positions however have exactly the same stoploss and takeprofit distances from their opening price set to whatever the last SET instruction values were.


    #125019 Report

    Hi Vonasi

    Thanks again, i would never have worked all this out without speaking to you! 🙂

    I know this is going to be a dumb question but i just want to make sure i understand it correctly….how exactly do we use the SET STOP and SET PROFIT instructions to close positions separately?


    #125022 Report


    Whenever one of the above instructions is read at the close of a candle then the stop loss and target orders are sent to the market and effect all open positions. The orders stay on the market until the position they are attached to are closed or until a new SET order is sent. If you change the 2 to a 3 then all positions will have their exit orders changed to 3 pips or 3%.

    #125035 Report

    Thanks again for explaining, this makes it alot easier to understand.

    One last question i promise, then i’ll leave you alone 🙂

    Within my code, my buy instructions are looking at when exponential lines cross but also to then count 2 candles after the lines cross to ensure that the market is still heading that way at that point….the code i have used is below:

    Example of buy order:


    But i’m still getting buys (or shorts) in my backtesting when the candles arn’t as i’ve set in the code, i think i’ve set it so it doesn’t buy before the indicators cross and there are 2 subsequent candles that are green before buying? Or have i got the code wrong?  I have done the same but in reverse for shorts.

    Thanks again

    #125043 Report

    There are some simple rules that everyone using the forums is expected to follow. Your post has broken one or more of these rules.

    The forum rules are as follows. I have highlighted in bold the rule/rules that you have not followed:

    Post your topic in the correct forum.

    ProRealTime Platform Support          only platform related issues.
    ProOrder                                                only strategy topics.
    ProBuilder                                              only indicator topics.
    ProScreener                                           only screener topics
    General Discussion                               any other topics.
    Welcome New Members                      for new forum members to introduce themselves.

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
    Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
    Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
    Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
    Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
    Do not include personal information such as email addresses or telephone numbers in your posts. If you would like to contact another forum member directly outside of the forums then contact the forums administrator via ‘Contact Us’ and they will pass your details on to the member that you wish to contact.
    Always be polite and courteous to others.
    Have fun.

    I have edited your post where required. Please ensure that your future posts meet these few simple forum rules. 🙂

    #125044 Report

    You need to check C1 two candles back.

    So this will now need a cross followed by two green candles.

    1 user thanked author for this post.
    #125047 Report

    Ah, sorry about that, i’ll make sure i do that from now on 🙂

    #125052 Report

    As, so close!

    Thanks for your help Vonasi, that seems to have worked but now thats given me a new thing to look at tomorrow 🙂

Viewing 12 posts - 1 through 12 (of 12 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login