stop repeating orders in same point

 
How i can stop Duplicate Transactions in EA 
Please help me 
bool OrderIsActive(int ordertype)
{
  for(int i=0;i<OrdersTotal();i++) {
        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
        if (OrderMagicNumber()==MagicNumber && Symbol()==OrderSymbol() && OrderType()==ordertype)

           return(true);
  }
  return(false);
}
Is this true ??? If not, what is correct


 
  1. Please use SRC button if you post code
  2. Here it is not necessary but make it your habit: count the orders down (in case you want to close one or more!)
  3. Check OrderSelect():
    bool OrderIsActive(int ordertype)
    {
      for(int i=OrdersTotal()-1;i>=0;i--) {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
            if (OrderMagicNumber()==MagicNumber && Symbol()==OrderSymbol() && OrderType()==ordertype)
    
               return(true);
      }
      return(false);
    }

But this shouldn't be the problem - I guess it is somewhere else.

 
Carl Schreiber: I guess it is somewhere else.
In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading)
Reason: