stop order unreliable in backtest

Forums ProRealTime English forum ProOrder support stop order unreliable in backtest

This topic contains 2 replies, has 2 voices, and was last updated by avatar Paul 6 days, 10 hours ago.

Currently, there are 0 users and 1 guest visiting this topic.
View all attachments
Viewing 3 posts - 1 through 3 (of 3 total)
  • #137551


    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.


    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!


    code used;



    Have you taken account that for example the Low shown on the candlestick is mid price?

    So with spread = 4 the SellShort / Stop Loss (for a Long) would be 2 points below the Low seen on a candlestick?

    1 user thanked author for this post.

    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 🙂


    1 user thanked author for this post.
Viewing 3 posts - 1 through 3 (of 3 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login