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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          134 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          75 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          119 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          114 views
          1 like
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          92 views
          0 likes
          Last Post CarlTrading  
          Working...
          X