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 cmoran13, Yesterday, 01:02 PM
            0 responses
            29 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            21 views
            0 likes
            Last Post PaulMohn  
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            160 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            95 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            148 views
            2 likes
            Last Post CaptainJack  
            Working...
            X