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 ageeholdings, 05-01-2024, 05:22 AM
        6 responses
        42 views
        0 likes
        Last Post ageeholdings  
        Started by tony_28217, Today, 07:04 PM
        0 responses
        11 views
        0 likes
        Last Post tony_28217  
        Started by flybuzz, Today, 10:33 AM
        1 response
        9 views
        0 likes
        Last Post flybuzz
        by flybuzz
         
        Started by spencerp92, 10-10-2023, 09:56 AM
        4 responses
        309 views
        0 likes
        Last Post flybuzz
        by flybuzz
         
        Started by samish18, Yesterday, 10:13 AM
        1 response
        26 views
        0 likes
        Last Post NinjaTrader_Eduardo  
        Working...
        X