Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Secondary data series count is always zero

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

    Secondary data series count is always zero

    I'm not sure if I'm doing this correctly, but it seems that my secondary data series count is always zero.
    The _secondaryDataSeries is always zero.
    Code:
                // How I'm adding it
                else if (State == State.Configure)
                {
                    // Secondary data series
                    AddDataSeries(Instrument.FullName, BarsPeriodType.Range, 30);
                }
                else if (State == State.DataLoaded)
                {
                    _secondaryDataSeries = new Series<double>(BarsArray[1]);
                }
    
               // Trying to get regression channel data
               Math.Round(RegressionChannel(_secondaryDataSeries, 35, 2).Upper[1], 2);​

    #2
    Among other things, you can't use Instrument.FullName in State.Configure as the Instrument property may be null causing your indicator to exception out - try sending null instead or use a different overload so you don't have to send which instrument and it will assume the same one on the chart.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello walley,

      Where are you printing BarsArray.Count()? Is this being printed in OnBarUpdate()?

      QuantKey_Bruce is correct, using the Instrument property in State.Configure is not supported, and you would need to use null.

      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."


      "Tips:
      4. For the instrument name parameter null could be passed in, resulting in the primary data series instrument being used.​"
      https://ninjatrader.com/support/help...dataseries.htm

      Testing this on my end, I am seeing BarsArray.Count() has a value of 2.
      https://drive.google.com/file/d/1A-J...w?usp=drivesdk
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Oh, I see. Thanks for the help all.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 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
        554 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