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
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!
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
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 PhillT, 04-19-2024, 02:16 PM
|
4 responses
34 views
0 likes
|
Last Post
by PhillT
Today, 04:24 PM
|
||
Started by ageeholdings, 05-01-2024, 05:22 AM
|
5 responses
37 views
0 likes
|
Last Post
by ageeholdings
Today, 03:21 PM
|
||
Started by reynoldsn, Today, 02:34 PM
|
0 responses
11 views
0 likes
|
Last Post
by reynoldsn
Today, 02:34 PM
|
||
Started by nightstalker, Today, 02:05 PM
|
0 responses
18 views
0 likes
|
Last Post
by nightstalker
Today, 02:05 PM
|
||
Started by llanqui, Yesterday, 09:59 AM
|
8 responses
30 views
0 likes
|
Last Post
by llanqui
Today, 01:57 PM
|
Comment