Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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?
        BertrandNinjaTrader Customer Service

        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 llanqui, Today, 12:51 PM
                  1 response
                  3 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by llanqui, Today, 11:13 AM
                  6 responses
                  11 views
                  0 likes
                  Last Post llanqui
                  by llanqui
                   
                  Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
                  23 responses
                  70 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by reynoldsn, Yesterday, 04:40 PM
                  3 responses
                  13 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by i2ogu3, Yesterday, 11:31 PM
                  2 responses
                  20 views
                  0 likes
                  Last Post i2ogu3
                  by i2ogu3
                   
                  Working...
                  X