Indicator 'jBar': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Indicator not workiing
Collapse
X
-
Indicator not workiing
I have a simple indicator that requires 5 or more bars. however when i add indicator nothing happens(no plot) and get the below error in the output window. The same exact window works very fine on some other charts. I did verify the current chart has many bars, infact more days worth of 30min bars. please help.
Indicator 'jBar': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.Tags: None
-
Hello chakriare,
Thanks for your post.
What happens when you load an indicator is that it will start processing, on a bar by bar basis, from the very beginning of data that is loaded in the dataseries of the chart, so if you have 5 days of data the indicator will start on the first bar 5 days ago.
If the code logic looks for a previous bar it will fail on the first bar (count starts at 0) as there is no previous bar. An example of looking at a prior bar would be: if (Close[0] > Close[1]) where 1 represents a prior bar.
To work around the initial loading you can use a check of the current bar number as the first statement in the OnBarUpdate() method. for example:
if (CurrentBar < 5) return; // do not process until 5 bars loaded
It is possible, depending on the code logic you may need more or less than 5.
Please review: http://ninjatrader.com/support/helpG...currentbar.htm
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
161 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
308 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|
||
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
245 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
349 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
179 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|

Comment