Hi,
I’m sure this is a simple question but I’m struggling to make it work. I’m trying to place a stop loss on the exponential moving average 20, either above the price if going short or below the price if going long. anyone able to point me in the right direction?
Many thanks
Either calculate the difference between close and the average and use SET STOP pLOSS or send a pending order at every bar to sell at the average price.
if longonmarket then
sl = close - average[20]
set stop ploss sl
if shortonmarket then
sl = average[20] - close
set stop ploss sl
or
if (your long conditions) then
buy 1 contract at market
sell at average[20] stop
endif
if longonmarket then
sell at average[20] stop
endif
if (your short conditions) then
sellshort 1 contract at market
exitshort at average[20] stop
endif
if shortonmarket then
exitshort at average[20] stop
endif
Hi
Thank you so much for your help, it is much appreciated
Thanks