• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Error on calling 'OnStateChange' method: Out-of-range" Why??

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    "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.
    Any help is appreciated.
    Attached Files

    #2
    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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by XimoTrader, Today, 12:57 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Started by FxInception, Today, 12:27 PM
    2 responses
    10 views
    0 likes
    Last Post FxInception  
    Started by siroya, Today, 10:34 AM
    1 response
    20 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by Leeroy_Jenkins, Today, 11:22 AM
    2 responses
    12 views
    0 likes
    Last Post Leeroy_Jenkins  
    Started by RedDuke, Today, 10:27 AM
    2 responses
    15 views
    0 likes
    Last Post RedDuke
    by RedDuke
     
    Working...
    X