Cumulating positions with breakeven

Forums ProRealTime English forum ProOrder support Cumulating positions with breakeven

Viewing 11 posts - 1 through 11 (of 11 total)
  • #145007

    Im using nicolas’s code on breakeven which was working great until i tried using cumulating positions.

    Is there a way to reset the code after each trade instead of ‘If not onmarket then breakeven=0’ ?

    Also strangely my cumulating positions dont follow there individual targets and stoplosses, its as if they are added to each other. I tried both pProfit and %Profit, neither worked. I tried searching through the forum and people were saying in IG Profit and stoploss will follow individual trades but not it prorealtime, is this right?

    How do I make it work so i can backtest it properly?

    Thanks in advance

     

    #145012

    I think you misunderstood how code works for accumulation….when more and more trades are placed by same strategy (accumulating), all of them will have a single stoploss and single target profit, you have to exit them all at same point (unless you manage them manually in which case code will stop managing your order).

    Orders placed by separate strategies or manually will have their individual SL and TP always.

    Hope this helps.

    1 user thanked author for this post.
    #145015

    If i were to trade live with IG using cumulative orders. Would they have individual target and stops? Not including the breakeven code.

    #145016

    Within same system, answer is no, they won’t have individual SLs and TPs.

    You can have multiple instances of same system running which will have their own separate SLs or TPs.

    #145019

    Thanks for your reply but Im sorry, im still extremely confused. According to this thread – https://www.prorealcode.com/topic/cumulate-orders-and-stops-targets/

    Targets and stoplosses are placed individually with IG. Is that only with %profit or with pProfit as well.

    Also if thats the case will we have different results with prorealtime backtest vs ig live trades if correlated??

    If we include the breakeven code with cumulative orders and say i am making a profit, would that also correlate with IG trades?

    It questions the reliability of the backtest specifically with IG.

     

     

    #145020

    I am attaching an eXcel file with the calculations of POSITIONPRICE (hilighted in bold blue on yellow), which is an average price updated each new entry according to price and number of lots accumulated.

    POSITIONPRICE is the keyword to use in your code to check gains/losses, beacuse TRADEPRICE (commonly used as a reference) cannot be used because there are several TRADEPRICES.

    All SL’s and TP’s are calculated according to the updated value of POSITIONPRICE when accumulating positions (DEFPARAM CumulateOrders = TRUE).

     

    #145024

    Thanks for your reply.

    “Set a target profit x% from the average position price.

    Note: the % profit is calculated and placed individually for each order with IG or PRT-CFD.”    from https://www.prorealcode.com/documentation/profit/

     Im more worried with the  differences between the backtest and IG. 

    For eg cumulated %profit in the backtest with be calculated based on positionprice but would it deliver the same results with IG?

    What would happen if I put pProfit with IG?

    My understanding is that IG will not trigger stoploss/target based of positionprice.

    #145029

    IG keep track of TP when a new position is entered, when accumulation is active, so they will close the single position when TP is reached, regardless of POSITIONPRICE.

    1 user thanked author for this post.
    #145033

    Individual target and stoploss doesn’t mean that they can be different: x% target for 1st order and y% target for 2nd order = Not possible.

    The breakeven function you are using set a pending stop order to sell all long orders at the same moment when price reach the breakeven price level.

    1 user thanked author for this post.
    #191088

    Hi, i am curious – sorry join this old discussion, but was just thinking about this myself and wondering how to do it.

    If used TRADEPRICE in the code instead of POSITIONPRICE would that make this possible ? For example a different loop for the Trailing SL’s or Breakevens if used TRADEPRICE[0], TRADEPRICE[1], TRADEPRICE[2] etc.. as in most recent trade price, the prior trade price, and the trade price before that? Using like ‘if positionsize + 1″ etc .. ?

    Would doing something like that allow the strategy to operate seperate Stop-loses/Trailing profits for each trade in cumulating positions?

     

     

    #191091

    TradePrice(1), even without parenthesis, is not the price of the last   entry; it’s the price of the last operation carried out, be it an entry or a partial exit.

    If you use it to trail your stop loss, you might then use a wrong price.

    Tradeprice is fine if you don’t close partial positions.

    PositionPrice will always be the updated average price.

    You could keep track of each individual entry price using an array and adding elements retaining a different Tradeprice each time a new entry is executed.

    Bear in mind that you can keep track of each Tradeprice, but you cannot track individual orders and close the one you prefer. Everytime you close a position, the FIFO (First In First Out) rule applies. So if you choose to close a position at the most recent Tradeprice, you can do it, but it’s the oldest entry that will be closed, though.

    Furthermore, I want to remind you that partial closing of positions can only be used with MARKET orders, not pending ones (as it’s not supported by IG).

     

    1 user thanked author for this post.
Viewing 11 posts - 1 through 11 (of 11 total)

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