try
if(iMA(NULL,60,12,0,MODE_EMA,PRICE_CLOSE,0)>=iMA(NULL,60,26,0,MODE_EMA,PRICE_CLOSE,0))
try
if(iMA(NULL,60,12,0,MODE_EMA,PRICE_CLOSE,0)>=iMA(NULL,60,26,0,MODE_EMA,PRICE_CLOSE,0))
Hi
That did not work as planned although the EA carried out orders. As soon as the MA lines meet the EA just executed buy orders till there is insufficient margin.
// try M15, Lots 0.1, Slipage 0
// if(iMA(NULL, 15, 12, 0, MODE_EMA, PRICE_CLOSE, 0) >= iMA(NULL, 15, 26, 0, MODE_EMA, PRICE_CLOSE, 0))
double eMA12_0 = iMA(NULL, 0, 12, 1, MODE_EMA, PRICE_CLOSE, 0);
double eMA12_1 = iMA(NULL, 0, 12, 1, MODE_EMA, PRICE_CLOSE, 1);
double eMA26_0 = iMA(NULL, 0, 26, 1, MODE_EMA, PRICE_CLOSE, 0);
double eMA26_1 = iMA(NULL, 0, 26, 1, MODE_EMA, PRICE_CLOSE, 1);
// ----
if( eMA12_0 > eMA26_0 && eMA12_1 < eMA26_1
&& OrdersTotal()<1)
{ OrderSend(Symbol(), OP_BUY, 0.1, Ask, 0, 0, 0, "Test Long", 29072010, 0, Green); }
if( eMA12_0 < eMA26_0 && eMA12_1 > eMA26_1
&& OrdersTotal()<1)
{ OrderSend(Symbol(), OP_SELL, 0.1, Bid, 0, 0, 0, "Test Short", 29072010, 0, Red); }
// ----
Bingo
The condition could never be fulfilled as the 2MAs are never equal due to not normalizing the double value on them.
Thanks

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
Can anyone advise me what is wrong with this code? Logic is to long 2 lots when 12EMA and 26 EMA meets, however backtesting this EA resulted in zero trades executed.
/+------------------------------------------------------------------+
int start()
{
if(iMA(NULL,60,12,0,MODE_EMA,PRICE_CLOSE,0)==iMA(NULL,60,26,0,MODE_EMA,PRICE_CLOSE,0))
OrderSend("EURUSD",OP_BUY,lot_size*2,Ask,3,0,0,NULL,0,0,Red); //enter market long order for 2lots
//----
return(0);
}