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 NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    43 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    47 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X