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.
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.
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 :
1
2
3
4
5
6
OnceATR=0
IfOnMarketandnotOnMarket[1]then// Just opened a new position ?
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue