Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Unable to load bars series ... etc. " error in Strategy Analyzer

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

    "Unable to load bars series ... etc. " error in Strategy Analyzer

    "Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner."

    Hi,

    I'm getting the above error when attempting to run Optimization through the Strategy Analyzer.

    I've read in other posts that we'll have to hard-code values when adding DataSeries to a strategy/indicator. I'm adding the dataseries using the following code:

    Code:
    else if (State == State.Configure)
    {
    if (CalculationType==UniversalCalculationType.SMA || CalculationType==UniversalCalculationType.ATR)
        AddDataSeries(BarsPeriodType.Day, 1);
    }
    What am I doing wrong? Any feedback is much appreciated.

    Thank you.





    #2
    Hello nicbizz,

    What you have shown is variable, its sometimes adding the data and sometimes not depending on your condition. AddDataSeries cannot be conditional, it needs to either always add the hard coded data or not add data, it can't be both.

    If your script in some cases will add data based on that condition you likely need to make a second script for that specific purpose instead of trying to control the secondary series being added.

    The strategy analyzer is not the only location where this could fail, its inconsistent where AddDataSeries can fail when used in a variable way so its best to just always avoid doing that.

    I look forward to being of further assistance.

    Comment


      #3
      Jesse,

      Removing the If condition appears to have fixed the error.

      Thanks!

      Comment


        #4
        Any way to fix this? I can hard-code this for test purposes, but would REALLY like to have this conditional control.

        Comment


          #5
          Hello mase2005,

          At this time there is no option to have AddDataSeries variable. You would need to select the data you wanted to use. The only variable option that AddDataSeries has is for the instrument, you can optionally pass null as the instrument if you wanted to use the same primary instrument. That would help for futures instruments which you use multiple timeframes of the same instrument.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          89 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          135 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          68 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          119 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          69 views
          0 likes
          Last Post PaulMohn  
          Working...
          X