mq5 OrderDelete() doesnt work??

 


https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradeorderdelete


Why OrderDelete() is doesnt work?

please help me



bool DeletePendingOrders(CLOSE_PENDING_TYPE pDeleteType)

{
   bool error = false;

   // Loop through open orders from latest to oldest
   for(int order = OrdersTotal() - 1; order >= 0; order--)
   {
      ulong ticket = OrderGetTicket(order);
      if (OrderSelect(ticket))
      {
         int orderType = EnumToString(ENUM_ORDER_TYPE(OrderGetInteger(ORDER_TYPE)));
         int orderMagicNumber = OrderGetInteger(ORDER_MAGIC); 
         
         bool deleteOrder = (pDeleteType == CLOSE_ALL_PENDING && (orderType == ORDER_TYPE_BUY || orderType == ORDER_TYPE_SELL)) ||
                            (pDeleteType == CLOSE_BUY_LIMIT && orderType == ORDER_TYPE_BUY_LIMIT) ||
                            (pDeleteType == CLOSE_SELL_LIMIT && orderType == ORDER_TYPE_SELL_LIMIT) ||
                            (pDeleteType == CLOSE_BUY_STOP && orderType == ORDER_TYPE_BUY_STOP) ||
                            (pDeleteType == CLOSE_SELL_STOP && orderType == ORDER_TYPE_SELL_STOP);
         
         if (deleteOrder && orderMagicNumber == MagicNumber)
         {
            if (OrderDelete(ticket))  // <<<<<<<<<<<<<<<<<<<<<<<<-------------THIS HERE
            {
               Print("Failed to delete order: ", ticket);
               error = true;
            }
         }
      }
   }

   return error;
}


Error

'OrderDelete' - undeclared identifier


Documentation on MQL5: Standard Library / Trade Classes / CTrade / OrderDelete
Documentation on MQL5: Standard Library / Trade Classes / CTrade / OrderDelete
  • www.mql5.com
Deletes the pending order. Parameters ticket [in]  Order ticket. Return Value true - successful check of the basic structures, otherwise -...
 
Simon Jeon:


Error

'OrderDelete' - undeclared identifier


Hello Simon

You need to declare this 

CTrader CT;

at the top of your function and then call it this way

CT.OrderDelete(ticket)
 
Lorentzos Roussos #:

Hello Simon

You need to declare this 

at the top of your function and then call it this way

YES~! It worked~! Thank you~!!!!