Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TD Ameritrade and OCO's

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

    TD Ameritrade and OCO's

    Hi, I have multiple open positions and at the end of the day if they don't hit their respective Target/Stop, I would like cancel the linked OCO's and close the positions. I know TD Ameritrade makes things difficult, what would be the best way to do this? I've tried various ways but cant seem to get it to work. Any help would be great, thank you!

    #2
    Hello gupagoer,

    Thanks for your post.

    You could cancel the orders with Account.Cancel and then look for the cancellation of these orders in OnOrderUpdate before attempting to close the position, and this should work well with TDA.

    Please see the example I have attached.
    Attached Files

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      Hello gupagoer,

      Thanks for your post.

      You could cancel the orders with Account.Cancel and then look for the cancellation of these orders in OnOrderUpdate before attempting to close the position, and this should work well with TDA.

      Please see the example I have attached.
      Is it possible to use this kind of approach to avoid the "boxed position error" ? The idea is to get a long/short strategy, so wait for the position to close, and then enter the reverse position. I'm trying to do it but I can't get it to work, any help would be appreciated.

      Boxed position error:
      Hi! I have a simple strategy on SPY, on a 5 minute timeframe were it Enters a Long position when MACD crosses above MACD(Avg) and Exits the position when the inverse occurs; and also Enters a Short Position when this latter occurs. Unfortunately it does the first part of the strategy, but after it has Exit the Long Position it

      Comment


        #4
        Hello rocker84,

        Maybe the concept would be similar.. Instead of cancelling an order and waiting for the order to update as cancelled in OnOrderUpdate(), you would instead submit a market order to exit the position, then once the position updates in OnPositionUpdate() as flat, send the new limit or stop order in the opposite direction.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        90 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        137 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        120 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        72 views
        0 likes
        Last Post PaulMohn  
        Working...
        X