Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Wrong Execution price for Backtest Stop Limit orders

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Wrong Execution price for Backtest Stop Limit orders

    Stop Limit orders in backtesting show executions at prices where the market never reached. I I am using StopLimit orders to implement my stop loss orders. In backtesting, when the stop is triggered, the limit price of the StopLimit order will show an execution at that limit price no matter what that price is, regardless of whether the market actually ever traded there. That is not how the market behaves in real life.

    For instance, the following statement in backtesting, will cause an execution at a market price of 0.00.

    SubmitOrder(0, OrderAction.Sell, OrderType.StopLimit, 1, 0.00, Low[0], "Test", "Test");

    We all know that cannot happen in real life. Why is this allowed to happen in the NT backtest code? I've seen user posts about this behavior as far back as 2007. There are probably many traders unknowingly relying or NT backtests which might be plain wrong. NT knows the OHLC values of every historical candle, why is the code allowing executions outside of the candle high an low?
    Last edited by monpere; 04-14-2012, 01:36 PM.

    #2
    Originally posted by NinjaTrader_AdamP
    monpere,

    This is not typical behavior but I have seen it only a handful of times.

    Could you possible post some screen shots so I may better understand what is happening?
    Here's a sample test strategy, which produces the results shown in the included image

    namespace NinjaTrader.Strategy
    {
    public class a00000 : Strategy
    {
    #region Variables
    #endregion

    protected override void Initialize() {
    Unmanaged = true;
    }

    protected override void OnBarUpdate(){
    if (CurrentBar % 20 == 0 ) {
    SubmitOrder(0, OrderAction.Buy, OrderType.Market, 1, 0.00, 0.00, "Test", "Test");
    SubmitOrder(0, OrderAction.Sell, OrderType.StopLimit, 1, Low[0]-(50*TickSize), Low[0], "Stop", "Stop");
    }
    }

    #region Properties
    #endregion
    }
    }
    Attached Files

    Comment


      #3
      monpere,

      This is expected as part of our "Default" fill algorithm which takes an incredibly conservative approach to order fill prices. If you use the "Liberal" fill algorithm, this will ensure that orders are filled on the bar as you are expecting.
      RayNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      646 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      367 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X