Download MetaTrader 5

stop repeating orders in same point

To add comments, please log in or register
Ma1991Lak7
20
Ma1991Lak7  
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


Carl Schreiber
7292
Carl Schreiber  
  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.

whroeder1
15917
whroeder1  
Carl Schreiber: I guess it is somewhere else.
In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading)
To add comments, please log in or register