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 Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                633 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                364 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                567 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                568 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X