Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inconsistent behavior when updating an ExitLongStop order

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

    Inconsistent behavior when updating an ExitLongStop order

    Hi
    I have a strategy that enters a trade and manages the take profits and stop loss using the ExitLongStop and ExitLong orders
    When my first take profit hits, I update the stop loss quantity and then take the profit.
    For example: Once entering a trade with 600 stocks. When the first take profit hits, I decrease the quantity of the stop loss to 400 stocks and exit 200 stocks as follows
    // Update stop loss quantity
    stopOrder = ExitLongStop(0, true, 400 , stopOrder.StopPrice , "STOP_LOSSS" , "ENTRY");
    // Take profit
    ExitLong(200 , "FIRST_TAKE_PROFIT" , "ENTRY");

    In some cases, I've noticed that the stop loss order doesn't get updated and my trade is left without any stop loss.
    (The order of the stop loss is canceled instead of being updated with the right quantity).
    It is important to mention that this is not consistent. Sometimes the stoploss order igets updated properly.
    Can someone help me understand what I'm doing wrong?
    Is there a race condition between the ExitLongStop and ExitLong orders (I know that the stop order should be updated prior to taking the profit).

    Regards,
    Ron

    #2
    In Ron,

    In order to scale out of a position, you must first scale in with distinct entry names. Matching signal names is what is used to determine exit quantity and will take priority over the quantity you have specified in the method. This is part of our managed framework. A basic scale out sample strategy is available here:


    If you wanted more control on the scaling behavior, you could work with unmanaged framework. With this there is no built in position/order management and can scale in/out they way you're looking to do.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      HI,

      See my comments below:

      Originally posted by NinjaTrader_RyanM View Post
      In Ron,

      In order to scale out of a position, you must first scale in with distinct entry names. Matching signal names is what is used to determine exit quantity and will take priority over the quantity you have specified in the method. This is part of our managed framework. A basic scale out sample strategy is available here:
      I don't want to enter the trade via multiple orders since this will increase my commission. See the following thread I sent quite a while ago: http://www.ninjatrader.com/support/f...ad.php?t=46473

      Yet, I am still unclear why my code doesn't work properly: I match the signal name of both the stop loss order and the take profit order to the entry name (i.e. "ENTRY").
      Prior to taking the profit, I decrease the stop loss order quantity and then issue an exit long order. Both orders "are linked" to the same entry order (*ENTRY").

      Please clarify.
      Last edited by rmaron; 02-22-2012, 11:35 AM.

      Comment


        #4
        It sounds like you'll want to consider unmanaged approach for this. Scaling out in a managed system will only work if you first scale in. Unmanaged approach is the alternative to this, with complete control on order submission.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan

          Thank you for the quick response.
          I don't want to be difficult. However, I'm still unclear why my code doesn't work properly.

          I understand I can use the unmanaged approach.
          However, I don't understand why Ninja Trader doesn't allow me to update my trade stoploss and then take profit on the rest of the quantity.

          Ron

          Comment


            #6
            It's just how the managed framework is designed to determine exit quantity. The NinjaTrader strategy framework does order/position management "under the hood" to simplify order submission for you. In this case you disagree with how your orders are handled by the managed layer. You're not able to change how this managed layer behaves, but you are able to create your preferred handling with unmanaged approach.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Is there an example one can provide me using the unmanaged approach to enter a trade and manage stop losses and take profits?

              Comment


                #8
                I'm sorry we don't have this specific example. You can read more about unmanaged order methods here:


                There are only three methods for submitting, changing, and cancelling orders. To get the most use of unmanaged orders, take a look at our advanced handlers topic here:


                And IOrder page here for exposing order properties and working with the objects needed for these methods:
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  I wonder what would be the right approach when changing the stoploss quantity and taking profit:
                  1) Should I first change the stop loss, wait for acknowledge that the stop loss quantity changed (i.e. In the OnExecution() method), and then send the take profit command. or
                  2) Send both the stop loss quantity change order and the take profit order (without waiting to the acknowledgement).

                  I hope someone could provide me with the better approach.

                  Ron

                  Comment


                    #10
                    This is for unmanaged approach, right? There's not one answer here as it depends how you design your strategy and the conditions it runs in. I would update the stop order quantity after receiving confirmation of limit order fill, but other approaches could certainly work.
                    Ryan M.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
                    573 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X