Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ocoId parameter in SubmitOrder method

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

    ocoId parameter in SubmitOrder method

    In the StrategyBase.SubmitOrder function there is a parameter called
    "string ocoId". What does this parameter do and how is it used?


    thanks-
    jon

    #2
    Jon,

    If you wanted to submit two orders that are OCOed to each other you would call SubmitOrder() with the same OCO ID on both of your orders. Then whenever one is filled the other will be cancelled automatically.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,

      VERY NICE!!! What do the barsInProgressIndex and name parameters do?
      Is 'name' simply the signal name? Very confused about the barsInProgressIndex.

      thanks!
      jon

      Originally posted by NinjaTrader_Josh View Post
      Jon,

      If you wanted to submit two orders that are OCOed to each other you would call SubmitOrder() with the same OCO ID on both of your orders. Then whenever one is filled the other will be cancelled automatically.

      Comment


        #4
        barsInProgressIndex means which instrument you want to submit to. This is needed for when you are using multiple instruments in your strategy. If not, just use 0 as the BIP context to submit to.

        Name is just whatever you want to name your order. This is for your own personal use. It has no signal tracking attached to this name like how signal names do with Managed orders.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh,

          So, I tried using SubmitOrder, but when the code went to instantiating my entry order the debugger crashed and gave me this error message:

          'SubmitOrder' method can not be called on managed strategies.

          I'm not sure how my strategy is a managed strategy. What defines a 'managed' strategy and how can I force my strategy to be unmanaged?

          thanks!
          jon


          Originally posted by NinjaTrader_Josh View Post
          barsInProgressIndex means which instrument you want to submit to. This is needed for when you are using multiple instruments in your strategy. If not, just use 0 as the BIP context to submit to.

          Name is just whatever you want to name your order. This is for your own personal use. It has no signal tracking attached to this name like how signal names do with Managed orders.

          Comment


            #6
            In Initialize() you will need to put this line:

            Unmanaged = true;
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh,

              Thanks for all your help!

              jon

              Originally posted by NinjaTrader_Josh View Post
              In Initialize() you will need to put this line:

              Unmanaged = true;

              Comment


                #8
                Josh,

                Suppose I submitted two orders (1 long and short) with SubmitOrder(). I use "order1" as the ocoId for each of these. The long order goes on to get filled. I know that this immediately cancels the short order because the ocoID is the same. However if I then place a collar around the long order, creating essentially two more orders (a sell stop below and a sell limit above the AvgFillPrice), will all of these orders also be tied to one another if I use "order1" as the ocoId in SubmitOrder? In other words, when creating these two orders (the collar), if I use "order1" as an ocoId, would all orders that have this ocoId get closed out/cancelled?

                entryshort
                entrylong
                entrylongstop
                entrylongprofit

                I have the above three orders and each of them has the value of "order1" as the ocoId. 'entryshort' gets cancelled (I have verified this and am very happy with it!) immediately once entrylong gets filled. However further, if the 'entrylongprofit' (hoping here) gets hit, would that cancel the 'entrylongstop' as well as tie this fill to the 'entrylong' entry.

                Does that make sense?

                Comment


                  #9
                  jonmoron,

                  I believe ocoID will only be effective in closing any orders that are already active at the time of the order fill. I don't recommend you use the same ocoID for your protective orders as your entry orders as it simply is a different OCO set.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Josh,

                    So you recommend using another ocoID for the protective orders for each entry? How then would a ProfitTarget fill be related to its entry? Or is there no reason to be concerned of this since I'm running Unmanaged?


                    Originally posted by NinjaTrader_Josh View Post
                    jonmoron,

                    I believe ocoID will only be effective in closing any orders that are already active at the time of the order fill. I don't recommend you use the same ocoID for your protective orders as your entry orders as it simply is a different OCO set.

                    Comment


                      #11
                      jonmoron,

                      There is no need to be concerned with it. Unmanaged literally has no signal tracking. It is really just you telling your brokerage directly buy, sell, buy-to-cover, etc.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Very well. But you do recommend I use ocoId for the protective collar orders, correct? It seems logical that I'd have orders canceled once I don't need them (ie they get exited out with PT or a SL).

                        thanks!


                        Originally posted by NinjaTrader_Josh View Post
                        jonmoron,

                        There is no need to be concerned with it. Unmanaged literally has no signal tracking. It is really just you telling your brokerage directly buy, sell, buy-to-cover, etc.

                        Comment


                          #13
                          Right. I do recommend ocoIDs for bracket orders.
                          Josh P.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          648 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          369 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          108 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          572 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          574 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X