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

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 rocketman7, Today, 02:12 AM
        7 responses
        31 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by guillembm, Yesterday, 11:25 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by junkone, 04-21-2024, 07:17 AM
        10 responses
        149 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by tsantospinto, 04-12-2024, 07:04 PM
        6 responses
        101 views
        0 likes
        Last Post tsantospinto  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        7 responses
        28 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X