Bug in iMA function? It does not calculate on monthly bars (solved)

 

Run the following simple "expert advisor":

int start()
{
Print("Weekly iMA = ",iMA("EURUSD",PERIOD_W1,2,0,MODE_LWMA,PRICE_WEIGHTED,0));
Print("Monthly iMA = ",iMA("EURUSD",PERIOD_MN1,2,0,MODE_LWMA,PRICE_WEIGHTED,0));
}

You will get an output file like this:

20:12:57 Test EURUSD,M1: loaded successfully
20:12:57 Test started for testing
20:12:57 2008.12.04 00:01 Test EURUSD,M1: Weekly iMA = 1.2705
20:12:57 2008.12.04 00:01 Test EURUSD,M1: Monthly iMA = 0
20:12:57 2008.12.04 00:01 Test EURUSD,M1: Weekly iMA = 1.2705
20:12:57 2008.12.04 00:01 Test EURUSD,M1: Monthly iMA = 0
20:12:57 2008.12.04 00:02 Test EURUSD,M1: Weekly iMA = 1.2704
20:12:57 2008.12.04 00:02 Test EURUSD,M1: Monthly iMA = 0
20:12:57 2008.12.04 00:02 Test EURUSD,M1: Weekly iMA = 1.2704
20:12:57 2008.12.04 00:02 Test EURUSD,M1: Monthly iMA = 0
...

This proves that the technical indicator does not calculate on monthy bars! Or not? Am I missing something? Can't see other explanation than a bug in iMA function.

 
jairo wrote >>

Run the following simple "expert advisor":

int start()
{
Print("Weekly iMA = ",iMA("EURUSD",PERIOD_W1,2,0,MODE_LWMA,PRICE_WEIGHTED,0));
Print("Monthly iMA = ",iMA("EURUSD",PERIOD_MN1,2,0,MODE_LWMA,PRICE_WEIGHTED,0));
}

You will get an output file like this:

20:12:57 Test EURUSD,M1: loaded successfully
20:12:57 Test started for testing
20:12:57 2008.12.04 00:01 Test EURUSD,M1: Weekly iMA = 1.2705
20:12:57 2008.12.04 00:01 Test EURUSD,M1: Monthly iMA = 0
20:12:57 2008.12.04 00:01 Test EURUSD,M1: Weekly iMA = 1.2705
20:12:57 2008.12.04 00:01 Test EURUSD,M1: Monthly iMA = 0
20:12:57 2008.12.04 00:02 Test EURUSD,M1: Weekly iMA = 1.2704
20:12:57 2008.12.04 00:02 Test EURUSD,M1: Monthly iMA = 0
20:12:57 2008.12.04 00:02 Test EURUSD,M1: Weekly iMA = 1.2704
20:12:57 2008.12.04 00:02 Test EURUSD,M1: Monthly iMA = 0
...

This proves that the technical indicator does not calculate on monthy bars! Or not? Am I missing something? Can't see other explanation than a bug in iMA function.

0:44:43 monthlytester started for testing
00:44:43 2008.03.03 00:00 monthlytester USDCAD,H1: Weekly iMA = 1.5161
00:44:43 2008.03.03 00:00 monthlytester USDCAD,H1: Monthly iMA = 1.5133
00:44:43 2008.03.03 00:02 monthlytester USDCAD,H1: Weekly iMA = 1.5161
00:44:43 2008.03.03 00:02 monthlytester USDCAD,H1: Monthly iMA = 1.5133
00:44:43 2008.03.03 00:10 monthlytester USDCAD,H1: Weekly iMA = 1.5161
00:44:43 2008.03.03 00:10 monthlytester USDCAD,H1: Monthly iMA = 1.5133
00:44:43 2008.03.03 00:10 monthlytester USDCAD,H1: Weekly iMA = 1.5161

Note did this on hourly chart, likely not enough data in your one minute chart file to do calcs.

Keith

 
kminler wrote >>

0:44:43 monthlytester started for testing
00:44:43 2008.03.03 00:00 monthlytester USDCAD,H1: Weekly iMA = 1.5161
00:44:43 2008.03.03 00:00 monthlytester USDCAD,H1: Monthly iMA = 1.5133
00:44:43 2008.03.03 00:02 monthlytester USDCAD,H1: Weekly iMA = 1.5161
00:44:43 2008.03.03 00:02 monthlytester USDCAD,H1: Monthly iMA = 1.5133
00:44:43 2008.03.03 00:10 monthlytester USDCAD,H1: Weekly iMA = 1.5161
00:44:43 2008.03.03 00:10 monthlytester USDCAD,H1: Monthly iMA = 1.5133
00:44:43 2008.03.03 00:10 monthlytester USDCAD,H1: Weekly iMA = 1.5161

Note did this on hourly chart, likely not enough data in your one minute chart file to do calcs.

Keith

Hi Keith,

Thanks for the reply. My M1 data report back to 1999. But I am getting a lot of "unmatched data error" in the log file. This is probably causing the problem. I tried to go to the History Center and download quotes from MetaQuotes. But this got rid of recent data (M1 bars from 2008.12.26 until today). If I close the platform, delete all history files ( . hst ? ) and reopen it, I suppose it will download everything again from the broker. Looks like downloading from MetaQuotes is not reliable (I used to do it frequently). This is the first time I have a serious issue with quotes. How can I get and maintain reliable quotes? I am not too much worried about tick precision, but just keep the tester running normally. Thanks again.

 
jairo wrote >>

Hi Keith,

Thanks for the reply. My M1 data report back to 1999. But I am getting a lot of "unmatched data error" in the log file. This is probably causing the problem. I tried to go to the History Center and download quotes from MetaQuotes. But this got rid of recent data (M1 bars from 2008.12.26 until today). If I close the platform, delete all history files ( . hst ? ) and reopen it, I suppose it will download everything again from the broker. Looks like downloading from MetaQuotes is not reliable (I used to do it frequently). This is the first time I have a serious issue with quotes. How can I get and maintain reliable quotes? I am not too much worried about tick precision, but just keep the tester running normally. Thanks again.

Hi Keith and all,

"Data newbie" error on my part. The starting date of the test is decisive. If testing from middle Dec 2008, there are not 2 months data to calculate iMA(2). Thanks for the help. Will think a bit more before screaming for help. Shame on me...

 
jairo wrote >>

Hi Keith and all,

"Data newbie" error on my part. The starting date of the test is decisive. If testing from middle Dec 2008, there are not 2 months data to calculate iMA(2). Thanks for the help. Will think a bit more before screaming for help. Shame on me...

No need to beat yourself up, nobody here is perfect and MQL4 seems designed to test everyones patience. If you ever do find a simple way to get and maintain reliable data please let me know.

keith

Reason: