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

Error on calling 'OnBarUpdate' method

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

    Error on calling 'OnBarUpdate' method

    Fixed thanks!
    Last edited by llstelle; 11-13-2012, 12:08 PM.

    #2
    llstelle, I would suggest you look into adding try / catch standard C# exception handing to get a better understanding where your code needs modifications to address this issue - http://www.ninjatrader.com/support/f...ead.php?t=9825
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Fixed thanks!
      Last edited by llstelle; 11-13-2012, 12:09 PM.

      Comment


        #4
        Originally posted by llstelle View Post
        Hi, thanks for the link. I've found the part of the code where the bug exists:

        Code:
                    for(int i=0; i<Y.Length; i++)
                    {
                        Y[i] = Closes[1][i];
                        SY += Closes[1][i];
                    }
        I am "accessing an index with a value that is invalid since its out of range" when accessing the closing prices 119 bars ago for the other instrument. That's why I included:

        Code:
        if (CurrentBar < 120)
                        return;
        It works perfectly fine for 1 year's backtest (1/1/2012 to 11/8/2012) but it doesn't seem to fix the problem on just 1 week (11/1/2012 to 11/8/2012) of data. Do you have an idea where is the problem?

        Thanks!
        You are accessing the Closes[1] barSeries. You need to check that barSeries too. Your current check, if (CurrentBar < 120), is on barSeries0.

        Comment


          #5
          Originally posted by koganam View Post
          You are accessing the Closes[1] barSeries. You need to check that barSeries too. Your current check, if (CurrentBar < 120), is on barSeries0.
          Got it! Thank you!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by r68cervera, Today, 05:29 AM
          0 responses
          3 views
          0 likes
          Last Post r68cervera  
          Started by geddyisodin, Today, 05:20 AM
          0 responses
          6 views
          0 likes
          Last Post geddyisodin  
          Started by JonesJoker, 04-22-2024, 12:23 PM
          6 responses
          35 views
          0 likes
          Last Post JonesJoker  
          Started by GussJ, 03-04-2020, 03:11 PM
          12 responses
          3,240 views
          0 likes
          Last Post Leafcutter  
          Started by AveryFlynn, Today, 04:57 AM
          0 responses
          7 views
          0 likes
          Last Post AveryFlynn  
          Working...
          X