My EA is making too many trades

 

I'm new to this and I don't see what I'm doing wrong, When I run it it just keeps making trades. I want it to work just at the close of the bar, but its making a trade every tick.

My code is

double FastMA = iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,0);
double PrevFastMA = iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,1);
double SlowMA = iMA(NULL,0,21,0,MODE_SMA,PRICE_MEDIAN,0);
double PrevSlowMA = iMA(NULL,0,21,0,MODE_SMA,PRICE_MEDIAN,1);

if(FastMA > SlowMA && PrevFastMA < PrevSlowMA)
{
OrderSend(Symbol(),OP_BUY,0.1,Ask,5,0,0);
return;
}

if(FastMA < SlowMA && PrevFastMA > PrevSlowMA)
{
OrderSend(Symbol(),OP_SELL,0.1,Bid,5,0,0);
return;
}

 
Here.
 
ubzen:
Here.

Thanks, that's what I needed.