• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Index was outside the bounds of the array

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

    Index was outside the bounds of the array

    I'm getting this error after an update or out of the blues!
    How do I get rid of it!

    Log: "Error on calling 'OnBarUpdate' method on bar 136691: Index was outside the bounds of the array"

    #2
    Hello johnnybegoode,

    This means an invalid index was used.

    With the error:
    "Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart"
    This message indicates an invalid index was used.

    As one example, calling Close[1] when CurrentBar is 0 (the very first bar) will cause this error.
    The reason for this is because there will not be a bar ago; essentially there is not enough data at bar 0 look back one bar.
    The script will start from the far left of the chart at the very beginning where the CurrentBar will equal 0 and then start working to the right, calling OnBarUpdate() for each bar.
    In this specific example, it would be needed to wait for the second bar to be built (from all series if there are multiple series added), to ensure that you have enough data to call a index 1 bar ago.
    This is especially important when multiple series are added to a single script as the data for all series may not start at the same time.
    Below is a link to the help guide on this specific example of an indexing error.
    https://ninjatrader.com/support/help...nough_bars.htm
    Also, below are links to the help guide on CurrentBar and CurrentBars.
    http://ninjatrader.com/support/helpG...currentbar.htm
    https://ninjatrader.com/support/help...urrentbars.htm

    Indexing errors can also occur when using an invalid index with arrays or collections.
    Below are public links to 3rd party educational sites on arrays and index out of range errors.
    https://www.dotnetperls.com/array


    What was the exact index you tried to use that was invalid?

    Did you ensure the Count of that object is equal to or greater than the index used?
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by jjnc2006, Today, 07:36 PM
    0 responses
    5 views
    0 likes
    Last Post jjnc2006  
    Started by futurenick, Today, 06:26 AM
    1 response
    11 views
    0 likes
    Last Post nkhoi
    by nkhoi
     
    Started by NinjaCustomer, Today, 12:29 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by Steve L, Today, 11:32 AM
    0 responses
    7 views
    0 likes
    Last Post Steve L
    by Steve L
     
    Started by prabbala, Today, 10:41 AM
    0 responses
    4 views
    0 likes
    Last Post prabbala  
    Working...
    X