Hi all,
Is it possible to code an exit code that would exit a position once a certain condition is met the second time around?
The exit condition I’m trying to achieve is when CDC ATR Trailing Stop v2.1 indicator turns red the second time around (on long positions) and turns green the second time around (on short positions). So it would not exit the position the first time the CDC ATR Trailing Stop v2.1 changes color.
How would one go about coding this? Please see attached screenshot.
Thanks in advance.
Simply set a flag.
if your entry conditions then
buy 1 contract at market
flag = 0
endif
if longonmarket and (my exit condition happens) then
flag = flag + 1
endif
if longonmarket and flag = 2 then
sell at market
flag = 0
endif
Above added as Log 204 here …
Snippet Link Library