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

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
    JimNinjaTrader Customer Service

    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 Skifree, Today, 03:41 AM
        3 responses
        12 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Started by traderqz, Yesterday, 09:06 AM
        5 responses
        32 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by guillembm, Today, 11:25 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by owensd, 04-21-2024, 11:34 PM
        9 responses
        34 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by trilliantrader, 04-10-2024, 09:33 PM
        7 responses
        25 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X