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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X