Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NTClosePosition() bug?

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

    NTClosePosition() bug?

    Hello,

    I am using eSignal EFS + NT DLL to trade three IB accounts at the same time. If I buy one contracts in each account with stop loss and profit target orders attached as an OCO group for each account position respectively, when I use something like

    function closeAllPositionsInMyIBAccounts()
    {
    NTClosePosition(account1);
    NTClosePosition(account2);
    NTClosePosition(account3);
    }

    to close all positions in three accounts and the related OCO orders, although NT is able to close all positions and cancel all orders without problem, however in almost every test, it pops out two message windows saying ""Can't find order with id = xx blah blah blah" and the corresponding order is shown as "Rejected Can't find order with id = xxx (yyy)", which seems been caused by the same problem as that in http://www.ninjatrader-support.com/v...ead.php?t=7909
    The rejected oder only belongs to account2 and account3.
    I believe something is wrong in the NT DLL implementation and this kind of error message window is very distracting and annoying.

    - Clearpicks

    #2
    The rejected oder only belongs to any of these three accounts.

    Comment


      #3
      Can you please post a screen shot of this error? I beleive its a message from the broker and not native to NinjaTrader but wanted to confirm.
      RayNinjaTrader Customer Service

      Comment


        #4
        Attached is a screenshot of the message window.


        Originally posted by NinjaTrader_Ray View Post
        Can you please post a screen shot of this error? I beleive its a message from the broker and not native to NinjaTrader but wanted to confirm.
        Attached Files

        Comment


          #5
          This is a native IB message. You would need to contact IB support in order to understand why they are issuing this message.

          Comment


            #6
            When cancelling a pair of OCO orders, how does NT DLL or NT do? Suppose the two orders are of order id 100 and 101 respectively but with the same OCO group id. When NTClosePosition() or NTCancelAllOrders() is called, does it sent two commands to IB TWS, each of them cancels one order or NT just uses a special IB TWS API function to instruct IB TWS to close all active orders? If it is the former case, maybe when the instruction to cancel order 100 arrives at IB TWS first, order 101 also gets cancelled because it is in the same OCO group as order 100 is. Then when the instruction to cancel order 101 arrives at IB TWS, no order with 101 exists, which results in the error message.

            - Clearpicks

            Originally posted by NinjaTrader_Dierk View Post
            This is a native IB message. You would need to contact IB support in order to understand why they are issuing this message.

            Comment


              #7
              Valid idea. We'll look into and let you know.

              Comment


                #8
                Clearpicks,

                Would need clarification. The IB error message box, when does it pop up -

                - Only when NTCancelAllOrders is called with NTClosePosition
                - If you ONLY call NTClosePosition (you do not call NTCancelAllOrders) does it still happen?

                So you know, NTCancellAllOrders is redundant when NTClosePosition() is called since NTClosePosition will cancel all orders as well
                -
                RayNinjaTrader Customer Service

                Comment


                  #9
                  It happens even if only NTClosePosition is called. If there is only one IB TWS connected, in some cases this error message does not pop out and in other cases it still pops out. When there are multiple IB TWS connected, depending on the NTClosePosition(account) sequence, in every run the error message pops out when closing positions in accounts which is not the first. For the first account for which NTClosePosition is called, again sometimes the error message does not show up and in other cases it may also show up.

                  - Clearpicks

                  Originally posted by NinjaTrader_Ray View Post
                  Clearpicks,

                  Would need clarification. The IB error message box, when does it pop up -

                  - Only when NTCancelAllOrders is called with NTClosePosition
                  - If you ONLY call NTClosePosition (you do not call NTCancelAllOrders) does it still happen?

                  So you know, NTCancellAllOrders is redundant when NTClosePosition() is called since NTClosePosition will cancel all orders as well
                  -

                  Comment


                    #10
                    We have fixed several issues related to cancellation of IB OCO orders. Situation which rarely comes up but this might resolve this issue you have reproted, I can't be certain. Please let us know after installing the next update that will be out in the next few weeks.
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      This issue can be reliably reproduced in current newest NT release. Could you guys do an in-house test and fix the issue before the next release. Otherwise if after a few week I find the issue is not fixed in next release, I would have to wait another a few week or even months.

                      Best Regards,
                      Clearpicks

                      Comment


                        #12
                        If you can create us a simple bare bones strategy that can demonstrate this on a single account then I will try it in house.
                        RayNinjaTrader Customer Service

                        Comment


                          #13
                          testing script

                          The testing script is uploaded. The name of the file should be changed to .efs. Follow the instruction in the file, you may reproduce some issues I was talking.
                          Attached Files
                          Last edited by clearpicks; 05-28-2008, 10:39 PM.

                          Comment


                            #14
                            Works as expected on my PC.

                            Here is what I tested.

                            - Single account on TWS (commenting out account2)
                            - Single account on TWS and Sim101 account

                            I don't have two IB accounts in my TWS login so I can't test that but it should not matter. The only possible situation that could have an effect is if you are connecting NT to two instances of TWS to get your two accounts. This is no longer supported.
                            RayNinjaTrader Customer Service

                            Comment


                              #15
                              The error message windows only pops out when trading multiple IB TWS accounts at the same time.

                              Being able to connect to multiple IB TWS accounts is a very useful feature, why do you no longer support it?

                              - Clearpicks


                              Originally posted by NinjaTrader_Ray View Post
                              Works as expected on my PC.

                              Here is what I tested.

                              - Single account on TWS (commenting out account2)
                              - Single account on TWS and Sim101 account

                              I don't have two IB accounts in my TWS login so I can't test that but it should not matter. The only possible situation that could have an effect is if you are connecting NT to two instances of TWS to get your two accounts. This is no longer supported.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Shansen, 08-30-2019, 10:18 PM
                              24 responses
                              942 views
                              0 likes
                              Last Post spwizard  
                              Started by Max238, Today, 01:28 AM
                              0 responses
                              9 views
                              0 likes
                              Last Post Max238
                              by Max238
                               
                              Started by rocketman7, Today, 01:00 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post rocketman7  
                              Started by wzgy0920, 04-20-2024, 06:09 PM
                              2 responses
                              28 views
                              0 likes
                              Last Post wzgy0920  
                              Started by wzgy0920, 02-22-2024, 01:11 AM
                              5 responses
                              33 views
                              0 likes
                              Last Post wzgy0920  
                              Working...
                              X