Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Torontobluejays, Today, 08:43 AM
      0 responses
      1 view
      0 likes
      Last Post Torontobluejays  
      Started by sastrades, 01-31-2024, 10:19 PM
      12 responses
      190 views
      0 likes
      Last Post sastrades  
      Started by Jimmyk, 01-26-2018, 05:19 AM
      8 responses
      864 views
      0 likes
      Last Post emuns
      by emuns
       
      Started by giulyko00, 04-24-2024, 12:03 PM
      6 responses
      29 views
      0 likes
      Last Post giulyko00  
      Started by 00nevest, 04-27-2024, 02:27 PM
      3 responses
      27 views
      0 likes
      Last Post 00nevest  
      Working...
      X