Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Growing list of TD issues

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

    #16
    sublime,

    You have to wait till NT recognizes your position before you can call the Exit() method.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      Originally posted by heech View Post
      What I did is call ExitLongLimit in my OnOrderUpdate function.

      Or if you're concerned about partial fills (if memory recalls, that's also an issue on TDA)... you might want to do it inside OnExecution.

      FWIW, I didn't really like TDA as a broker's handling of my stop orders. It's just a suspicion, but I couldn't help but feel there were several times the price dipped lower just so they could fill my stop order. In other words, share price would dip to my stop price for a single trade, and then bounce back up.

      So, I ultimately moved to "simulated" stop orders using OnMarketData().
      Yeah, I might try to call ExitLongLimit on OnPositionUpdate, that would probably be good enough for me. My Stop is really just for extreme drops in the market, It usually is never hit. But, now it's apparent that the limit and stop are required to be sent together if I use the set methods. Either way... I might try some of these work-arounds before I give up on the TDA adapter.

      But much of my frustration could have been avoided if I would have known of these limitations. I would ask NT to post the known limitations of the different adapters so the strategy developers can see the issues before strategy creation and testing. It would give the users an opportunity to pick a broker that more meets our needs. And it would save NT support hours of explaining the same issue over and over.

      Comment


        #18
        We are thinking about how to properly publish these limitations and will provide something shortly.

        Comment


          #19
          Originally posted by NinjaTrader_Dierk View Post
          We are thinking about how to properly publish these limitations and will provide something shortly.
          That would be incredibly helpful, Dierk.

          What might be a bigger project, but would be a HUGELY HUGELY valuable project... is if you guys declared an open interface for the broker adapters, and let us both debug/write our own adapters.

          From what I've seen, your core platform is very well written, and basically bug-free. At least, I haven't come across any sticking problems. It's only the broker adapters that seem to be giving us issues.

          By opening up the broker adapters (and making available whatever adapter code you have now):

          - we as developers can help maintain this stuff + bug hunt, without you guys compromising your product + customer base,

          - best of all, we can start implementing adapters to OTHER BROKERS. I for one would LOVE to see a generic FIX adapter!

          If you guys made this possible for NT 7, it would really put your platform on the next level.

          Comment


            #20
            Unfortunately we have no plans to open up the platform for 3rd party broker adapter development at this time. Thanks for your suggestion though.

            Comment


              #21
              Ok, so I've had some time to re-code some of my strategies and run them in live simulation. I've taken the course of not using the Set() methods for opening a Target / Stop Loss OCO order. Instead, I'm using the OnPositionUpdate like so:

              protected override void OnPositionUpdate(IPosition position)
              {
              if (position.MarketPosition == MarketPosition.Long)
              {
              if (Position.Instrument.FullName == "QLD")
              {
              ExitLongLimit(2,true,position.Quantity, position.AvgPrice + (position.AvgPrice*profit),"MT2QLDTGT","MT2QLDOpen ");

              } else
              {
              ExitLongLimit(3,true,position.Quantity, position.AvgPrice + (position.AvgPrice*profit),"MT3QIDTGT","MT3QIDOpen ");
              }
              }
              }

              I didn't want to use the overload, but I think its the only way to keep it alive past the bar. This method worked okay in live simulation. I did notice that when the limit order was activated, it sometimes didn't exit all shares. For instance, it's long 3987 shares of QID. Once the limit is activated, it sells all but 510 shares in a series of orders. It sells them in separate executions in shares of 5, 6, 500, 2967, and 8.

              For some reason, it doesn't sell 510 of the original 3987 shares. It happened on the prior order as well. It bought 11066 shares of QLD and when the limit order was activated, only sold 6263 and left 4803 still in the market.

              Now when the strategy generated a close order, it closed the remaining position in both instances. I've just never seen it leave part of the limit order forever open, even as the price continues to move above the limit price. I can only surmise that it has something to do with how I'm calling the limit order from within the strategy.

              The log shows that its creating a series of PlaceOrders() with cooresponding Amended matching orders. And in the first case of the remaining 510 shares, the log also shows a "Entered internal PlaceOrder()" to sell the 510, but then immediatelly generates a "Ignored PlaceOrder() method" because 'There already is a matching, terminal exit order in place'. Just wondering if I'm calling this method incorrectly.

              Also, we know an ExitLong generated by the strategy will blow up an existing Limit and Stop loss OCO pair in TD. However, will the ExitLong blow up if I only have the limit in TD that is generated with the ExitLongLimit method from above? I've already been told I can't cancel the limit order, so I'm guessing this will not kill the strategy. Works in simulation, but as you know.... that doesn't mean much.

              Comment


                #22
                Just a guess, but perhaps you're supposed to not enter a new Exit order within OnPositionUpdate... and just wait for position to go to zero?

                I've stayed away from limit orders so far, partly because I'm afraid of this level of complexity. Look forward to finding out if the answer is easy.

                Comment


                  #23
                  sublime,

                  Limit orders are NOT guaranteed to ever reach a Filled state. Depending on market conditions it is very possible to get partial fills or even no fills. The ignoral should not influence your order. Your ExitLongLimit() is still active and working.

                  A close order on the other hand (I'm guessing you mean a market order) is pretty much as much of a guarantee for a fill as you will ever get, so that is why you see it close your positions.

                  Not sure I follow your comment on not being able to cancel limit orders. You can cancel an ExitLongLimit() order either by letting it expire or explicitly calling CancelOrder() on it.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #24
                    Originally posted by NinjaTrader_Josh View Post
                    sublime,

                    Limit orders are NOT guaranteed to ever reach a Filled state. Depending on market conditions it is very possible to get partial fills or even no fills. The ignoral should not influence your order. Your ExitLongLimit() is still active and working.

                    A close order on the other hand (I'm guessing you mean a market order) is pretty much as much of a guarantee for a fill as you will ever get, so that is why you see it close your positions.

                    Not sure I follow your comment on not being able to cancel limit orders. You can cancel an ExitLongLimit() order either by letting it expire or explicitly calling CancelOrder() on it.
                    Ok, I see what's happening. With the onPositionUpdate method, the Limit order is being amended on every partial fill of the market exit order. So, it may take 5 partial fills to exit the entire position, and my code still sees a long position and modifies the quantity of the Limit order. What's the easiest way to avoid this? In the OnBarUpdate, should I just call CancelOrder() on the Limit order after I call the ExitLong() ?

                    I believe this also happens when the limit price is reached as well. As the broker executes partial fills in exiting the position, the onPositionUpdate sees a reduced position and amends the Limit order. I don't think this is necessary. I just want to execute on the original Limit order. Should I not use onPositionUpdate?

                    Comment


                      #25
                      You can just filter your logic in OnPositionUpdate further to not make amends. You can detect partial fills by decreased position quantities, but steady market position direction.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #26
                        Originally posted by NinjaTrader_Josh View Post
                        You can just filter your logic in OnPositionUpdate further to not make amends. You can detect partial fills by decreased position quantities, but steady market position direction.
                        I like it. I'm amending only on position increase.

                        Comment


                          #27
                          Ok, Josh... on the road to progress once again. My change to the onpostionupdate() works perfectly in creating the exitlonglimit(). When the limit price is hit, it exits the entire position. If there is a partial fill, the status correctly states so and fills it at the earliest moment. The strategy made $2500 in live simulation and the output file looks great.

                          So before I try this live, please answer this question. Because of the limitations with TDA, if I have a working exitlonglimit() order and my strategy issues an ExitLong() order, will this blow up the strategy? Will TDA give me an error saying there is already a working exit order and this exceeds the open position and everything explodes? Or will TDA cancel the exitlonglimit() order and process the exitlong() order?

                          It works in simulation, but will it work through the adapter? Remember, It's not the limit and stop loss OCO order issued through the Set()... which we know will explode if an exitlong() is issued.

                          If it will not work, I'm guessing I would need to CancelOrder() the Limit order... and just need a little direction on the best place to issue that command... as in, which method.

                          Comment


                            #28
                            sublime,

                            You may want to cancel the ExitLongLimit() no matter what before the ExitLong(). Reason is what if your price actually hit the limit order and it was triggered before the exit long could report back. Then you now have an overfill and are actually in a short position as both exits fill out.

                            In fact, the best approach I would suggest would even be to just modify the ExitLongLimit() to an arbitrarily low value to guarantee it triggers and gets filled instead of submitting ExitLong(). That way you don't have to wait for cancellation and submission of a new order or worry about the overfill scenario.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #29
                              Originally posted by NinjaTrader_Josh View Post
                              In fact, the best approach I would suggest would even be to just modify the ExitLongLimit() to an arbitrarily low value to guarantee it triggers and gets filled instead of submitting ExitLong(). That way you don't have to wait for cancellation and submission of a new order or worry about the overfill scenario.
                              Josh,

                              Really, really, really good advice. I was trying to figure out a similar problem, re: going from limit->market, without managing to screw things up. This seems like a really elegant way to go.

                              Sorry if I missed this discussion below though, how do we modify the price of an existing limit IOrder?

                              Comment


                                #30
                                Just call ExitLongLimit again and only change the price parameter.
                                Josh P.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Haiasi, 04-25-2024, 06:53 PM
                                2 responses
                                17 views
                                0 likes
                                Last Post Massinisa  
                                Started by Creamers, Today, 05:32 AM
                                0 responses
                                5 views
                                0 likes
                                Last Post Creamers  
                                Started by Segwin, 05-07-2018, 02:15 PM
                                12 responses
                                1,786 views
                                0 likes
                                Last Post Leafcutter  
                                Started by poplagelu, Today, 05:00 AM
                                0 responses
                                3 views
                                0 likes
                                Last Post poplagelu  
                                Started by fx.practic, 10-15-2013, 12:53 AM
                                5 responses
                                5,408 views
                                0 likes
                                Last Post Bidder
                                by Bidder
                                 
                                Working...
                                X