I have a question regarding an ATR stop loss/profit code snippet. Here is two different codes, that produce very different backtest results. I would expect it to be the same. Why does the backtest differ when I have the stop loss and target profit outside of the “if”-statement? I guess its probably obvious for someone with more coding experience than me. Thanks in advance!
When you put the SL and the TP in the “IF” statement, they are only placed once, but when you put them outside the “IF” statement, they are placed every time while “ATR” values change…
As a result, the two codes work with different “ATR” values, hence the difference…
Thanks so much JS! To me it sounds more “correct” to then place it outside of the “IF” statement then? Or would you say none is more correct than the other?
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