Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't get CancelOrder to work on second instrument

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

    Can't get CancelOrder to work on second instrument

    I'm trying to cancel all orders of an unmanaged strategy. It is working on the primary instrument, but is not canceling the orders on the secondary instrument. Can anyone tell me what I'm doing wrong?

    I'm simply calling...

    Code:
                CancelOrder(ZN_entryOrder);
                CancelOrder(ZN_exitOrder);
                CancelOrder(ZF_entryOrder);
                CancelOrder(ZF_exitOrder);
                CancelOrder(ZF_flattenOrder);
                CancelOrder(ZN_flattenOrder);
    The ZN (primary instrument) orders cancel fine. The ZF orders do not. Any ideas what I can do to get them to cancel as well?

    Thanks

    #2
    Hello lookoutBelow,

    Thank you for your inquiry.

    Because you are using multiple instruments, you would need to check the BarsInProgress to cancel the order when the strategy is running on the second DataSeries.

    For example:

    Code:
    if (BarsInProgress == 0)
    {
         CancelOrder(ZN_entryOrder);
         CancelOrder(ZN_exitOrder);
         CancelOrder(ZN_flattenOrder);
    }
    else if (BarsInProgress == 1)
    {
         CancelOrder(ZF_entryOrder);
         CancelOrder(ZF_exitOrder);
         CancelOrder(ZF_flattenOrder);
    }
    You can read more about working with Multi-Time Frames & Instruments in the NinjaTrader help guide at this link: http://ninjatrader.com/support/helpG...nstruments.htm

    Please, let us know if we may be of further assistance!
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks Zachary.

      Out of curiosity. Is there a command to simply cancel all open orders on a particular symbol (or on a strategy), without naming specific IOrders?

      Thanks.
      Last edited by lookOutBelow; 06-26-2015, 11:59 AM.

      Comment


        #4
        Hello lookOutBelow,

        There is no supported method of cancelling all orders on a strategy, however you could do this:

        Code:
        CancelAllOrders(bool entries, bool exits);
        This will cancel all orders for the specific strategy that it is called in, and you can choose to do only entries, exits or both.

        Please note that this method is unsupported and do not have any documentation on the subject.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Excellent! Thanks much!

          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