Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Index was out of range...".

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

    "Index was out of range...".

    I'm adding a daily bars object,
    Code:
    Add(Symbol, PeriodType.Day, 1); //BarsInProgress ==4
    to my strategy, and then trying to pull yesterdays closing price on a different time frame using:

    Code:
    yestClose = Closes[4][1]
    and I get the index out of range error. I've tried:

    if(CurrentBar < 1)
    return;

    and still get the error. Any ideas why that would be happening? Thanks,

    kc

    #2
    Does your connection / data provider support historical daily data kcsystemtrader?

    You can check it here - http://www.ninjatrader-support.com/H...ricalData.html

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Does your connection / data provider support historical daily data kcsystemtrader?

      You can check it here - http://www.ninjatrader-support.com/H...ricalData.html
      yes, it is IB, and I've tried on my live account as well

      Comment


        #4
        Hmm, are you sure this is BarsInProgress 4? Keep in mind the index for those starts at 0.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Hmm, are you sure this is BarsInProgress 4? Keep in mind the index for those starts at 0.
          BarsInProgress == 0 is an index
          ==1 is ticks on the stock I'm trading
          ==2 is 1 MIN on the stock I'm trading
          ==3 is 5 MIN on the stock I'm trading
          ==4 is Day on the stock I'm trading

          on BarsInProgress == 1, every tick, I wait for ten 10 ticks before running any code using:

          Code:
          if(CurrentBar < 10) 
          return;
          then
          Code:
          Closes[4][1]
          runs and I get the error in the log saying the index was out of range. Meanwhile I have a daily chart loaded that looks fine and the historical data has definitely been downloaded and should be accessible

          Comment


            #6
            kcsystemtrader, please check into this sample and the sequential order in which the bars objects are added - http://www.ninjatrader-support2.com/...ead.php?t=6652

            Please add the slower charts first and then progress to the fastest one you use.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X