**NT** Error on calling 'OnBarUpdate' method for strategy: Sequence contains no elements
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
Collapse
X
-
Hello,
Your NinjaScript / C# Code will always be logically processed and evaluate according to your set logic – this can of course lead to unexpected results at times, thus we would suggest to simplify and debug your code to better understand the event sequence it would go through - if you would like please post an example script which replicates the error mentioned so that we may examine it
First of all you would want to use Print() statements to verify values are what you expect - Debugging your NinjaScript code.
For strategies add TraceOrders = true to your Initialize() method and you can then view valuable output related to strategy submitted orders through Tools > Output window - TraceOrders
It may also help to add drawing objects to your chart for signal and condition confirmation - Drawing Objects.
If you would prefer the debug assist of a professional NinjaScript consultant, please check into the following listings - Click here for a list of certified NinjaScript ConsultantsLanceNinjaTrader Customer Service
-
Hello,
I'm not able to replicate this error with this bit of code alone. While I dont know for sure without seeing the rest of the code you may consider adding the following as a check to ensure enough bars have been loaded before your processing begins.
Code:// Checks to make sure we have at least 20 or more bars if (CurrentBar < 20) return;
LanceNinjaTrader Customer Service
Comment
-
Thanks! I just found the issue. I had some misunderstandings in the code where the code was called way before it should have. It called the code and then it realized that the lists that I use in the code are empty at this time. Soo that why I got the error.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by GussJ, 03-04-2020, 03:11 PM
|
11 responses
3,227 views
0 likes
|
Last Post Today, 08:07 PM | ||
Started by andrewtrades, Today, 04:57 PM
|
1 response
13 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
7 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
440 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
12 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
Comment