Trailing stop on last bar's close
-
Hello everyone!

I am trying to set a trailing stop loss based on the previous bar {Close Price + 2ATR} (for sell orders) and {Close Price - 2ATR} (for buy orders).
I have tried to use loop blocks and the trailing stop block (blocks 41 to 44) but I cannot find a way to set the price "reference" as the previous candle close and to make this happen for every new bar created...does anyone know how to do this?https://fxdreema.com/shared/AkT0UWaM
Thanks!!
-
Try something like this: http://prntscr.com/c3gik7
But about the ATR value, put it in a Variable. I named it like "ATRValue" only for the example.
I also think that 2 Trailing Stop blocks must be used, because of the "+" and "-" used for buys and sells -
__Try something like this: http://prntscr.com/c3gik7
But about the ATR value, put it in a Variable. I named it like "ATRValue" only for the example.
I also think that 2 Trailing Stop blocks must be used, because of the "+" and "-" used for buys and sells[/quote:199rh1k4]Thanks for the input! But I do not quite understand what you have done there...I cannot see anywhere a reference to the previous bar close price and I cannot understand why you take the ATRvalue+ATRvalue2 , I would like PreviousClose+ATR2 ....could you explain it please?

I have tried to update it like this https://fxdreema.com/shared/5hV58uyNd but like this it does not work on MT4 - I have attached a screenshot with the errors...any idea why it cannot run?
-
The error means that SL is 0. SL is used for this particular MM and can't be 0, it must be something.
I touched this project a little bit: https://fxdreema.com/shared/K3KusLlie
So, you calculate all variables once per bar. But then you Buy/Sell at any time in the middle of the candle. The problem is that in the middle of the candle the price moves and eventually the calculated SL levels become wrong.