Defining SL and TP target with ATR

Forums ProRealTime English forum ProOrder support Defining SL and TP target with ATR

Viewing 2 posts - 1 through 2 (of 2 total)
  • #174954

    Hi all,

    I would like to define my SL and TP target using AverageTrueRange (ATR).  So for example, if I open a trade to go long at price = 100, and ATR = 10, I would like to define the SL = ATR =10; and the TP = 2*ATR = 20.  I would like the SL and TP target to be fixed throughout the life of the trade.

    However, it seems my PRT code below reset a new target for the SL and TP everytime a new candle is formed.  How do I go about modifying it so the SL and TP are the one that are originally defined during the inception of the trade.  And once the trade is closed, and upon opening a new trade, the SL and TP will be reset accordingly.

    Thank you and looking forward to hearing from you soon.

     

     

    #174961

    Firstly, you should use LOSS and PROFIT, at lines 7-8, without a leading “p“, because they require a difference (or range) expressed as a price which ATR is. You could keep using PLOSS and PPROFIT but in this case you should append “*PipSize” at the end pf those two lines, to make code portable across different instruments (as it is now it will work with indices, not with currency pairs).

    Secondly, to make SL and TP unchangeable, you have to embed their calculation within the IF…ENDIF that enters at market:

    in order to prevent them to be calculated again each new candle.

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

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