An issue with a backtest running on the dow with a stop order.
i’ve coded to close a long position on stop at the supportprice.
the position is then is the red and closing it should cut potential losses.
Now, in the backtest, the index never traded at the supportprice, yet still the position in closed exactly at the line. In de demo, the position is not closed, which is correct and ended up winning.
The difference between the low & supportline is 2 points.
(positionsize=0.5)
if spread=3.8 or lower, the position stays open and wins in the backtest +22,60
if spread=3.9 or higher, the position is closed with losses in the backtest-17,50
(demo +22,64)
It bugs me that it’s depended on spread if it’s closed or not which shouldn’t be an issue at all because the line was never touched.
So the question, why was it closed?Because it means a stoporder doesn’t work exactly as intended in a backtest!
I didn’t realise. If spread is high, the difference could be even bigger. On a fast timeframe it’s a problem with many trades, stability and testing. Guess the best solution is to use crossover/crossunder & exit at market, which come at a cost too.
Maybe then use MTF, like something I did with barhunter. In this case backtesting on 5s, putting it live on 1s.
Thanks GraHal, there are a few options! and it’s never easy 🙂