Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to OCO bracket order in a strategy

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

    how to OCO bracket order in a strategy

    Hello everybody,

    I have created a strategy in strategy builder which submits an EnterLongStopMarket order at a certain condition. I like to submit an additional EnterShortStopMarket order and both orders should be combined as an OCO bracket order. As soon one gets filled the other one should be cancelled.

    Currenty I have one single action in my set which does the EnterLongStopMarket() stuff. I added a new action in my set which does look like my existing EnterLongStopMarket() line with the difference that it is the command "EnterShortStopMarket()" and uses a lower stop price and another signal name. I had expect -although without OCO capability- that both orders would be placed when condition is true but only the Long Stop order is being submitted. Why do I already fail here on that step? Why doesn't the short stop position gets submitted? The log doesn't show anything.

    How can I fulfill this task? Please point me to the right direction. Thanks in advance.

    Patricia
    Last edited by patricia70; 01-17-2021, 01:41 PM.

    #2
    Hello patricia70,

    The Strategy Builder cannot use OCO. The internal order handling can try and send cancellation requests but this is not the same as OCO. For true OCO you would need to use the unmanaged approach and generate unique OCO Id strings.

    https://ninjatrader.com/support/foru...579#post770579
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea. It would ok for me to achieve this:

      order1 "GoLong" submitted at time 12:00:01 at 3.500
      order2 "GoShort" submitted at time 12:00:02 at 3.400

      it won't happen that they both get executed nearby at the same time because the stops are very distant each other. Now I need to cancel the other order as soon as one gets filled. How can I do this? any help appreciated.

      Comment


        #4
        Hello patricia70,

        Thanks for your reply.

        In the strategy Builder, limit type orders that are submitted but not filled are automatically canceled when the bar closes. There are no other means to cancel orders in the Strategy Builder.

        The Strategy Builder operates under the managed approach which imposes rules to prevent unwanted positions, please make sure you are reviewing those: https://ninjatrader.com/support/help...antedPositions

        As Chelsa advised you would need to use the unmanaged approach: https://ninjatrader.com/support/help...d_approach.htm

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Silent Warrior: obviously you mixed up the thread. Please start your own thread when you want to submit feauture requests. Thanks for your understanding. @mod: please move his post away to the appropriate subforum

          NinjaTrader_PaulH Thanks for your reply. I missed the link from NinjaTrader_ChelseaB thanks for pointing out. I'll go and read the documents you pointed to. Thank you so far!

          Comment


            #6
            Hello patricia70,

            Thanks for your reply.

            "@mod: please move his post away to the appropriate subforum"

            I have already done so earlier today.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I have read through the posts and the help files. I am not pretty sure yet if understood correctly. I'd like to go with the managed order because I have a better feeling when having the implied checks "under the hood". Additionally I don't count mself as "very experienced developer" as stated in the help file of "unmanaged orders".

              I have following two basic questions before diving deeper.

              1)
              I understand that in managed orders the order automagically gets cancelled after bar close. When I'd use "on price change" instead of "on bar close" then after each price change the order is re-submitted if condition still is true, correct?

              2) I don't bother if real OCO is used or not, I just like to know: is it possible at all to reach my goal in "managed order approach" ? I don't want to spend much time in strategy builder building and trying conditions and then after few days make the experience it's not possible at all I just need to know if my goal is solvable through managed orders or not.

              Thanks in advance

              Comment


                #8
                Hello patricia70,

                Thanks for your reply.

                1) No, the order is maintained (not resubmitted) until the bar closes. The logic under the hood would be as simple as: when the bar closes issue a cancelOrder()

                2) You cannot place two limit entry orders, in opposite directions as this violates "Internal Order Handling Rules that Reduce Unwanted Positions". https://ninjatrader.com/support/help...antedPositions

                You can certainly use the logic of your strategy to monitor the price compared to the two different price levels and then place a single order, either a limit type or directly with a market order. For this type of strategy, you would want to be operating with Calculate.OnPriceChange.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Paul and thank you.
                  Originally posted by NinjaTrader_PaulH View Post
                  2) You cannot place two limit entry orders, in opposite directions ...
                  you said "limit entry orders". is this also true when I use Stop Buy and Stop Sell orders? I am using those type of orders for my entries, the strategy is range breakout.

                  Originally posted by NinjaTrader_PaulH View Post
                  You can certainly use the logic of your strategy to monitor the price compared to the two different price levels and then place a single order, either a limit type or directly with a market order. For this type of strategy, you would want to be operating with Calculate.OnPriceChange.
                  I want to trade both directions, but only the first breakout of the horizontal price level. Either the top or the bottom. I cannot distinguish or "guess" which direction it will go. So simply said, I have no choice and HAVE TO use unmanaged order approach?

                  Comment


                    #10
                    Hello patricia70,

                    Thanks for your reply.

                    Yes, I was including all orders that are not market orders, I should have said that instead.


                    You do not need to place two limit orders in the opposite direction and can instead use your strategy logic to do that for you.

                    Determine the range high and range low

                    if (Price crosses above high of Range)
                    EnterLong();

                    if (price crosses below low of range)
                    EnterShort();

                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Paul and sorry for very late reply. Was really busy in the past weeks. Are you aware of any example which I could use therefore? I already tried your described variant, but it doesn't work. I would like to begin from scratch with a very small and simple example and build up. Thanks for your support.

                      Comment


                        #12
                        Hello patricia70,

                        I've attached a strategy builder example of determining an opening range and then looking for the first cross up/down of that range.

                        The screenshot shows what to expect in this example. I just used horizontal lines to show the 30-minute opening range of the current session and a vertical line to indicate when the cross condition occurs, either the High cross or the low cross. This is where you would place your EnterLong() or EntyerShort() order

                        A bool variable called OKtoTrade is used to tell the strategy when to look for the trade and once the first trade is entered it would be set to false to prevent further trades. On a new session, the range values are reset.

                        The chart shows the Opening Range starting at 7:31 (which is mountain time).
                        Click image for larger version

Name:	Patricia70-1.PNG
Views:	9
Size:	47.3 KB
ID:	1143565

                        Here is the strategy example:

                        [ATTACH]n1143566[/ATTACH]
                        Paul H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by southpacific001, Yesterday, 09:25 PM
                        1 response
                        6 views
                        0 likes
                        Last Post Vendor_NT_Mobile  
                        Started by EnveousColnago, Today, 07:39 AM
                        1 response
                        14 views
                        0 likes
                        Last Post NinjaTrader_ShawnB  
                        Started by fitmar2525, Today, 06:44 AM
                        0 responses
                        7 views
                        0 likes
                        Last Post fitmar2525  
                        Started by David36, Today, 04:30 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post David36
                        by David36
                         
                        Started by cincai, Today, 04:09 AM
                        1 response
                        4 views
                        0 likes
                        Last Post cincai
                        by cincai
                         
                        Working...
                        X