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

NT7 Probable bug w ExitLongLimit() command

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

    NT7 Probable bug w ExitLongLimit() command

    From the picture you can see that if I place a sell order ExitLongLimit with a limit price that is much better than the low price of the bar, it gets executed at the limitOrder price rather than the low of the bar price.
    I double checked the slippage is set to zero.


    The test code below simply says:
    if ( 34 < base.CurrentBar ) base.ExitLongLimit(3, 65.82, "bad NinjaTrader", "");
    where 65.82 is a price much much lower than the low of the current bar #34.
    I am attaching a picture that shows the problem.
    When I look at the strategy performance also you can see big losses where in actuality you could have big gains.
    I am quite surprised to find an error like this on a platform of this caliber. Am I crazy?
    Best
    G





    Code:
    // 
    // Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
    // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
    //
    
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using System.Collections.Generic; //List
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Strategy;
    #endregion
    
    
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
        /// <summary>
        /// 
        /// </summary>
        [Description("")]
        public class gSimplestEntryExtStrategyDebugLimitOrder : Strategy
        {
        #region Variables
    
        #endregion
    
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                //EnterShort(3);
                //ExitShort();
                if (base.CurrentBar == 27) { EnterLong(3); }
                //if ( 34 < base.CurrentBar ) base.ExitLongLimit(3, 66.02, "good NinjaTrader", "");
                if ( 34 < base.CurrentBar ) base.ExitLongLimit(3, 65.82, "bad NinjaTrader", "");
            }
    
            #region Properties
            
            #endregion
        }
    }
    Attached Files
    Last edited by giogio1; 06-27-2018, 10:31 PM. Reason: to make the reading more comprehensible

    #2
    Hello giogio1,

    Thank you for your report.

    NT7 does not restrict fills to a bars High/Low, whereas this was a change in NT8. This does not happen in NT8, which you should adapt to.

    It does not make sense to call ExitLongLimit with a price through the market, you should instead use ExitLong so that its treated as a market order. To do this you could write an if statement such as the following,

    Code:
    if(exitPrice<Close[0])
    ExitLong();
    else
    ExitLongLimit(exitPrice);
    But the best resolution and the most accurate for backtests is going to bring a secondary tick series in and fill orders on that series. This will give the most realistic results and you will not have this issue.

    Please see the following example for how to do this,
    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply.
      In case of gap the solution wouldn't be correct. I am quite surprised the issue got never addressed during the NT7 life.
      I am considering switching to NinjaTrader 8 but since it freezes too easily I am holding on. I also have large investment of indicators for NT7 that I cannot throw away.
      G

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DJ888, 04-16-2024, 06:09 PM
      4 responses
      12 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by terofs, Today, 04:18 PM
      0 responses
      7 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by nandhumca, Today, 03:41 PM
      0 responses
      6 views
      0 likes
      Last Post nandhumca  
      Started by The_Sec, Today, 03:37 PM
      0 responses
      3 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by GwFutures1988, Today, 02:48 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Working...
      X