Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I dont see where is the Error

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

    I dont see where is the Error

    What does this error mean and how do I fix it?

    9/25/2012 11:46:00 PM Strategy Error on calling 'OnBarUpdate' method for strategy 'XXX/2eb771a987a04bf6a26e80b69e17003e': Index was outside the bounds of the array.

    #2
    Originally posted by urbmiranda View Post
    What does this error mean and how do I fix it?

    9/25/2012 11:46:00 PM Strategy Error on calling 'OnBarUpdate' method for strategy 'XXX/2eb771a987a04bf6a26e80b69e17003e': Index was outside the bounds of the array.
    Reads like you are trying to access a bar that does not yet exist, but nobody can really say until we see more of the code that is throwing the problem.

    Comment


      #3
      Originally posted by urbmiranda View Post
      What does this error mean and how do I fix it?

      9/25/2012 11:46:00 PM Strategy Error on calling 'OnBarUpdate' method for strategy 'XXX/2eb771a987a04bf6a26e80b69e17003e': Index was outside the bounds of the array.
      That means that you're accessing a bar that doesn't exist on the chart. For example,
      if(Close[50] > 99.89)
      {
      //do something
      }

      In that example, the system tries to get the closing price of the bar 50 and on the chart there is only 10 bars so it will throw that kind of error.

      Try this one

      if(CurrentBar < 50) return;

      That 50 is the number of bars.

      Comment


        #4
        urbmiranda, what is the largest index back value (i.e. Close[index]) that you're trying to access? If you set the default BarsRequired higher to account for this, would you see a changed outcome on your end?

        Comment


          #5
          Hi, I work with urbmiranda...

          Inside Initalize() block there's the instruction:

          Add(PeriodType.Week, 1)

          which seems to be causing trouble.

          This is what we did:
          We started from scratch, copying the original's strategy code in a new script (we had several strategies together before, so we're trying to make sure no strategy is affecting another one).

          That done, the error i get is as follows:

          "
          Error on calling 'OnBarUpdate' method for strategy 'XXXXX/094d24a9291d4d7ebaabf03dfa84fe59': You must use the overload that has a 'BarsInProgress' parameter when calling the BarsSinceEntry() method in the context of a multi-time frame and instrument strategy.
          "

          Any suggestions?

          Comment


            #6
            Hello SebTr,
            To assist you further can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

            Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

            I look forward to assisting you further.

            *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Originally posted by SebTr View Post
              Hi, I work with urbmiranda...

              Inside Initalize() block there's the instruction:

              Add(PeriodType.Week, 1)

              which seems to be causing trouble.

              This is what we did:
              We started from scratch, copying the original's strategy code in a new script (we had several strategies together before, so we're trying to make sure no strategy is affecting another one).

              That done, the error i get is as follows:

              "
              Error on calling 'OnBarUpdate' method for strategy 'XXXXX/094d24a9291d4d7ebaabf03dfa84fe59': You must use the overload that has a 'BarsInProgress' parameter when calling the BarsSinceEntry() method in the context of a multi-time frame and instrument strategy.
              "

              Any suggestions?
              It means what it says. You created a multi-timeseries script, so you need to use the correct syntax. Here is what the online help says: http://www.ninjatrader.com/support/h...sinceentry.htm

              "The following method signature should be used when working with multi-time frame and instrument strategies:

              BarsSinceEntry(int barsInProgressIndex, string signalName, int entriesAgo)"

              Comment


                #8
                Thanks everyone for your support so far.

                The BarsSinceEntry() on multi-time frame issue is solved now. Thanks for your help.

                We have another problem though: I get once again the error: 'Index was outside the bounds of the array'. Thing is I fail to find in the code where this error might be. I've looked carefully everywhere there's an instruction calling a bar, or data (like Open, Close or SMA functions, indicators, etc)... everything seems to be fine.
                Is there any way I can get a more detailed error log? Or perhaps setting a 'stop point' inside my code, so i can run it line by line and test everything my code is doing?

                Tks!

                Comment


                  #9
                  Originally posted by SebTr View Post
                  Thanks everyone for your support so far.

                  The BarsSinceEntry() on multi-time frame issue is solved now. Thanks for your help.

                  We have another problem though: I get once again the error: 'Index was outside the bounds of the array'. Thing is I fail to find in the code where this error might be. I've looked carefully everywhere there's an instruction calling a bar, or data (like Open, Close or SMA functions, indicators, etc)... everything seems to be fine.
                  Is there any way I can get a more detailed error log? Or perhaps setting a 'stop point' inside my code, so i can run it line by line and test everything my code is doing?

                  Tks!
                  When I am at my wits end, I use this shotgun approach that I detailed in this thread. See if you might want to use it too.



                  Actually after reading that whole thread again, it turns out that the problem/error message we were dealing with is the same one that you have posted.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  656 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  371 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  109 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  574 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  579 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X