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

"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
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by sdauteuil, 09-23-2021, 10:16 AM
            4 responses
            1,208 views
            0 likes
            Last Post jacobpescaia44  
            Started by agclub, 04-21-2024, 08:57 PM
            5 responses
            34 views
            0 likes
            Last Post agclub
            by agclub
             
            Started by ESHunter, Yesterday, 08:06 PM
            2 responses
            18 views
            0 likes
            Last Post ESHunter  
            Started by ETFVoyageur, 05-07-2024, 07:05 PM
            19 responses
            150 views
            0 likes
            Last Post ETFVoyageur  
            Started by ETFVoyageur, 05-11-2024, 10:13 PM
            3 responses
            26 views
            0 likes
            Last Post ETFVoyageur  
            Working...
            X