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 chbruno, Today, 04:10 PM
    0 responses
    3 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    6 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by frslvr, 04-11-2024, 07:26 AM
    9 responses
    127 views
    1 like
    Last Post caryc123  
    Working...
    X