Download MetaTrader 5
To add comments, please log in or register
Find out how to install MetaTrader on Linux
Forex Trader
Forex Trader 2010.04.02 16:07 


Need serious help!! I am not sure it is metratrader or me.. I am writing EA and testing it .Part of it involves rising moving average.

my MA is 55 bars periods. Long order is triggered when MA(55) is rising past 3 bars. unfortunately it doesn't give me what I wanted.

For example, at some point in the chart, MA(55) is not rising, just flat, such as cur_ma is not greater than pre_ma. function is below

bool LMARising(){ //long MA is rising
double cur_lma,pre1_lma,pre2_lma,pre3_lma;
bool lma_rising;

pre1_lma = iMA(0,0,LMA_PERIOD,0,MODE_EMA,PRICE_CLOSE,1);
pre2_lma = iMA(0,0,LMA_PERIOD,0,MODE_EMA,PRICE_CLOSE,2);
pre3_lma = iMA(0,0,LMA_PERIOD,0,MODE_EMA,PRICE_CLOSE,3);

if((cur_lma>pre1_lma) && (pre1_lma>pre2_lma) && (pre2_lma>pre3_lma))
lma_rising = true;

lma_rising = false;

return (lma_rising);


recently, I just tested on EURUSD 30mins chart, some of those incorrect results are below

2010.04.02 22:26:05 2010.03.04 06:00 MACross-Version-1.2 EURUSDFXF,M30: cur_lma=1.3668 pre1_lma=1.3668 pre2_lma=1.3667

2010.04.02 22:26:05 2010.03.08 11:00 MACross-Version-1.2 EURUSDFXF,M30: cur_lma=1.3642 pre1_lma=1.3642 pre2_lma=1.3642
2010.04.02 22:26:05 2010.03.11 01:30 MACross-Version-1.2 EURUSDFXF,M30: cur_lma=1.3625 pre1_lma=1.3624 pre2_lma=1.3624
2010.04.02 22:26:05 2010.03.15 05:00 MACross-Version-1.2 EURUSDFXF,M30: cur_lma=1.3735 pre1_lma=1.3735 pre2_lma=1.3735
2010.04.02 22:26:06 2010.03.23 02:30 MACross-Version-1.2 EURUSDFXF,M30: cur_lma=1.3543 pre1_lma=1.3543 pre2_lma=1.3542

2010.04.02 22:26:06 2010.03.30 10:30 MACross-Version-1.2 EURUSDFXF,M30: cur_lma=1.3472 pre1_lma=1.3472 pre2_lma=1.3471

As you can see above, my orders are incorrectly triggered at those time, where it is supposed to be only if LMARising() function is true. Hope I made myself

clear. Please let me know how I can make that happen..

Thanks in advance.

To add comments, please log in or register