Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged Orders

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

    Unmanaged Orders

    When I try to have both a long and short submit order open NT cancels my orders when I try to open an opposite order.

    I submit my long using this code below.

    Code:
    SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, 1, Close[0],0, oco, "Long limit entry");
    Is it possible to have both buys and sells open with unmanaged orders? If so how can we do this in code?

    #2
    Hello r3n3v,

    Below is a link to an example of bracket entry OCO orders using the unmanaged approach.
    https://ninjatrader.com/support/foru...579#post770579

    And a link to submitting OCO stop and target exits with the unmanaged approach.
    https://ninjatrader.com/support/foru...269#post802269

    My guess is you are trying to re-use OCO strings that were previously used on filled, cancelled, or rejected orders.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      No I'm using different oco strings and it still closes both orders.

      Code:
      oco = GetAtmStrategyUniqueId() + "entry";
      oco2 = 2+GetAtmStrategyUniqueId() + "entry";​
      
      SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, 1, Close[0],0, oco, "Long limit entry");
      
      SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopMarket, 1,0,Close[0]-(40*TickSize),oco2, "Short limit entry");
      
      ​
      Last edited by r3n3v; 11-28-2022, 09:48 AM.

      Comment


        #4
        Hello r3n3v,

        Why are you using an OCOId string with a market order?
        What orders are you trying to cancel when a market order, which fills immediately, fills?

        Are you able to reproduce using the examples I provided you?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Yes I can reproduce the example you provided. However this doesn't accomplish what I'm trying to do. I simply want to buy and sell and keep both orders on when both are filled. If for example a long is filled and then I want to have a short filled at the same time on the same instrument I don't want to sell to close the long position. I would want to keep a short position open as well. I want both orders active at the same time. How can we do this with unmanaged orders?

          Comment


            #6
            Hello r3n3v,

            You are reproducing that both entry orders are being cancelled and neither order is being filled?

            Below is a link to a video of running this script.


            If you follow the exact steps in this video, is the behavior different?

            Where you have mentioned:
            I simply want to buy and sell and keep both orders on when both are filled.
            OCO is one-cancels-others. If one order fills, the other orders using the same OCOID are cancelled.
            If you want both orders to fill, then you should not be using OCO. If you want the buy order to go long, and the sell order to go back to flat, then don't use OCO so that One does not Cancel the Other.

            Where you have mentioned:
            If for example a long is filled and then I want to have a short filled at the same time on the same instrument I don't want to sell to close the long position.
            This is not possible on the same account and same instrument. There is only one position per account and instrument. You cannot be both long and short at the same time.


            Where you have mentioned"
            I want both orders active at the same time. How can we do this with unmanaged orders?
            In the managed approach, submit two orders.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            71 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            143 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            76 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            47 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            51 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X