Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Account.Change() vs Account.QueueChange()

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

    Account.Change() vs Account.QueueChange()

    Hello,

    I have a personal add-on that extends chart trader and among other things, manages OCO brackets for stop, profit target(s), etc. and I wanted to clarify the use of Account.Change() vs Account.QueueChange() and when (if ever) to explicitly call QueueChange().

    Right now, I have a method to handle order changes that is as follows:

    public void TryChangeOrder(Order order)
    {
    lock (order)
    {
    if (order.OrderState == OrderState.Initialized ||
    order.OrderState == OrderState.Cancelled ||
    order.OrderState == OrderState.CancelPending ||
    order.OrderState == OrderState.CancelSubmitted ||
    order.OrderState == OrderState.Rejected ||
    order.OrderState == OrderState.Filled) return;

    if (order.Account.Provider != Provider.Provider14 &&
    (order.OrderState == OrderState.ChangePending || order.OrderState == OrderState.ChangeSubmitted))
    {
    order.Account.QueueChange(order, order.OrderState);
    }
    else
    {
    order.Account.Change(new[] { order }).
    }

    }
    }

    Essentially, the idea is that is an order is not in a state to handle a change, I either discard it (order has been filled, cancelled, etc.) or queue it (it is in the process of being changed already). As you can see in the code, I currently exclude Rithmic (Provider14) and always call Change(), as the API (or NT implementation) does not seem to support QueueChange() with Rithmic. For all other providers (Sim, Live and Playback), however, I follow this logic.

    However, on certain occasions, I run into issues where it seems that if I call QueueChange() multiple times (e.g., an order is being partially filled and I need to modify stop and/or target quantities), there are intermittent occasions when not all of the changes seem to be processed.

    If I remove this and just call Change(), it seems to then work fine in Sim even when always forcing partial fills, but the reason I added the QueueChange() in the first place was because I had issues with Continuum at the very least, though there is the potential for others to exhibit the same problem.

    So, before I make any changes, I wanted to see if you could offer any clarification on this? I do see that even when calling Change(), QueueChange() is called when the order is already in a ChangePending or ChangeSubmitted state - at least in Sim.

    So, maybe I shouldn't be calling QueueChange() directly at all?

    Thanks!



    #2
    Hello sdonahue,

    Thank you for writing in.

    QueueChange() is not documented in the help guide and I suspect that its purpose is only meant for internal use by the NinjaTrader application, not for NinjaScript access. The Change() method is documented for use to change an Order object as mentioned in the help guide here:


    Please use Change() whenever you intend to change an order, and if you encounter any issues or unexpected behavior you are welcome to report it to us so we may further investigate.

    Feel free to reach out with any additional questions or concerns.

    Comment


      #3
      Thanks, Emily - that's what I suspected. I will revert back to only calling Change() and test it out and report back if I run into any issues. Thanks!

      Comment


        #4
        Originally posted by sdonahue View Post
        If I remove this and just call Change(), it seems to then work fine in Sim even when always forcing partial fills, but the reason I added the QueueChange() in the first place was because I had issues with Continuum at the very least, though there is the potential for others to exhibit the same problem.
        Issues with Continuum?
        Can you elaborate?

        Comment


          #5
          Originally posted by bltdavid View Post

          Issues with Continuum?
          Can you elaborate?
          Sure - I was having issues with orders not being changed properly when the order was not in a state to accept changes (e.g. ChangeSubmitted, ChangePending) and I called Change(). That's why I implemented the handling to try and call QueueChange myself.

          Most of the issues occur when changes happen in quick succession, such as a partial fill and the quantities are being changed quickly to match the filled entry quantity.

          Yesterday, I did as Emily suggested and went back to just using Change() and I signed up for a demo of Continuum so I didn't have to test it live and it *seems* to be working, even with partial fills. Granted, it was the end of the day and I'd like to test more when the market opens, but that's been the main issue.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          78 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          146 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          79 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          52 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          56 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X