[/CODE]I keep on getting this error
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 'OnStateChange' method: Out-of-range" Why??
Collapse
X
-
"Error on calling 'OnStateChange' method: Out-of-range" Why??
I am trying to code a strategy for my trading system, I have everything down but I keep on getting the same error when I try to use it.
[/CODE]I keep on getting this error
Strategy 'DivergenceIndicator': Error on calling 'OnStateChange' method: 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,
Thank you for the post.
I see that you are accessing series from the OnStateChange override such as High[0] in State.Configure.
You would need to wait till later states such as DataLoaded or historical to access Series data.
I would suggest using Comments to find all of the occurrences where there are errors, meaning to comment out your existing logic until you reach a point where you no longer get the error. You could slowly uncomment code and find items that cause errors in OnStateChange and then move them to OnBarUpdate or a correct state such as State.Historical.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Jltarrau, Today, 05:57 AM
|
3 responses
6 views
0 likes
|
Last Post
by Jltarrau
Today, 07:22 AM
|
||
Started by f.saeidi, Today, 05:56 AM
|
2 responses
8 views
0 likes
|
Last Post Today, 07:17 AM | ||
Started by Pattontje, Yesterday, 02:10 PM
|
2 responses
36 views
0 likes
|
Last Post
by Pattontje
Yesterday, 11:49 PM
|
||
Started by xiinteractive, 04-09-2024, 08:08 AM
|
7 responses
27 views
0 likes
|
Last Post Today, 07:14 AM | ||
Started by Skifree, Today, 03:41 AM
|
2 responses
8 views
0 likes
|
Last Post Today, 07:14 AM |
Comment