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 PopovDS, Today, 11:17 AM
        0 responses
        5 views
        0 likes
        Last Post PopovDS
        by PopovDS
         
        Started by James Cowart, Today, 10:55 AM
        0 responses
        5 views
        0 likes
        Last Post James Cowart  
        Started by ETFVoyageur, Today, 10:27 AM
        0 responses
        4 views
        0 likes
        Last Post ETFVoyageur  
        Started by amousaber, Today, 09:30 AM
        0 responses
        14 views
        0 likes
        Last Post amousaber  
        Started by suraj, Today, 08:51 AM
        0 responses
        8 views
        0 likes
        Last Post suraj
        by suraj
         
        Working...
        X