Anyone knows how to delete the pending orders in mt5?

 

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
 
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!");
          }
      }     
}

 
luenbo:

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

Thanks for this you just saved me at least as much time as it took you to figure it out! 
 
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.
 
Thanks Guys, this help me a lot.
 
Thanks! It has helped me also :)
 
enbo lu #:

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



Simple code. Thanks bro :-)

Reason: