order delete a pending order bythe other pending order of opposite trades .HELP!!!

 
I have been wondering if it is possible to have a code where two opposites pending order can be deleted by one if the order becomes a market order.If possible can you help me write the codes.
 
It can be done. Give it a shot and try to code it. If you run into snags me or somebody will help.
 
int PendingOrders(int Magic)              //COUNTS PENDING ORDERS
{
  int c=0;
  int total  = OrdersTotal();

  for (int i=total-1; i >=0; i--)
  {
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);     
    if (OrderMagicNumber()==Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP))
    {
      c++;
    }
  }
  return(c);
}  

int DeletePendingOrders(int Magic)        //DEFINITION OF HOW TO DELETE THE PENDING ORDERS
{      
    if(PendingOrders(Magic)==1)
    
    for(int i=0; i<OrdersTotal(); i++)
    {        
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if(OrderMagicNumber()==Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP))
    {
      OrderDelete(OrderTicket());
    }
  }
  return(0);
}
 
jmca wrote >>
It can be done. Give it a shot and try to code it. If you run into snags me or somebody will help.

Did you see the text i sent to you in private,this is the code i want you to look into.I have attached the EA to this reply.Concerning the pending order delete,please let me clarified the whole situation.I want to open two opposite pending orders simultaneously for a symbol-one a buystop,the other a sell stop- such that if market price hit one and becomes a market order the other pending order should delete automatically and instantaneously.Thanks for your co-operation.

Reason: