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 xepher101, 05-10-2024, 12:19 PM
      9 responses
      112 views
      0 likes
      Last Post jeronymite  
      Started by tkaboris, Today, 07:53 PM
      0 responses
      1 view
      0 likes
      Last Post tkaboris  
      Started by JGriff5646, Yesterday, 05:47 PM
      2 responses
      22 views
      0 likes
      Last Post JGriff5646  
      Started by lezlebric, Today, 06:32 PM
      0 responses
      13 views
      0 likes
      Last Post lezlebric  
      Started by TheTechnician86, Today, 05:47 PM
      0 responses
      9 views
      0 likes
      Last Post TheTechnician86  
      Working...
      X