ATR based Stop Loss (and Profit Target) - NON Trailing
Posted: Fri Nov 12, 2021 4:08 pm
Hey Guys,
i would like to ask you for a help, with one topic which is driving me nuts:
--> How to set ATR based, non-trailing SL (resp, PT based on R2R ratio?)
In my Study I have define SL as follows
...and it gives expected levels on SL and PT....BUT ...
when I turn my Study into Strategy I am stopped on the very next candle, no matters what the price is.
Here is the exit code:
What I think might be the issue that the script reflects always the current candle and not the entry candle.
Can anyone help me with such definition?
Or suggest whatever change is needed?
Or point me out to the resource (video, article) which shows NON trailing ATR based SL for strategy?
thanks a lot
zwp
i would like to ask you for a help, with one topic which is driving me nuts:
--> How to set ATR based, non-trailing SL (resp, PT based on R2R ratio?)
In my Study I have define SL as follows
Code: Select all
atr = atr(14)
stopSell = highest(high,2) + (atr*atrMult)
stopBuy = lowest(low,2) - (atr*atrMult)
profitSell = close - ((stopSell - close)*R2R)
profitBuy = close + ((close - stopBuy)*R2R)
when I turn my Study into Strategy I am stopped on the very next candle, no matters what the price is.
Here is the exit code:
Code: Select all
strategy.close("Go Long", when= (profitBuy or stopBuy))
strategy.close("Go Short", when= (profitSell or stopSell))
What I think might be the issue that the script reflects always the current candle and not the entry candle.
Can anyone help me with such definition?
Or suggest whatever change is needed?
Or point me out to the resource (video, article) which shows NON trailing ATR based SL for strategy?
thanks a lot
zwp