
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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;
}