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

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 mattbsea, Today, 05:44 PM
        0 responses
        1 view
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        31 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        2 views
        0 likes
        Last Post tkaboris  
        Started by GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,281 views
        0 likes
        Last Post Leafcutter  
        Started by WHICKED, Today, 12:45 PM
        2 responses
        19 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Working...
        X