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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          52 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          142 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          160 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          96 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          276 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X