Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy calling a Multiple BarsInProgress Indicator

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

    Strategy calling a Multiple BarsInProgress Indicator

    I used the Strategy Builder to build the code for this operation. I then copied it into the strategy I am building.

    When I start the strategy, The strategy shuts itself off during startup. I get the following error.

    2023-08-22 10:45:04:063 ERROR: 'RJayTradingSystemDivergenceCyclesMTFS' tried to load additional data.
    All data must first be loaded by the hosting NinjaScript in its configure state.
    Attempted to load ES SEP23 Globex: RJay's RenkoSpectrum 2.0 Bars 6 - 1


    Strategy Code being used is as follows:

    public class DivergenceCyclesStrategy08092023 : Strategy
    {​

    private RJayTradingSystemDivergenceCyclesMTFS RJayTradingSystemDivergenceCyclesMTF_Data;

    if (State == State.DataLoaded)
    {​
    RJayTradingSystemDivergenceCyclesMTF_Data = RJayTradingSystemDivergenceCyclesMTFS(Close, 14);

    // RJayTradingSystemDivergenceCyclesMTF_Data.Plots[0].Brush = Brushes.Black;
    // RJayTradingSystemDivergenceCyclesMTF_Data.Plots[1].Brush = Brushes.Transparent;
    // RJayTradingSystemDivergenceCyclesMTF_Data.Plots[2].Brush = Brushes.Transparent;​

    AddChartIndicator(RJayTradingSystemDivergenceCycle sMTF_Data);
    }
    }

    How do I get the data for the second bars in progress to load from the strategy?

    How do I clear this error?

    Do you have any code snippets I can look at?
    Last edited by RJay; 08-22-2023, 09:07 AM.
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    #2
    Hello RJay,

    Thank you for your post.

    In order to resolve the error, you will need to call AddDataSeries() in your strategy for each added series in the indicator. This is also noted in the help guide:
    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."
    You could add the additional series from the "Additional Data" screen of the builder and copy that to your strategy:Or you could call AddDataSeres() in the unlocked script directly:Please let us know if we may be of further assistance.

    Comment


      #3
      I addedd the AddDataSeries code of the Indicator to the strategy code and the strategy now appears to be working. Thanks.
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      48 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X