Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaTrader 8.1.1.1 AddDataSeries with same instrument and TradingHours

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

    NinjaTrader 8.1.1.1 AddDataSeries with same instrument and TradingHours

    In NinjaTrader 8.1.1.1, if you use AddDataSeries in State.Configure but leave the instrument blank (either "" or null) this was interpreted to mean the same instrument as on the chart. This is necessary because you can't rely on Instrument yet to get the symbol name until State.DataLoaded.

    But, running the same today on ES 06-23 (rollover day), this results in the message "[name] tried to load additional data. All data must first be loaded by the hosting NInjaScript in its configure state." where before it was successful.

    This is a bug specific to rollover day, because if you change the symbol to one that is not rolling over today like CL 04-23 or even the previous contract of the same instrument ES 03-23, it works perfectly, and I'm willing to wager it will work perfectly on ES 06-23 tomorrow, because tomorrow is not rollover day.
    Attached Files
    Last edited by QuantKey_Bruce; 03-13-2023, 06:23 AM.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    #2
    I suppose I should clarify that if you do not specify the trading hours, the bug does not happen. It is specific to rollover day, IF you specify the trading hours.

    The issue here, more concretely, is that when you specify the trading hours and they're different than the trading hours on the chart, that's a different data series that has to be loaded. And that works. But, it doesn't work on rollover day - that is the bug.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello QuantKey_Bruce,

      I have moved your thread from the Platform Technical Support section of the forums to the Indicator Development section of the forums as your questions relate to C# development and programming NinjaScript Indicators.

      The message indicates that you attempted to host an indicator that calls AddDataSeries() from another script without calling the same AddDataSeries() call in the host script.

      From the help guide:
      "Warning
      Should your script be the host for other scripts that are creating indicators and series dependent resources in State.DataLoaded, please make sure that the host is doing the same AddDataSeries() calls as those hosted scripts would. For further reference, please also review the 2nd example below and the 'Adding additional Bars Objects to NinjaScript' section in Multi-Time Frame & Instruments​"


      "Note: To maximize data loading performance, any NinjaScript object (indicator or strategy as host) which references a multi-series indicator which calls AddDataSeries must include it's own calls to AddDataSeries(). For example, if the code above was included in an indicator, and that indicator was referenced in a NinjaScript strategy, then the hosting strategy will need to include the same calls to AddDataSeries(). When the strategy adds the additional Bars objects, the calls to AddDataSeries() within the indicator will be ignored. If the Bars objects are not added by the strategy in such cases, and error will be thrown in the Log tab of the Control Center that would read - "A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.""


      This means whatever AddDataSeries() call you make in a hosted indicator, copy and paste the same AddDataSeries() call into the host strategy or indicator that is calling that hosted indicator.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        No, the script does not host anything at all. The error message that is displayed is inappropriate for the situation.

        It's named "HostingNinjaScriptExample20230313" because it's a demonstration of an inappropriate error condition (a bug) and that's the name of the error message.

        Here's the entire script:

        Code:
        public class HostingNinjaScriptExample20230313 : Indicator
            {
                //public override string DisplayName { get { return Name.Trim(); } }
        
                protected override void OnStateChange()
                {
                    if (State == State.SetDefaults)
                    {
                        Name                        = "Hosting NinjaScript Example 2023-03-13";
                        PaintPriceMarkers            = true;
                        IsSuspendedWhileInactive    = false;
                        IsOverlay                    = true;
        
                        IsAutoScale = false;
                        PaintPriceMarkers = true;
                    }
        
                    else if (State == State.Configure)
                    {
                        AddDataSeries(null, new BarsPeriod() { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, "CME US Index Futures RTH");
                    }
                }
        
                protected override void OnBarUpdate()
                {
                }
            }
        }​
        I should have named it "trading hours rollover day bug demonstration" but in my haste I named it after the error message that displays instead.

        There is no reason it should fail on rollover day and work on every other day - that appears to be a platform bug.
        Last edited by QuantKey_Bruce; 03-13-2023, 10:04 AM.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Hello QuantKey_Bruce,

          I am not able to reproduce.

          Below is a link to a video of adding this to the ES 06-23 1 minute chart with no error, and changing to the ES 03-23, again with no error.
          https://drive.google.com/file/d/1GF4...w?usp=drivesdk
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            It no longer fails here, either. I strongly suspect it was failing because the test case was running before the opening on rollover day, and therefore there was no data for that day in the RTH trading hours (yet). Now that there is data, it no longer fails.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment


              #7
              Hello QuantKey_Bruce,

              The message you specified, only happens when hosting an indicator.

              I would not expect this error when directly applying an indicator to a chart that does not host any other indicators.

              The message you specified is not related to data, or the Trading hours, or the rollover.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                The issue appears to be limited to: we just rolled over to a new contract (ES 06-23 in this case) and there's data on the chart for ES 06-23 (instrument default settings trading times) and we try to AddDataSeries the US Equities Index Futures RTH trading times, but we're before the open, so the current date (2023-03-13) has no data in that trading time for this date... failure. If there is data on the latest date, it does not fail, nor does it fail if we are running it on any other date after the rollover.
                Bruce DeVault
                QuantKey Trading Vendor Services
                NinjaTrader Ecosystem Vendor - QuantKey

                Comment


                  #9
                  Chelsea,

                  Because it's after the open, we're going to have to work a little harder to reproduce the problem. Here's how you can reproduce it.

                  Go into your Trading Hours, and make a copy of US Equity Index Futures RTH... rename the copy to "US Equity Index Futures RTH Late".

                  Then, go into the new one "US Equity Index Futures RTH Late" and edit Monday so that Monday's trading times are from 3:30 PM to 4:00 PM (it's currently only 12:15 PM in that time zone on rollover Monday).

                  Then, go into the script and modify the script so it uses the trading times "US Equity Index Futures RTH Late" by modifying that one line where it's doing AddDataSeries with the trading times.

                  Boom. Reproduces the error message immediately when applied to an ES 06-23 chart of 1-minute bars using instrument defaults.

                  Note that this would have been the same thing, had you run it before the open today on the regular RTH trading times - it's just that it took a few hours for you to look at it and by then there was already data so it didn't fail.
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChelseaB View Post
                    The message you specified, only happens when hosting an indicator.

                    I would not expect this error when directly applying an indicator to a chart that does not host any other indicators.

                    The message you specified is not related to data, or the Trading hours, or the rollover.
                    Right! I would not EXPECT that either - that's why I'm reporting it - it's a bug. And yes, it is completely specific to rollover day, when there is no data yet for the trading hours requested for the present day. I've just posted new instructions for how to reproduce. Thank you for your patience with this one as it is a bit obscure but it is a definite reality.
                    Bruce DeVault
                    QuantKey Trading Vendor Services
                    NinjaTrader Ecosystem Vendor - QuantKey

                    Comment


                      #11
                      Hello QuantKey_Bruce,

                      Thank you for the direction. I was able to reproduce the error and this is unexpected.

                      I've reported to our development. Once I have a tracking ID I will post in this thread for future reference.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Great! Thanks for sticking with this one. I know it was a less obvious one, but I am glad you could reproduce the issue.

                        Please be sure to let development know when they are looking at this one that it has to be rollover day, or this does not happen. I could easily imagine them checking this later when it's not rollover and simply concluding it works fine.
                        Bruce DeVault
                        QuantKey Trading Vendor Services
                        NinjaTrader Ecosystem Vendor - QuantKey

                        Comment


                          #13
                          Hello QuantKey_Bruce,

                          I've received tracking ID # NT-1310 for this issue.

                          As new releases of NinjaTrader become available, please check the release notes for this ID.


                          Once listed, please update and confirm the behavior is resolved.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Thank you Chelsea.
                            Bruce DeVault
                            QuantKey Trading Vendor Services
                            NinjaTrader Ecosystem Vendor - QuantKey

                            Comment


                              #15
                              Just a quick note - if they are having any trouble reproducing this: the exact same thing happens this morning on CL which just rolled over today to 05-23.
                              Bruce DeVault
                              QuantKey Trading Vendor Services
                              NinjaTrader Ecosystem Vendor - QuantKey

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              574 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              332 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              553 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              551 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X