Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

atomic OCO orders and internet disconnections

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

    atomic OCO orders and internet disconnections

    Hi,

    As the internet is not guaranteed to remain connected at all times, does Ninja perform atomic operations to IB (and other trading platforms) to ensure that OCO bracket orders are correctly placed at the IB trading servers at the same time entry orders are placed?

    I have seen a situation where an order was placed to take a position and when the OnExecution event arrived, stop loss and profit OCO orders were to be subsequently placed and associated with the open position. During the interviening time between the initial order being placed and the order being filled at IB, the internet connection to the client PC failed (for an extended period) and a naked order was left active on the account. When the connection was subsequently recovered, the market had moved against the account resulting in a significant loss to the account.

    Does the SetStopLoss method provide the ability to perform an atomic OCO order simultaneously when the initial order is placed?

    I'm developing for NT7 and I see there is an entry for "Unmanaged" orders however this section of the documentation only contains "Enter topic text here"

    Regards,

    Paul

    #2
    Paul, there's of course always the risk in electronic trading to receive what we call an 'inflight' execution -



    That being said, the Set() methods do offer placing OCO orders, however it will depend on the executing brokerage technology if this OCO handling is done on your local PC or natively on the brokers server -

    Note: This information is relevant for NinjaTrader 7 only. For NinjaTrader 8, please click here (https://ninjatrader.com/support/helpGuides/nt8/where_do_your_orders_reside_.htm). CQG Orders in a state "Accepted" or "Working" are at the exchange. If the exchange does not support a specific order type, the
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Thanks for getting back to me so fast.

      Originally posted by pbcah
      Hi,

      As the internet is not guaranteed to remain connected at all times, does Ninja perform atomic operations to IB (and other trading platforms) to ensure that OCO bracket orders are correctly placed at the IB trading servers at the same time entry orders are placed?
      Originally posted by NinjaTrader_Bertrand View Post
      That being said, the Set() methods do offer placing OCO orders, however it will depend on the executing brokerage technology if this OCO handling is done on your local PC or natively on the brokers server -

      http://www.ninjatrader-support2.com/...ead.php?t=5349
      Bertrand, being specific to one target platform (Interactive Brokers), I see by your web reference that OCO orders are handled natively on the IB servers.

      Does this mean that as manually occurs in the IB TWS now, do IB OCO orders generated by NT7 cause the IB TWS to transmit all the orders as one atomic operation (computing term for simultaneously and none of the sub-operations are valid if any are not completed [BTW, I'm not trying to be offensive just clear])?
      Originally posted by pbcah
      I have seen a situation where an order was placed to take a position and when the OnExecution event arrived, stop loss and profit OCO orders were to be subsequently placed and associated with the open position. During the interviening time between the initial order being placed and the order being filled at IB, the internet connection to the client PC failed (for an extended period) and a naked order was left active on the account. When the connection was subsequently recovered, the market had moved against the account resulting in a significant loss to the account.

      Does the SetStopLoss method provide the ability to perform an atomic OCO order simultaneously when the initial order is placed?

      Originally posted by NinjaTrader_Bertrand View Post
      Paul, there's of course always the risk in electronic trading to receive what we call an 'inflight' execution -

      I'm working with some older code and see this non-atomic operation to place a position then when the OnExecution event is received, it places a subsequent OCO order. This existing code seems dangerous and in fact I have seen the scenario I've listed result in real losses.

      From what you've provided here, I feel that NT7 provides the ability to place what amounts to an IB Bracket order then I can perform a "Submitt" to get the IB TWS to transmit it to the server as one atomic operation. Is this correct?
      I'm developing for NT7 and I see there is an entry for "Unmanaged" orders however this section of the documentation only contains "Enter topic text here"
      Can you please send me info on this portion of my question?

      Regards,

      Paul

      Comment


        #4
        Paul, IB does OCO on its servers natively. This means that if your strategy submits a bracket order (OCO) and your internet connection goes down when half of the OCO is hit, the other order will be canceled automatically.

        I'm not exactly sure what you mean by 'atomic' though, so I could be wrong. I take it to mean 'submit both orders as a simultaneous operation'. Please correct me if I'm wrong.

        As for Unmanaged orders, there isn't much to it. Here is the information from the NT7 announcement page:

        New Unmanaged Order Submission
        In 6.5 some users were burdened with our "Internal Order Handling" rules. We have introduced unmanaged order submission which bypasses the convenience of our order handling layer. This lower level of programming allows you to do what you want relative to order submission/management without any limitations other than any imposed by your broker. There are only three methods, SubmitOrder(), ChangeOrder() and CancelOrder(). You then get the flexibility of managing your orders how you see fit and optionally handling rejections.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Originally posted by pbcah View Post
          ... does Ninja perform atomic operations to IB (and other trading platforms) to ensure that OCO bracket orders are correctly placed at the IB trading servers at the same time entry orders are placed? ...
          Hi folks,

          I am too interested in an answer to Paul's question, especially concerning atomic order transmission to the IB server.

          If entering a bracket order in TWS, then 3 orders are submitted as a bundle (atomic), for example a entry-limit-order and a bracket with exit-limit-target and exit-stoploss. After submitting that bracket in TWS, I see these 3 orders waiting for execution.


          What happens if I execute the same order with NT?
          1. NT sends 3 orders to the IB server, a entry-limit-order and the 2 bracket orders.
          2. NT sends a nacked enter-limit-order to the IB server. Once the entry-order is executed, NT sends the exit-bracket to the IB server.
          Regards
          Ralph

          Comment


            #6
            Ralph, it would be your second scenario, once the entry is filled, the exit bracket is sent and providing the native OCO is used, the IB servers would handle the OCO logic then.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thanks Bertrand,

              yes, that is my understanding how NT order handling works.

              I am still wondering if it is possible to enable/implement somhow scenario #1, because that would be save trading (relatively). I think that would be something NT would need to implement because I don't see the possibility to emulate this behaviour with the order management capabilities available in NT 6.5.

              And the IB-API would need to provide the capability to transmit such kind of ordes too.

              Regards
              Ralph

              Comment


                #8
                Ralph, thanks for the feedback I can understand you well, do you a certain IB order type in mind? I'm only aware of adding an exit bracket after fill - http://www.interactivebrokers.com/en/p.php?f=orderTypes
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Not a certain order type but an order entry feature. I am using this save kind of order entry for the chart-trader and book-trader in IB. Attached you can see an example for the chart-trader. Picture #1 shows the order definition mask to customize a button for chart-trader and picture #2 shows how the submitted order is displayed. All three orders are held at the IB server (the entry order is a stop limit order), no more action is needed after the entry order gets filled once.

                  Regards
                  Ralph
                  Attached Files

                  Comment


                    #10
                    Thanks for posting those details Ralph, we'll take a look.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Bertrand View Post
                      Thanks for posting those details Ralph, we'll take a look.
                      Hi Bertrand,
                      I am new to using your excellent trading tool however what I've seen and used is impressive and this is a comment coming from a 30 year veteran systems engineer.

                      With this in mind, I'd like to paint the scenario that first alerted me to this as a possibly dangerous feature of Ninja and perhaps I am using your tool incorrectly so I'd appreciate your views.

                      I have a friend who has started using Ninja in the past 3 months. He uses it in conjunction with an excellent risk management product. He reports that his trading has become very profitable since starting to use Ninja and the risk tool, at least until he suffers a major loss which has happened 2-3 times. He initially didn't notice the correlation between the loss of his IB connection and him suffering some large losses. What was happening was that occasionally (more frequent than you think), he would be in the process of placing an order that included an automated stop loss OCO and he would loose his connection to the IB server. What we determined later was that the first half of the OCO was being placed and filled but the second half was not due to the loss of the connection.

                      As my friend is doing frequent trades with an automated tool, getting into and out of the market is a very rapid fire process so when the connection was lost, it did not seem like a big deal however, what had happened was that he had in fact placed a naked leveraged order on a rapidly moving market. When the connection recovered (hours later), he found that he had a large loss that effectively wiped out his previous weeks gains.

                      So when you say "we'll take a look", perhaps you could consider this scenario and I would appreciate it if you could also consider putting the resolution of this issue at the top of your BUG list as it is costing people real money on both the NT6.5 and NT7 releases. IB allows you to setup a bracket order in their TWS that is then sent to the market using a single transmit operation. From what I have been able to work out, IB performs this operation as a computing-atomic operation.

                      Regards,

                      Paul

                      Comment


                        #12
                        Paul, thanks for the kind words and sharing your feedback, observations and insight into the issue - we definitely appreciate it.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Bertrand View Post
                          Paul, thanks for the kind words and sharing your feedback, observations and insight into the issue - we definitely appreciate it.
                          yes but Bertrand, can you give me an idea of when you are committed to correcting this serious issue?

                          Comment


                            #14
                            Paul, as mentioned previously your valuable feedback and suggestions have been noted down on our feedback list - unfortunately I can't give an ETA nor commitment on this.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_Bertrand View Post
                              Paul, as mentioned previously your valuable feedback and suggestions have been noted down on our feedback list - unfortunately I can't give an ETA nor commitment on this.
                              Bertrand, do you see leaving traders naked in the market with no opposing Stop Loss as a significant fault?

                              I have implemented your recommended approach to handling bracket orders and see that for some reason Ninja waits to place associated OCO bracket orders until after a position has been filled. This is how I have implemented it and it appears to work except in the circumstance that I've described.

                              The impact on trading using an automatic strategy is that it is now necessary to closely monitor every operation to ensure there has not been a disconnect. This would be quite disappointing to Ninja traders as after all isn't this one of the attractive propositions that will reduce or remove the tedium of sitting at a machine for hours watching charts?

                              I would like Ninja managers to consider scheduling one small change to the NT7 beta that will alleviate this issue and would not require a great deal of re-programming or testing and you could extend a modal switch to derived classes to turn it on or off for those who don't want it. Can you at least allow your managed orders to send the Stop Loss order at the same time as the entry order as a true OCO? The SL can be adjusted later to accommodate slippage in the same manner when the execution price is known at the same time as the associated Profit target order is sent (although this should also be sent when the entry order is sent).

                              The benefits of this small change will be:

                              a) Traders will no longer need to baby sit NT + IB trading as they will not be left in the market naked.
                              b) NT7 will be utilising platforms like the TWS in the manner that they have been designed.
                              c) NinjaTrader's product will be seen as kick-arse.
                              d) Traders' will no longer loose erroneous large amounts of money after trading with NT.

                              In my considered opinion, I see this issue as a B class fault with Ninja (the work around is to personally scrutinise all transactions) which can result in major losses being incurred by using it as a trading platform in its standard configuration. Please take this comment as my professional opinion and I do not intend any insult related this overall excellent product.

                              Regards,

                              Paul
                              Last edited by pbcah; 05-16-2010, 02:45 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Ashkam, 04-29-2024, 09:28 AM
                              4 responses
                              42 views
                              0 likes
                              Last Post Ashkam
                              by Ashkam
                               
                              Started by nightstalker, Yesterday, 02:05 PM
                              1 response
                              29 views
                              0 likes
                              Last Post NinjaTrader_Eduardo  
                              Started by dcriador, Today, 02:09 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post dcriador  
                              Started by nicthe, Today, 07:38 AM
                              4 responses
                              21 views
                              0 likes
                              Last Post bltdavid  
                              Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
                              30 responses
                              98 views
                              0 likes
                              Last Post cmtjoancolmenero  
                              Working...
                              X