Everything compiles fine. I started with strategy builder to get a base code, then built everything out from there, I recently added order instructions and when I went to do a dry run with it, I get the error as I try to enable it.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Error on calling "OnBarUpdate" method on bar 0
Collapse
X
-
Error on calling "OnBarUpdate" method on bar 0
I'm getting this error on a strategy I built. I have tried every conceivable way to resolve it from responses in the forum but it's still not working. Is it possible that it's just not reading the chart data for some reason, and not a simple conflict?
Everything compiles fine. I started with strategy builder to get a base code, then built everything out from there, I recently added order instructions and when I went to do a dry run with it, I get the error as I try to enable it.Tags: None
-
Hello Conceptzx,
What is the full error message?
Ctrl + c to copy the error from the Log tab of the Control Center, Ctrl + v to paste in your reply.
If the full error is stating an index error, see the forum post below.
Chelsea B.NinjaTrader Customer Service
-
Strategy 'CXreversal': Error on calling 'OnBarUpdate' method on bar 2: Index was outside the bounds of the array.
9/11/2023 7:24:10 PM Strategy 'CXC/305165547': Ignored SubmitOrderManaged() method at 9/11/2023 7:24:10 PM: BarsInProgress=0 Action=BuyToCover OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='ExitShorts' FromEntrySignal='ShortA, ShortB, ShortC' Reason='This was an exit order but no position exists to exit'
8/21/2023 10:06:00 PM CancelAllOrders: BarsInProgress=0
8/21/2023 10:06:00 PM CancelAllOrders: BarsInProgress=1
is the NS output I get
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 2)
return;
is how I have it currently configured. Look back set to infinite, tried 1000 days for data series and everything I could think of. I've tried several Protected Override Void settings. The script compiles with no errors and only one warning because I made a parameter to change the Entries per direction in the settings rather then the code.Last edited by Conceptzx; 09-11-2023, 01:33 PM.
Comment
-
Hello Conceptzx,
What is the full error message?
Ctrl + c to copy the error from the Log tab of the Control Center, Ctrl + v to paste in your reply.
What line of code is causing the error? (If you are unsure add unique prints above each condition or action)Chelsea B.NinjaTrader Customer Service
Comment
-
Hello Conceptzx,
If you are unsure add unique prints above each condition or action.
Below is a link to a forum post on using prints to understand behavior.
The last print to appear will be one line above the line with the error.Chelsea B.NinjaTrader Customer Service
Comment
-
System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.StrategyBase] CXreversal
System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.StrategyBase] CXreversal
System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.StrategyBase] CXreversal
System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.StrategyBase] CXreversal
System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.StrategyBase] CXreversal
System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.StrategyBase] CXreversal
System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.StrategyBase] CXreversal
Strategy 'CXreversal': Error on calling 'OnBarUpdate' method on bar 2: Index was outside the bounds of the array.
System.Collections.ObjectModel.Collection`1[NinjaTrader.NinjaScript.StrategyBase] CXreversal
8/21/2023 10:06:00 PM CancelAllOrders: BarsInProgress=0
8/21/2023 10:06:00 PM CancelAllOrders: BarsInProgress=1
Does this make any sense? It fails when I enable.
Comment
-
Hello Conceptzx,
Just to confirm, you are getting this output from the NinjaScript Output window?
None of the prints you have added at all are appearing?
Try printing from OnStateChange() above the State conditions (for all states).
Does this print appear?Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
44 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
124 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
65 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment