Select order by magic number

 

I have two pending orders open, with magic number 222  and 444.  I want the ea to delete the order with the largest magic number i.e 444. How do I amend this code to perform this function?


Thanks.

//+------------------------------------------------------------------+
//| Delete all pending orders                                        |
//+------------------------------------------------------------------+
void DeleteAllPendingOrders(void)
  {
   for(int i=OrdersTotal()-1; i>=0; i--) // returns the number of current orders
      if(m_order.SelectByIndex(i))     // selects the pending order by index for further access to its properties
         if(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==InpMagic)
             if(!m_trade.OrderDelete(m_order.Ticket()))
                if(InpPrintLog)
                   Print(__FILE__," ",__FUNCTION__,", ERROR: ","CTrade.OrderDelete ",m_order.Ticket())
  }
 
Your code deletes orders with MN InpMagic. Where do you set that variable to 444?
Reason: