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

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 Aviram Y, Today, 05:29 AM
            0 responses
            1 view
            0 likes
            Last Post Aviram Y  
            Started by quantismo, 04-17-2024, 05:13 PM
            3 responses
            25 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by ScottWalsh, 04-16-2024, 04:29 PM
            7 responses
            34 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by cls71, Today, 04:45 AM
            0 responses
            6 views
            0 likes
            Last Post cls71
            by cls71
             
            Started by mjairg, 07-20-2023, 11:57 PM
            3 responses
            216 views
            1 like
            Last Post PaulMohn  
            Working...
            X