Dear Forum,
I’d be grateful for any help with the following straighforward coding problem.
Once my trade is entered I want to set a stop at the low of the preceeding bar.
Now I assumed it would just be
Sell at Low[1] stop
However, in backtest at least, this seems to change as Low[1] moves one bar forward with the creation of each new bar.
Does anyone know the fix for this?
Many thanks all
Linden
WingParticipant
Veteran
After the line of code where you buy, you need another line of code to save the low of the previous bar for future use. Example:
once MyStop = 1
If buyconditions=true and onmarket=0
buy 1 lot at market
MyStop = low[1]
endif
sell at MyStop stop
Thanks Wing, I understand above, except why we need …
once MyStop = 1
Thank You
GraHal
Thanks Wing, thats really fantastic.
Many thanks
Linden