Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChangeOrder

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

    ChangeOrder

    Hi,

    Can I use ChangeOrder to alter the quantity on an OCO order?

    I am fixing someone else's code and trying to avoid rewriting it. Instead of putting out one OCO set with each partial fill, only one was put out on the first fill (hence the error).

    Is quantity read-only or can I modify it and if I can, do you have any suggestions on what to use for quantity (i.e. position.quantity).

    I can envision a situation where I get a partial fill on the entry (4 out of 10) and then a partial fill of that partial fill on an exit (2 of the 4) and then another fill on the entry, etc. What a mess that would be.

    I suspect, I am going to have to use order lists but this is only a prototype and I don't want to spend a lot of time on it.

    Any and all suggestions will be appreciated.

    Best Regards,
    Scott

    #2
    Hi Scott,

    Yes, ChangeOrder() does accept quantity as a value to change. With ChangeOrder you must pass in the IOrder object to reference the order you want to change.

    To use quantity from actual fills, you can work in OnExecution and refer to the execution.order.Filled property for a specific IOrder. This property updates to reflect the total quantity actually filled so will work in partial fill cases as well.

    Let's say you have three partial fills on a 200 quantity order.
    100
    25
    75

    The value returned from execution.Order.Filled will then be:100, 125, 200.

    Last edited by NinjaTrader_RyanM1; 07-11-2011, 02:28 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan, I knew you could change the quantity of a regular working order but I wasn't sure if you could on an OCO order. If I change them both (to the same value as mentioned above) and one is filled, I assume the OCO portion still works and the two will remain properly linked.

      So if I get the fills as you show above and no exit orders are filled, I could submit the first - quantity 100, then ChangeOrder to 225 (100 + 125) and then ChangeOrder again to 425 (225 + 200) on both the take profit and stop loss sides of the pair; is that correct?

      Then if the profit target was hit for 300, both the profit order and the stop loss would be reduced to 125 hopefully.

      Best Regards,
      Scott

      Comment


        #4
        I see, thanks for the reply. The orders you linked are tied together with OCO, but ChangeOrder requires an IOrder object. There's no other way to reference the order and update the quantity without this object.

        You will want to check with the broker that you plan to submit to for clarification on behavior when two orders are OCO linked and these are partially filled. In our simulated environment, the quantity is updated so that working orders will match quantity and will even update quantity proportionately if there is a difference in quantity between two OCO orders.

        I'll try to clarify the execution.Order.Filled example so I believe you were seeing it as 425 total quantity. 200 represents the quantity of the order submitted, and this order is filled partially three times. 100 + 25 + 75 = 200.

        The value of execution.Order.Filled is updated with the total quantity when accessed, so the first fill comes in at 100, then the next value returned is 125, which is 100 + 25 (the first two partial fills) Then the last fill returns a value of 200 - your whole order filled. It updates to the complete fill quantity for each partial fill.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Ryan,

          Thanks, I use execution.Quantity which is always that particular execution quantity; that way I never have to figure out what number to use. But in this case knowing the total via execution.Order.Filled will save me the trouble of summing up, etc.

          Best Regards,
          Scott

          Comment

          Latest Posts

          Collapse

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