Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Index out of bounds while running the optimizer

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

    Index out of bounds while running the optimizer

    Hello,

    I have a problem while running the optimizer on my strategies.

    I randomly get errors like this : Strategy 'X': Error on calling 'OnBarUpdate' method on bar X: Index was outside the bounds of the array.

    As I said, those errors happens randomly. The bar number that causes the error always changes between optimization (even with identical optimization parameters), and sometimes there are no errors at all (optimization runs fine and returns the results).

    Also, I never get these errors while backtesting or while running my strategies live.

    I searched the forum, and found this post : https://ninjatrader.com/support/foru...x-out-of-range
    However, the solution mentioned in there didn't solve my problem.

    Did anyone ever experienced this problem? Do anyone know why those errors could be so random?

    Thank you,
    Alexis

    #2
    Hi Alexis, thanks for your post.

    This would happen because some aspect of your script is accessing an array index that is not there. E.g. If you run an optimization with parameters that get used to index an array like X 1;20;1,
    If its bar 0 and the script accesses Close[X] where X = 1 you would get this problem. You can also try this with Visual Studio Debugging to break when a .NET exception occurs:


    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    47 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    23 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    33 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    51 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X