Hi All,
Apologies if this has been asked before but I have searched the forums and couldn’t find how to do this. I am still a beginner at this but really enjoying it.
I am trying to code a trailing stop loss which is a multiple of ATR from the last high since being in the market (i.e. Tradeprice). Once the close goes through this level then sell at next open.
I thought using the Barindex-tradeindex like in code below was correct but sometimes it just sells the next day from purchase even if the move was in a profitable position.
CURRENT CODE:
if longonmarket and Close < ((Highest[Barindex-TradeIndex](High))-SL) then
sell at market
endif
The SL is= ATR*3
Really scratching my head at this so any help would be greatly appreciated.
Thanks a million.
WhiteWolf – Welcome to the forums.
The ‘General Trading Discussions’ forum is for….. well general trading discussions. Your question is automatic trading strategy coding related and so should be in the ProOrder forum. I have moved it – please try to post in the most relevant forum with future posts.
Try changing HIGH to HIGH[1] because close will more than likely always be less than the current high unless it is equal to it!
Apologies and thanks for your help.