Download MetaTrader 5

Anyone knows how to delete the pending orders in mt5?

To add comments, please log in or register
enbo lu
Moderator
1957
enbo lu  

Anyone knows how to delete the pending orders in mt5?

first,select the pending orders you want to delete;

second, use OrderDelete() function to delete them.

but how to write this in mql5? 

can anyone help?

thanks a lot~ 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
enbo lu
Moderator
1957
enbo lu  
luenbo:

Anyone knows how to delete the pending orders in mt5?

first,select the pending orders you want to delete;

second, use OrderDelete() function to delete them.

but how to write this in mql5? 

can anyone help?

thanks a lot~ 

 

 

By reading the doc, I solved it myself,aha~ 

void PendingOrderDelete() 
{  
         CTrade mytrade;
         int o_total=OrdersTotal();
         for(int j=o_total-1; j>=0; j--)
         {
            ulong o_ticket = OrderGetTicket(j);
            if(o_ticket != 0)
            {
             // delete the pending order
             mytrade.OrderDelete(o_ticket);
             Print("Pending order deleted sucessfully!");
          }
      }     
}
Jeremy Scott
8529
Jeremy Scott  
luenbo:

By reading the doc, I solved it myself,aha~ 

void PendingOrderDelete() 
{  
         CTrade mytrade;
         int o_total=OrdersTotal();
         for(int j=o_total-1; j>=0; j--)
         {
            ulong o_ticket = OrderGetTicket(j);
            if(o_ticket != 0)
            {
             // delete the pending order
             mytrade.OrderDelete(o_ticket);
             Print("Pending order deleted sucessfully!");
          }
      }     
}
Thanks for this you just saved me at least as much time as it took you to figure it out! 
phi nuts
2181
phi nuts  
Use mql5 search and search for pending in forum and you find plenty, one of them is this, but you have to read the whole topic.
To add comments, please log in or register