• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLong is delayed by 1 bar

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

    EnterLong is delayed by 1 bar

    I have a daily strategy that calculates an entry signal at the close price of the day.. I am placing an order calculated at the Close of the bar by calling:

    EnterLong();

    The order is placed 1 bar too late. The order is placed on the Close of the next bar.. How can I make it execute on the Close of the currentBar? I know this can't happen in real life but should be doable on Historical bars.

    #2
    You're experiencing this behavior while backtesting? In that case orders are always placed one bar later. This should not be the case while doing live trading.

    Comment


      #3
      Hello afshinmoshrefi,

      When NinjaTrader is running with Calculate set to OnBarClose, orders are placed after the bar closes using logic calculated from that bar.

      Below is a link to the help guide on the Calculate property.

      http://ninjatrader.com/support/helpG.../calculate.htm

      This means that any orders that are triggered from that bar are submitted after the bar closes as the new bar opens. As the order is placed as the new bar opens and the timestamp of the order is within the time of the next bar, the order will show on the next bar.

      Calculate is always OnBarClose in historical data (backtest) when TickReplay is disabled.

      If the strategy were running with Calculate as OnPriceChange or OnEachTick in real-time or historically with TickReplay enabled, or if the script has intra-bar granularity and submitted orders on a smaller timeframe, this would cause the timestamp of the order to be within the bar it is triggered on as the order may be submitted intra-bar. This would show the order on the same bar as the bar that triggered the order submission as it would be submitted before that bar closes.

      This is outlined in the help guide Discrepancies: Real-Time vs Backtest.
      http://ninjatrader.com/support/helpG...ime_vs_bac.htm

      Also, below is a link to a forum thread about intra-bar granularity and TickReplay.
      http://ninjatrader.com/support/forum...297#post491297
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        This features introduces a limitation in back testing analysis which I'm not sure if is possible to overcome. In my analysis I use daily data and would like to simulate a trade as if is entered on the same bar as is processed. I do understand that in live trading that is not possible but for development it is standard. I have done this simulation with MathLab and believe is also possible with Octave, R and NumPy.

        I was also told by a friend that Trade Station has a feature where orders can be entered on the same bar or next bar which solves this issue. Since I use 40 data sources, addition of intra-day data is not feasible for simulation.

        Are there any ideas on how I may be able to use NinjaTrader 8 to do this simulation?

        Comment


          #5
          Hello afshinmoshrefi,

          Unfortunately, its a matter of order of operations. If the order is placed after a bar closes that order's time stamp will be within the next bar. The only way to show an order on the same bar is to place the order before the bar closes.

          You could add a secondary series of minute if the accuracy is not that important. You could have the order be sent one minute before the bar closes.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            The issue is total of 80 data sources in 1 strategy. 40 daily data sources and 40 minute data sources are very very slow on NT8. I have written my own trading routine inside an indicator which can do the trade on daily bar close. The issue is that I cannot use optimization; that would be substantial additional programming.

            Comment


              #7
              Hi afshinmoshrefi,

              When backtesting, intra-bar granularity would be the only way I am aware of to trigger an order before a bar closes.

              I think this would be necessary even if this causes a large amount of data to be loaded.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by afshinmoshrefi View Post
                The issue is total of 80 data sources in 1 strategy. 40 daily data sources and 40 minute data sources are very very slow on NT8. I have written my own trading routine inside an indicator which can do the trade on daily bar close. The issue is that I cannot use optimization; that would be substantial additional programming.
                The 1-bar delayed entry is almost certainly because you are validating your entry before actual entry. There is only one tick on the bar when backtesting/optimizing. You need to account for that environmental difference.

                Same question in this thread. You can look it over for a resolution. http://ninjatrader.com/support/forum...ad.php?t=91858

                My response is a bit far down in the thread, so here is the post that has a solution: http://ninjatrader.com/support/forum...51&postcount=1

                As it was related to NT7, you will have to make the necessary adjustments for NT8.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by RandanAL, Today, 05:13 PM
                0 responses
                5 views
                0 likes
                Last Post RandanAL  
                Started by timko, Today, 05:06 PM
                0 responses
                5 views
                0 likes
                Last Post timko
                by timko
                 
                Started by ballboy11, Today, 01:04 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_PaulH  
                Started by Linda1507, Today, 01:22 PM
                2 responses
                15 views
                0 likes
                Last Post Linda1507  
                Started by ntbone, Today, 12:15 PM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X