calling the AverageTrueRange (ATR) value at a previous candle

Forums ProRealTime English forum ProOrder support calling the AverageTrueRange (ATR) value at a previous candle

Viewing 5 posts - 1 through 5 (of 5 total)
  • #229942

    Hi everyone,

    I am defining my stop loss as a function of the ATR and I would like this ATR to be, not the ATR value at the current candle, but the ATR value as it was at the opening of the trade.

    I thought it would be as simple as writing

    but instead it throws everything off. The backtest just accumulates massive losses on the very first trade of the period. And since the formula includes “TradeIndex”, I can’t program an indicator to see what values it produces.

    Am I missing something obvious?

     

    Thanks a lot !

     

    #229944

    Hi there,

    You could start with a command

    in order to see whether that remains the same throughout the open position. This is not necessarily so ! (depending on what you further do when the position is running).
    If that remains the same, then consider whether the logic is OK (I can’t tell but it looks weird ?).
    Otherwise it seems to me that you could have something like this :

     

     

    #229963
    JS

    Hi,

    What is important for such calculations is that your ATR -calculation is in the “IF-Then” statement:

    If myConditions then

    Buy 1 contract at Market

    ATR=AvarageTrueRange[10](Close[BarIndex-TradeIndex])

    EndIf

    Set Stop PLoss ATR

    Set Take Profit (2*ATR)

    If your calculation is outside the “IF-Then” then the ATR values will change every time the code is recalculated … (at the Close of the Bar)

    #230297

    If you define ATR as :

    ATR = AverageTrueRange[10](close)

    then, ATR value at TradeIndex is :

    MyStopLoss = ATR[BarIndex-TradeIndex]

    Anyway, the best option is to define the stop loss just after th buy instruction with “Set Stop PLoss ATR”

    #230459

    Thanks a lot everyone!

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

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