Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChangeOrder()

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

    ChangeOrder()

    Hi,

    With the UNMANAGED APPROACH.

    When some condition is true, I want to change the Quantity parameter of an order that has not been either Canceled or filled. Since the order is submited, do I have to reset it to null to call the ChangeOrder()? In that case, Which even driven method can I use?

    Thanks.

    #2
    To be more precise.

    I want to call the changeOrder method to change one order when other different order is filled.

    Thanks

    Comment


      #3
      Hello CJS,

      Correct. You'll need to access the specific IOrder object when submitting ChangeOrder. You'll want to check that this object is not null prior to the statement.

      Order Modification
      Unlike the Managed approach where you could modify a working order by calling the entry order method again with your new parameters, the Unmanaged approach requires the utilization of the ChangeOrder() method. The ChangeOrder() method requires you to have access to the IOrder object you wish to modify so it is important to hold onto those for any active order you have in your strategy.


      Code:
       [LEFT]protected override void OnBarUpdate() 
      [LEFT]{
      // Raise stop loss to breakeven when you are at least 4 ticks in profit
      if (stopOrder != null && stopOrder.StopPrice < Position.AvgPrice && Close[0] >= Position.AvgPrice + 4 * TickSize)
      ChangeOrder(stopOrder, stopOrder.Quantity, stopOrder.LimitPrice, Position.AvgPrice);
      }[/LEFT]
      [/LEFT]
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        The order you're changing should not be null, and you can work within OnExecution() to check the orderState for the other order.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          But. What happens, in the UNMANAGED APPROACH, when an order has been submitted, but it has not been either canceled or filled and I want to use it the next trading day to submit a new order?. Do I have to cancel it and reset it to null before de next trading day?

          Thanks

          Comment


            #6
            CJS, it would depend on the order's TIF settting - if you're submittting a DAY order it would be auto cancelled at the end of day as it expires then. You should ensure the IOrder object is nullified on a cancelled orderstate and then you can submit a fresh order via SubmitOrder().

            Comment


              #7
              Can I call de CancelOrder to cancel one order from de OnExecution of the other diferent order? Or the cancelOrder Method has to be called just from de OnBarUpdate?

              Thanks

              Comment


                #8
                CJS, you can use CancelOrder() in any of the event driven order methods or the OnBarUpdate().

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by charlesugo_1, 05-26-2026, 05:03 PM
                0 responses
                59 views
                0 likes
                Last Post charlesugo_1  
                Started by DannyP96, 05-18-2026, 02:38 PM
                1 response
                143 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by CarlTrading, 05-11-2026, 05:56 AM
                0 responses
                161 views
                0 likes
                Last Post CarlTrading  
                Started by CarlTrading, 05-10-2026, 08:12 PM
                0 responses
                97 views
                0 likes
                Last Post CarlTrading  
                Started by Hwop38, 05-04-2026, 07:02 PM
                0 responses
                276 views
                0 likes
                Last Post Hwop38
                by Hwop38
                 
                Working...
                X