• 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

Error only for Optimization, Accessing an index out of range

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

    Error only for Optimization, Accessing an index out of range

    Hi, I keep getting this error running the Backtest type "Optimizer" on my strategy, however a "Standard" run works just fine.

    Indicator 'ATR': 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.
    Strategy 'Algo1': Error on calling 'OnBarUpdate' method on bar 145: 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.

    I am using " if (CurrentBar < X) { return;} " in OnBarUpdate(). Note that the 145 in the output/error log is +1 the value I use for X. I am running the most recent version of NT8 and have tried running this particular strategy on multiple PCs and have the same problem.

    Was there an update recently to the ATR indicator maybe or something else because this code used to be able to run the Optimizer without an issue. Or maybe it there some variable persistence issue with the optimizer? I am able to get

    Any help diagnosing would be greatly appreciated!

    Thanks,
    John

    #2
    Solved. Had to check "Optimize Data Series" box for some reason it works even though I'm not using it as a variable to iterate over

    Comment


      #3
      Hello John,

      Thanks for your posts.

      I do not think those issues would be fixed by checking "Optimize Data Series." Those errors are more related to an indexing issue where you are trying to access something that is not there. Typically this is seen when a calculation is made looking back so many bars before those bars have been processed. (This is where we make CurrentBar checks.)

      There could have been an issue where the strategy was not compiled to include this check, or the issue may have been due to another type of indexing issue. For example, referencing an array or dictionary that does not have an element at the index being accessed. If the issue is unrelated to needing a certain number of bars, I may suggest adding debugging prints to find out which line is throwing the error to learn more about the issue.

      More information relating to CurrentBar checks and indexing errors relating to not enough bars being available can be found here - https://ninjatrader.com/support/help...nough_bars.htm

      Debugging tips can be found here - https://ninjatrader.com/support/help...script_cod.htm

      If there is anything else we can do to help, please let us know.
      JimNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by profitabletrader306, Today, 12:00 AM
      0 responses
      2 views
      0 likes
      Last Post profitabletrader306  
      Started by marcelodelta, Yesterday, 08:28 PM
      2 responses
      11 views
      0 likes
      Last Post marcelodelta  
      Started by junkone, Yesterday, 09:06 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by ferenc., Yesterday, 04:54 PM
      2 responses
      17 views
      0 likes
      Last Post ferenc.
      by ferenc.
       
      Started by rwilliam, Yesterday, 03:51 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Working...
      X