Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Handling Rules: How can I switch sides with limit orders?

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

    Order Handling Rules: How can I switch sides with limit orders?

    I am running into the internal order handling rules again. My strategy works fine with market orders. I am modifying it to use limit orders. In a backtest, it is failing to place some orders. The situation is:

    1. Place two long orders with unique signals (EnterLongLimit), get filled, immediately set a different profit target for each
    2. Meet conditions to switch sides (NOT hit the profit target), place two short orders with EnterShortLimit

    If I comment out the calls to SetProfitTarget, it works most of the time, but occasionally the second EnterShortLimit fails anyway.

    #2
    Right, two concurrent entry orders are not supported at this time.

    Comment


      #3
      I don't think this is the situation -- I don't have long and short orders open at the same time. I thought what I am doing is legal as long as I am using UniqueEntries.

      Comment


        #4
        Got it. Did you check on TraceOrders?

        You would need to cancel out the targets before entering the opposite side with a non-market order.

        Comment


          #5
          Is this the right code to cancel the profit targets? I've tried this and it doesn't change anything.

          Code:
          int n;
          for (n = 0; n < Orders.Count; n++)
             CancelOrder(Orders[n]);

          Comment


            #6
            Hmm ... did not try that before. Likely will not work on backtest.

            Here are your options:
            - drop built in SetStopLoss/Target conecpt and code stop target by yourself (well, not really an option...)
            - use a market order as cross over. This will go without limitations
            - monitor order status events to get the IOrder of the Stop/Target so you could cancel them out

            We are aware that this is a tough one and will consider improvements with NT7

            Comment


              #7
              Pete,

              I had to work around this issue recently and found the best way to handle was Dierk's recommended approach #3 to use the IOrder approach vs Set() exits and track the targets/stops to then cancel them prior to submitting the reversing entry.

              Regards,

              Whitmark
              whitmark
              NinjaTrader Ecosystem Vendor - Whitmark Development

              Comment


                #8
                These two reference samples may be of use to you: http://www.ninjatrader-support.com/v...ead.php?t=3917
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks guys, looks like that will work.

                  Comment


                    #10
                    Hi there,

                    I am a tradestasion user and evaluating your platform. I am trying to create a simple strategy that will have multiple targets, and would sometimes need to reverse with limit orders.

                    market order is not an option and based on your suggestion I will not try to rewrite the built-in functions.

                    this leaves me with the last option:
                    could you please point me into some sample of how to achieve it?

                    would it mean that if the limit price has not been hit, I will need to resubmit the target and stops or will it happen automatic?

                    it will be a crucial point for me, any help would be appreciated.

                    regards,
                    Nir

                    Comment


                      #11
                      This would only be possible if you submitted the limit reverse order if you did not have any existing stops/target orders working. Is this acceptable?
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        would be all right for 1 bar, if limit price will not touched than I need the original stop and targets back in place.

                        thx for the quick response.

                        Comment


                          #13
                          You can try submitting the limit order you want and on the next bar check that limit order's IOrder status. If the order is not in a state you find acceptable cancel it and quickly add on the stop & target orders.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            thx,

                            could anyone help me to find a sample how to cancel the stop and profit orders that been created by SetProfit() and SetStop(), before I am submitting my new reversing limit order?

                            thx
                            nir

                            Comment


                              #15
                              You can't cancel orders generated by those methods. You would have to use the ExitLongLimit(), ExitLongStop() methods etc.. Check out the Help Guide section for advanced order handling.

                              RayNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

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