multi order ea.

 
need some help . i have an ea that need to send orders will some of them still open .on a backtesting with open it run very good, but when i run it with tick or in real time after the first order the next on is all the max ordered allowd. what need to be done in order that each time only one order will be send.
thankx for your help.
matalondri@aol.com
 
you must use MagicNumber and OrdersTotal()

I have this function to count an expert orders

int MyRealOrdersTotal(int Magic)
{
  int c=0;
  int total  = OrdersTotal();
 
  for (int cnt = 0 ; cnt < total ; cnt++)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUY || OrderType()==OP_SELL))
    {
      c++;
    }
  }
  return(c);
}
 
waddahattar wrote:
you must use MagicNumber and OrdersTotal()

I have this function to count an expert orders

int MyRealOrdersTotal(int Magic)
{
  int c=0;
  int total  = OrdersTotal();
 
  for (int cnt = 0 ; cnt < total ; cnt++)
  {
    OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
    if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUY || OrderType()==OP_SELL))
    {
      c++;
    }
  }
  return(c);
}

Reason: