A function to check if the pending order already exists :

Code:
int checklevel(double level){
   bool check=false;
   for(int j=OrdersTotal()-1;j>=0;j--){
      if(!OrderSelect(j,SELECT_BY_POS))continue;
         if(OrderMagicNumber()==Magic)
            if(OrderSymbol()==Symbol())
               if(OrderType()==OP_BUY || OrderType()==OP_SELL || OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT)
                  if(NormalizeDouble(OrderOpenPrice(),Digits)==level)return(1);
   }
   return(0);
}