Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to Match Order State to Execution??

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

    Unable to Match Order State to Execution??

    Need some help here -

    When a buy order is being placed via my NT strategy, the buy goes through to my broker (Ameritrade) just fine but in the NT log, I get the following error, which also puts a halt to my script:

    Unable to Match order state to Execution: Order="blahblah" Name='Purchase' State='Filled Instrument', etc, etc.

    I do have the following bit in my OnOrderUpdate function:

    protected override void OnOrderUpdate(IOrder order)
    {
    if (entryOrder != null && entryOrder.Token == order.Token)
    {
    if (order.OrderState == OrderState.Filled)
    {
    etc...

    So what's going on here? Unfortunately, since my strategy crashed, I wasn't able to sell when I wanted to sell.

    Should I just use Error Handling here? What would be the best idea?

    #2
    saltboy, thanks for the post - which NinjaTrader version are you using currently? You can check under Help > About
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      saltboy, thanks for the post - which NinjaTrader version are you using currently? You can check under Help > About
      I'm using 6.5.1000.12

      Comment


        #4
        Ok, please upgrade to the latest 6.5.1000.13 production release via Help > Download Site and also reset your database's historical trade executions under Tools > Options > Misc, then rerun the strategy.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Ok, please upgrade to the latest 6.5.1000.13 production release via Help > Download Site and also reset your database's historical trade executions under Tools > Options > Misc, then rerun the strategy.
          Unfortunately, after the upgrade and DB wipe, the problem still happened.

          Please let me know if you need any more detail from me - thanks.

          Comment


            #6
            saltboy,

            Please try with the Sim101 account and let us know if you can reproduce with that account on a db reset.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              saltboy,

              Please try with the Sim101 account and let us know if you can reproduce with that account on a db reset.
              Well, the Sim101 account works fine, but I'm not actually placing live trades, so there's no execution to match with a trade state, right?

              This could be a problem on the Ameritrade side, but I'm not sure.

              Comment


                #8
                There would be a virtual execution to map to on Sim101. If it works on Sim101, then it would be an issue with getting that order over to TDA. Is there anyway you can clear out whatever you have on TDA and start from a clean slate there?
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  There would be a virtual execution to map to on Sim101. If it works on Sim101, then it would be an issue with getting that order over to TDA. Is there anyway you can clear out whatever you have on TDA and start from a clean slate there?
                  Josh and folks, the same problem happened again today. I cleaned out my TDA slate and ran the same strategy twice on two different charts - one against Sim101 and one against my Ameritrade Account. The Sim101 posted no errors but the Ameritrade did post errors.

                  In the case of Sim101, the state starts off in pendingsubmit. I don't expect this state in Ameritrade since all orders are instantly submitted.

                  In both cases, the state goes from Accepted, to Working

                  From there, however, I see some discrepancies. In both cases, it looks like it takes two executions to fill the first order of the day. In the case of Sim101, the state changes from Working to "PartFilled Instrument" and THEN to "Filled Instrument". However, in the case of Ameritrade, it goes from "Working" straight over to "Filled Instrument". There is no "PartFilled Instrument" State for Ameritrade, even though it took two executions to fill the order.

                  So, that's where I think the discrepancy lies - NT is expecting a "PartFilled Instrument" state for the first Ameritrade execution and then a "Filled Instrument" state for the second execution, but instead is returned only a "Filled Instrument" state for just the first execution.

                  Because the state that was returned isn't the one it's expecting, the error "Unable to Match order state to Execution" is thrown.

                  And again, at that point, the strategy crashes.

                  I would imagine that if it took only one execution to fill an order, we wouldn't have this problem because "PartFilled" would never be returned as a state - only "Filled" would be returned. But such is the stock market - it takes a lot of executions to fill big orders.

                  This is a pretty serious problem, IMO, and I'm willing to try anything to get it to work.

                  Let me know what we can do here - thanks guys!

                  Comment


                    #10
                    saltboy, thanks for your patience and detailed reply - please contact us using the Help > Mail to Support feature and then check to include your trace and log files for further review of this issue. Thanks
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Bertrand View Post
                      saltboy, thanks for your patience and detailed reply - please contact us using the Help > Mail to Support feature and then check to include your trace and log files for further review of this issue. Thanks
                      Thanks Bertrand - I've just sent off the e-mail with the logs and trace files.

                      Comment


                        #12
                        Thanks saltboy, development informed me that this warning would be thrown if NinjaTrader can't match the exact orderstate 1:1 to your broker - thus if the broker API would skip reporting one state change this message would be the result.

                        For NinjaTrader 6.5 this message is reported if the strategy works with the OnOrderUpdate() method, in OnExecution() it should not be noticed. Anyways this is just a warning for you and can be ignored if you understand the nature of this > the strategy would not be terminated.

                        For NinjaTrader 7 a revised strategy handling logic is employed, which will not be sensitive to this issue.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Bertrand View Post
                          Thanks saltboy, development informed me that this warning would be thrown if NinjaTrader can't match the exact orderstate 1:1 to your broker - thus if the broker API would skip reporting one state change this message would be the result.

                          For NinjaTrader 6.5 this message is reported if the strategy works with the OnOrderUpdate() method, in OnExecution() it should not be noticed. Anyways this is just a warning for you and can be ignored if you understand the nature of this > the strategy would not be terminated.

                          For NinjaTrader 7 a revised strategy handling logic is employed, which will not be sensitive to this issue.
                          Bertrand, so I guess I should just use OnExecution and NOT OnOrderUpdate and

                          Comment


                            #14
                            That should be the work around, yes.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Josh View Post
                              That should be the work around, yes.
                              I guess I should have finished my sentence, but your reply was perfect. Thanks!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, Today, 10:57 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by MacDad, 02-25-2024, 11:48 PM
                              7 responses
                              158 views
                              0 likes
                              Last Post loganjarosz123  
                              Started by Belfortbucks, Today, 09:29 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post Belfortbucks  
                              Started by zstheorist, Today, 07:52 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post zstheorist  
                              Started by pmachiraju, 11-01-2023, 04:46 AM
                              8 responses
                              151 views
                              0 likes
                              Last Post rehmans
                              by rehmans
                               
                              Working...
                              X