• 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 curious, Today, 02:17 AM
    0 responses
    1 view
    0 likes
    Last Post curious
    by curious
     
    Started by pmmkm, Yesterday, 11:13 PM
    0 responses
    3 views
    0 likes
    Last Post pmmkm
    by pmmkm
     
    Started by pulpiwapi, 03-04-2019, 11:18 PM
    11 responses
    149 views
    0 likes
    Last Post music_p13  
    Started by indy73, 06-25-2019, 10:52 PM
    3 responses
    20 views
    0 likes
    Last Post sledge
    by sledge
     
    Started by priceisking, Yesterday, 12:51 PM
    1 response
    23 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Working...
    X