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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 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
        548 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X