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 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:


    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    36 views
    0 likes
    Last Post love2code2trade  
    Started by alifarahani, Today, 09:40 AM
    2 responses
    13 views
    0 likes
    Last Post alifarahani  
    Started by junkone, Today, 11:37 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by pickmyonlineclass, Today, 12:23 PM
    0 responses
    1 view
    0 likes
    Last Post pickmyonlineclass  
    Started by frankthearm, Yesterday, 09:08 AM
    12 responses
    44 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X