Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Cancel All Orders by strategy

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

    Cancel All Orders by strategy

    Hello,
    Can you please tell me how to cancel all open orders by strategy, (I have several strategy started at the same time).

    #2
    Hello soma8,

    Thank you for writing in.

    Just to clarify, are you attempting to cancel all open orders made from the specific strategy itself, or are you trying to cancel orders across all strategies submitted to your account from just one strategy?

    To do the former, you can use the undocumented method, CancelAllOrders(). This method requires two arguments passed to it:
    Code:
    CancelAllOrders(bool entries, bool exits);
    Setting the first bool to true will cancel all open entry orders and setting the second bool to true will cancel all open exit orders.

    If you would like to cancel orders across your account, I would suggest taking a look at this very helpful post from one of my colleagues, Jesse, that details how you can loop through the orders placed on the account to cancel them: http://ninjatrader.com/support/forum...78&postcount=2

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

    Comment


      #3
      Thank you,

      I want to cancel all open orders made from the specific strategy itself.

      Comment


        #4
        Hello soma8,

        Thank you for the clarification.

        You would want to utilize the CancelAllOrders() method mentioned in my previous post.

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

        Comment


          #5
          Thank you,
          protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity,
          Cbi.MarketPosition marketPosition, string orderId, DateTime time)
          {
          //traitements
          CancelAllOrders(true, true);
          }
          but i have an error in script: the name 'CancelAllOrders' does not exist in the current context.

          Comment


            #6
            Hello soma8,

            I apologize for the misunderstanding; as this question was not posted in the NinjaTrader 8 section and it was not specified that this was for NinjaTrader 8, I have provided syntax for NinjaTrader 7.

            You would need to loop through the Orders collection and cancel each order.

            Example:
            Code:
            foreach (Order o in Orders)
            {
                 CancelOrder(o);
            }
            Please, let us know if we may be of further assistance.
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              Thank you, now il's working

              Comment


                #8
                Originally posted by soma8 View Post
                I want to cancel all open orders made from the specific strategy itself.
                Sorry, I am confused.

                Do you mean one specific instance of strategy XYZ?

                Or all instances of the one specific strategy known as XYZ?

                I think this is an important distinction.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by CortexZenUSA, Today, 12:46 AM
                0 responses
                0 views
                0 likes
                Last Post CortexZenUSA  
                Started by usazencortex, Today, 12:43 AM
                0 responses
                2 views
                0 likes
                Last Post usazencortex  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                168 responses
                2,262 views
                0 likes
                Last Post sidlercom80  
                Started by Barry Milan, Yesterday, 10:35 PM
                3 responses
                10 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by WeyldFalcon, 12-10-2020, 06:48 PM
                14 responses
                1,429 views
                0 likes
                Last Post Handclap0241  
                Working...
                X