Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Failed to process 'OnOrderChangedNow': 'Index was outside the bounds of the array.'

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

    Failed to process 'OnOrderChangedNow': 'Index was outside the bounds of the array.'

    I'm getting this error on a live account and not sure whats causing it. I'm placing orders using CreateOrder in a new indicator I wrote. Because OnOrderChangedNow is throwing an error OnOrderUpdate with state filled is not being called. I am not using OnOrderChangedNow in my code. Any ideas on how to fix it? Attached is the trace log.
    Last edited by hurleydood; 03-18-2020, 12:55 PM.

    #2
    Hello hurleydood,

    Thanks for your post.

    OnOrderChangedNow threw an indexing error and this method would be internal to NinjaTrader. I would like to see how the issue can be reproduced.

    Do you see this error on the latest version of NinjaTrader 8, release 21?

    Is this error reproducible with your script? If so, could you share a reduced example that we can use to hit the error on our end?

    I see that you have eliminated personal information and only provide a snippet of the trace file. I've linked it in our internal ticket and removed it from your post in case there was some personal information that is still within.

    I look forward to assisting.

    Comment


      #3
      I'm running release 21. I am using this script below, https://ninjatrader.com/support/foru...188#post788188
      In my version I enter a position when the button is clicked. When OnOrderUpdate is called with filled state I then create stop and target oco orders which end up not running. I'll get you the code if you can't reproduce with the original code.
      Last edited by hurleydood; 03-18-2020, 01:46 PM.

      Comment


        #4
        Ok. You don't have to worry about this other than maybe better backtracing.
        I've cleaned up the code and added extra debugging and it turned out the order ID gets changed when the order is accepted by the live broker.
        When OnOrderUpdate is called I was using an the original order ID from CreateOrder and stored it into an array which caused the out of bounds array error when it couldn't find the order. Works fine with sim because the order ID never changes. Thank you.

        Is there a way to track the order ID changes?
        Last edited by hurleydood; 03-18-2020, 05:29 PM.

        Comment


          #5
          Hello hurleydood,

          Thanks for our patience.

          The Order ID would change when the order is Accepted/Working when it is received outside of NinjaTrader. If you print out the full order string (order.ToString()) you can see when the ID changes and when specific order states change.

          You could also consider creating unique order names for tracking and store those in a Dictionary to keep track of your orders.

          We look forward to assisting.

          Comment


            #6
            Thanks I went with unique names. Thanks for your help.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X