Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

multiseries CurrentBars always == -1 for added data

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

    multiseries CurrentBars always == -1 for added data

    I have a very simple indicator where I add 1 Day data to grab the X day highs/lows easily.

    I am using it in a historical data chart. It never calls OnBarUpdate with BarsInProgress == 1, only 0 for the main data series.

    When I try to retrieve values out of the 1 Day bars it fails because CurrentBars[1] is always == -1 no matter where I am in the chart, there is never anything in there. I don't know what I'm doing wrong here. Why can't I access the 1 day data?

    Code:
    protected override void Initialize()
            {            
                Overlay = true;
                Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Long Term High"));
                Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Short Term Low")); 
                Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Long Term Low")); 
                Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "Short Term High"));
                
                Add(PeriodType.Day, 1); 
            }

    #2
    It seems like if you never call OnBarUpdate for the second data series, you're not going to have any data in BarsArray[1], and that's why you're seeing that CurrentBars[1] == -1.

    Comment


      #3
      I'm supposed to call OnBarUpdate myself for the extra data series? The documentation makes it seem like this is automatically done by their API for you, and you just have to handle the BarsInProgress == 1 or == 2 cases?

      Comment


        #4
        volkie,

        You need to ensure that you have historical data for the daily bars as well in order for it to work. Try loading another chart full of daily data. OnBarUpdate() doesn't need to be called manually. It is called on every historical bar.

        You may also want to try using Try/Catch to see if you can catch any errors the compiler misses.

        Adam P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        153 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        133 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        128 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X