You almost have it, there's only a small mistake in your script - the stop is placed at a wrong line in the code. And remove the "NumWFOCycles" line.
Stop = 1.8*ATR(20);
if(priceClose(9) > priceClose(10) && priceOpen(158) > priceLow(130) && priceClose(156) > priceClose(173))
reverseLong(1);
if(priceClose(9) < priceClose(10) && priceOpen(158) < priceLow(130) && priceClose(156) < priceClose(173))
reverseShort(1);
- Please do not trade this system live. I'm wondering why Daniel Fernandez, whom I know as a honest and serious trader, is putting up such a nonsense system on his website. There is no way that comparing a price from 173 days ago can produce a useful trade signal.
Such systems happen when people only rely on the outcome of their code generators, and do not think about whether the algorithm really makes sense. Systems like that certainly produce any result in a backtest, but fail miserably in a WFO test.