Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error barsAgo when optimizing

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

    Error barsAgo when optimizing

    Hello,

    When optimizing a strategy I get the error:
    "Strategy 'TestStrategy': Error on calling 'OnBarUpdate' method on bar 63: 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.​"

    If the strategy is executing the 63th bar, why it says "when there are only 4 bars on the chart"?

    Thanks

    #2
    Hello guillembm,

    The error gives a generic example of a reason that would be caused, you would need to debug your code to see what specifically happened in your use case. The error does provide details that the error happened in OnBarUpdate and on bar 63 so you have some information to go on for debugging. Its generally suggested to use prints to diagnose this type of error, place prints in the code in various locations and then when you hit the error check what the last print was, that was the last code that successfully executed.



    JesseNinjaTrader Customer Service

    Comment


      #3
      I am also getting the error "'SMA' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load AUDUSD Default: 15 Minute"

      My code is :

      else if (State == State.Configure)
      {
      AddDataSeries(BarsPeriodType.Minute, 15);
      }​

      Comment


        #4
        Hello guillembm,

        From the details I would be unsure why that message would appear, the SMA does not use a secondary series. We would need a much more specific example of what code is being used to know why that may be happening. Generally you will see that message if your parent script calls an indicator that uses AddDataSeries in its code but the parent script did not add the same data.

        If your primary instrument is not AUDUSD then you would additionally need to do

        AddDataSeries("AUDUSD", BarsPeriodType.Minute, 15);
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Christopher Leggit, Today, 12:04 AM
        0 responses
        6 views
        0 likes
        Last Post Christopher Leggit  
        Started by Carmelisak, Yesterday, 11:22 PM
        0 responses
        4 views
        0 likes
        Last Post Carmelisak  
        Started by unpronounceable1700, Yesterday, 10:35 PM
        0 responses
        12 views
        0 likes
        Last Post unpronounceable1700  
        Started by milfocs, Yesterday, 09:16 PM
        0 responses
        4 views
        0 likes
        Last Post milfocs
        by milfocs
         
        Started by Mr.Hamster, 08-04-2022, 11:40 AM
        7 responses
        193 views
        1 like
        Last Post 286000
        by 286000
         
        Working...
        X