Is there a way to know a pending order already execute?

 

Sometimes I need delete pending order,but if the pending order already executed,then MT4 will occur a 4108 error if I try to delete it.So I wonder is there a way to know a pending order already execute?

 
qq19342174:

Sometimes I need delete pending order,but if the pending order already executed,then MT4 will occur a 4108 error if I try to delete it.So I wonder is there a way to know a pending order already execute?

Check it's https://docs.mql4.com/trading/OrderType it will no longer be a pending order if it's been executed/triggered.
 
for(b=OrdersTotal()-1;b>=0;b--)
   {
      if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES)==true)
       {
         if (OrderType()        == OP_BUYSTOP)
         OrderDelete(OrderTicket());

         if (OrderType()        == OP_SELLSTOP)
         OrderDelete(OrderTicket());
       } 
    }
 

Or simply . . .

if (OrderType() > OP_SELL)
 
APeng:


Thanks APeng,problem solved. And RaptorUK,thanks you too!
Reason: