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 cmtjoancolmenero, Yesterday, 03:58 PM
          4 responses
          24 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Brevo, Today, 01:45 AM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by rjbtrade1, 11-30-2023, 04:38 PM
          2 responses
          74 views
          0 likes
          Last Post DavidHP
          by DavidHP
           
          Started by suroot, 04-10-2017, 02:18 AM
          5 responses
          3,022 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by Stanfillirenfro, Today, 07:23 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X