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

Strategy output error: A hosted indicator tried to load additional data.

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

    Strategy output error: A hosted indicator tried to load additional data.

    Hi,

    This is a low importance error/issue (for now). I got the following error when trying to check if the current close is below/above a pivot point (R1/S1) before entry. When I run backtest, I get no executions but following error:

    Code:
    A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.
    1) What does the error mean?
    2) Can pivot point indicator be used in a strategy (to check if close is less or greater than R1/S1 etc.)?

    br,
    Chris

    #2
    Hello Chris,

    The error indicates that an indicator added a dataseries with AddDataSeries() but the host strategy or calling indicator did not.

    From the help guide:
    "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"


    "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.""
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,
      there is a bug somewhere in this regard. I was having trouble with a custom strategy, but could not see any error in programming. Then, I was able to produce the error with the built-in "SampleMACrossOver" strategy.
      I had cloned a Session Template and changed its hours, because I needed to test something starting up on time. When this Session Template is used, the error occurs.

      "A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state."

      I've attached a pic of the session template. I tried trashing charts and creating new ones, different instruments etc, but the problem remained persistent.
      This is v8.0.8

      Cheers,
      saltminer
      Attached Files

      Comment


        #4
        Hi saltminer,

        Please send an email to platformsupport [at] ninjatrader [dot] com for further assistance.

        In the email please include a short description that backtesting the SampleMACrossOver with a custom trading hours template is causing an error to appear in the log.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Problem only when optimizing

          Hi,
          I have a strategy that can load its own intrabar granularity for more accurate backtests. It can use either 1 Minute or 1 Tick dataseries.
          It works fine on a chart and in a backtest, but during an optimise the "hosted indicator tried to load additional data" error stops the optimise immediately.

          I'm using AddDataSeries(...) in State.Configure. Depending on a user input enum parameter, the AddDataSeries will either be not called, or will be called to add a Minute DataSeries or add a Tick DataSeries.

          Is this not possible in the Optimizer, even when this granularity parameter is fixed and not changing throughout the optimisation?

          Thanks,
          saltminer

          Comment


            #6
            Hello saltminer,

            It is not supported to have dynamic variables in the AddDataSeries method.

            From the help guide:

            "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner."

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi,
              is there a way in State.Configure to detect that the strategy is being optimised, and thus the code will ALWAYS (as if hard coded) load the additional dataseries?
              saltminer

              Comment


                #8
                Hello saltminer,

                There is undocumented code shared by Matthew that demonstrates detecting the backtest type.




                That said, it is still not supported to dynamically add data series including using branching commands (if statements).
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by suroot View Post
                  Hi,

                  This is a low importance error/issue (for now). I got the following error when trying to check if the current close is below/above a pivot point (R1/S1) before entry. When I run backtest, I get no executions but following error:

                  Code:
                  A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.
                  1) What does the error mean?
                  2) Can pivot point indicator be used in a strategy (to check if close is less or greater than R1/S1 etc.)?

                  br,
                  Chris
                  Hello,

                  I am getting same error when adding amaPivots indicator..

                  A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.

                  Here is the code I've built with Strategy Builder, but still getting an error...

                  Any help?

                  namespace NinjaTrader.NinjaScript.Strategies
                  {
                  public class TestAmaPivots : Strategy
                  {
                  private NinjaTrader.NinjaScript.Indicators.LizardIndicator s.amaPivotsDaily amaPivotsDaily1;

                  protected override void OnStateChange()
                  {
                  if (State == State.SetDefaults)
                  {
                  Description = @"Enter the description for your new custom Strategy here.";
                  Name = "TestAmaPivots";
                  Calculate = Calculate.OnBarClose;
                  EntriesPerDirection = 1;
                  EntryHandling = EntryHandling.AllEntries;
                  IsExitOnSessionCloseStrategy = true;
                  ExitOnSessionCloseSeconds = 30;
                  IsFillLimitOnTouch = false;
                  MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                  OrderFillResolution = OrderFillResolution.Standard;
                  Slippage = 0;
                  StartBehavior = StartBehavior.WaitUntilFlat;
                  TimeInForce = TimeInForce.Gtc;
                  TraceOrders = false;
                  RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                  StopTargetHandling = StopTargetHandling.PerEntryExecution;
                  BarsRequiredToTrade = 20;
                  // Disable this property for performance gains in Strategy Analyzer optimizations
                  // See the Help Guide for additional information
                  IsInstantiatedOnEachOptimizationIteration = true;
                  }
                  else if (State == State.Configure)
                  {
                  AddDataSeries(Data.BarsPeriodType.Day, 1);
                  }
                  else if (State == State.DataLoaded)
                  {
                  amaPivotsDaily1 = amaPivotsDaily(Close, amaPivotFormulaPD.Floor_Trader_Pivots, amaSessionTypePD.Daily_Bars, amaCalcModePD.Intraday_Data);
                  }
                  }

                  protected override void OnBarUpdate()
                  {
                  if (BarsInProgress != 0)
                  return;

                  if (CurrentBars[0] < 1)
                  return;

                  // Set 1
                  if (CrossAbove(amaPivotsDaily1.PP, Close, 1))
                  {
                  EnterLong(Convert.ToInt32(DefaultQuantity), "");
                  }

                  }
                  }
                  }

                  Thanks

                  Comment


                    #10
                    Hello music_p13,

                    The error message is that the indicator called is adding a dataseries that is not being added to your script (the host).

                    Is amaPivotsDaily an open source indicator you can see the code of?

                    What data series has the indicator added with AddDataSeries()?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Yes, thanks for reply, adding 1 minute and daily dataseries fixed the issue.

                      I am good now, thanks

                      Comment


                        #12
                        Originally posted by NinjaTrader_ChelseaB View Post
                        Hello saltminer,

                        It is not supported to have dynamic variables in the AddDataSeries method.

                        From the help guide:

                        "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner."

                        https://ninjatrader.com/support/help...dataseries.htm
                        The provided link is dead.. can you ..

                        Comment


                          #13
                          Hello traderchef,

                          Welcome to the NinjaTrader forums!

                          Link corrected.
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by TraderBCL, Today, 04:38 AM
                          2 responses
                          17 views
                          0 likes
                          Last Post TraderBCL  
                          Started by martin70, 03-24-2023, 04:58 AM
                          14 responses
                          106 views
                          0 likes
                          Last Post martin70  
                          Started by Radano, 06-10-2021, 01:40 AM
                          19 responses
                          609 views
                          0 likes
                          Last Post Radano
                          by Radano
                           
                          Started by KenneGaray, Today, 03:48 AM
                          0 responses
                          5 views
                          0 likes
                          Last Post KenneGaray  
                          Started by thanajo, 05-04-2021, 02:11 AM
                          4 responses
                          471 views
                          0 likes
                          Last Post tradingnasdaqprueba  
                          Working...
                          X