# Problem with Cross Signal as several signals will be emerged in a second

18

Does anyone have same problem after calculate the cross signal for MACD as it will emerge a several signals in a second so that EA will open a several orders at the same time due to these signals. I tried and though many methods such as limit the OrdersTotal & Sleep(90000) etc., but all did't work. Can anyone help to overcome this problem? Thank you!

Pls see the code as below:

```int start()
{
string Status="None";

double MACDM0=iMACD("XAUUSD",PERIOD_M15,12,26,9,0,MODE_MAIN,0);
double MACDS0=iMACD("XAUUSD",PERIOD_M15,12,26,9,0,MODE_SIGNAL,0);
double MACDM1=iMACD("XAUUSD",PERIOD_M15,12,26,9,0,MODE_MAIN,1);
double MACDS1=iMACD("XAUUSD",PERIOD_M15,12,26,9,0,MODE_SIGNAL,1);

//MACD Cross
if(MACDM1<MACDS1 && MACDM0>MACDS0 )
{
Status="MACD_UpCross";
}

if(MACDM1>MACDS1 && MACDM0<MACDS0)
{
Status="MACD_DownCross";
}

//---Open Order

if(Status=="MACD_UpCross")
{
}

if(Status=="MACD_DownCross")
{
OrderSend(NULL,OP_SELL,0.1,Bid,0,0,0,NULL,0,0,clrNONE);Print("Status= ",Status);
}
```
Files:
test_2.JPG 275 kb
test.JPG 181 kb
609

1°)

Candle 0 gives false signals

So it's better to compare closed candles 2 with 1

2°)

Allow   trades only when new candle opens - not on its ticks

18

It’s works! Thank you for your help! You’re the best, Paul =)