Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Error on calling 'OnBarUpdate' method
Collapse
X
-
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
-
You are accessing the Closes[1] barSeries. You need to check that barSeries too. Your current check, if (CurrentBar < 120), is on barSeries0.Originally posted by llstelle View PostHi, thanks for the link. I've found the part of the code where the bug exists:
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:for(int i=0; i<Y.Length; i++) { Y[i] = Closes[1][i]; SY += Closes[1][i]; }
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?Code:if (CurrentBar < 120) return;
Thanks!
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
157 views
1 like
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
91 views
1 like
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
143 views
2 likes
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
131 views
1 like
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
107 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment