Is there a fault in the EA's code or a broker issue? - page 2

 
Icham Aidibe:

It continues to place many orders ? 

Yes, sometimes 2. However, not very often and definitely not with every broker (I'm testing a few).

 
Daniel George:

Yes, sometimes 2. However, not very often and definitely not with every broker (I'm testing a few).

It shouldn't. Try to clean that also : 

void PlaceOrder()
  {
   while(IsTradeAllowed()==false)
      Sleep(100);
   RefreshRates();
   TheOrder=OrderSend(Symbol(),OP_SELLSTOP,NormalizeLots(CalcLots),NormalizePrice(SellPendingLevel),int(Slippage*PipValue),0,0,TradeComment,MagicNumber,0);
   return;
  }

to ... 

void PlaceOrder()
  {
   if(IsTradeAllowed()==true) { 
   	RefreshRates();
   	TheOrder=OrderSend(Symbol(),OP_SELLSTOP,NormalizeLots(CalcLots),NormalizePrice(SellPendingLevel),int(Slippage*PipValue),0,0,TradeComment,MagicNumber,0);
	}
  }

Sleep() shouldn't be used unwisely.

 
Icham Aidibe:

It shouldn't. Try to clean that also : 

to ... 

Sleep() shouldn't be used unwisely.

Thank you, I'll give it a try.

Can you please explain why

while(IsTradeAllowed()==false)
Sleep(100);

is not recommended here?

I thought it is better to have it, as a filter to send the order only if trade is allowed. 

 
Can this be a broker issue? And if so, can someone explain how it is possible to happen?
Reason: