MQL4 - automated forex trading   /  

Forum

Value of Moving average Not Matching the actual average !!

Back to topics list To post a new topic, please log in or register

avatar
332
t4fast 2010.08.21 17:35 

Hi all,

I have come across a strange thing,

I've opened the GBPUSD daily chart, applied a 200 simple moving average on close values, the value of the 200 SMA was 1.5487

then I have downloaded the values (File,Save as) and calculated the average of the last 200 candles, and it was 1.5121 different from the indicator reading !!

any explanation ?


Forecasting Financial Time-Series

Forecasting Financial Time-Series

Forecasting financial time-series is a required element of any investing activity. The concept of investing itself - put up money now to gain profits in future - is based on the concept of predicting the future. Therefore, forecasting financial time-series underlies the activities of the whole investing industry - all organized exchanges and other securities trading systems.


avatar
1971
ubzen 2010.08.22 02:29 
I'm just guessing here. However the first thing that comes to my mind is the Difference in Points. Your chart may show 4 digits after the decimal point. Or the value you save might be 4-digits after the decimal point. The indicator on the other hand might be using 5 or more digits after the decimal point. The way I check this is to draw a Horizontal line using the line tool above. Then I double click it, then try to verify the value of the price it returns. Check that in the mean-time til someone who have a better explanation comes along. Again I'm just guessing here.

avatar
1
slack 2010.08.22 03:01 
t4fast:

Hi all,

I have come across a strange thing,

I've opened the GBPUSD daily chart, applied a 200 simple moving average on close values, the value of the 200 SMA was 1.5487

then I have downloaded the values (File,Save as) and calculated the average of the last 200 candles, and it was 1.5121 different from the indicator reading !!

any explanation ?


Are you sure you are using the close and the right formula because I'm getting correct numbers. Please post a screen-shot of your spreadsheet.

-


avatar
332
t4fast 2010.08.23 05:19 

To further confirm my findings,

i've looked at a different platform (real account)

and the moving average is indeed different. Please compare the last candles (for example)



4 digits average and a 5 digits average will not be that apart.




avatar
1971
ubzen 2010.08.23 08:12 

I did some investigation and I'm getting the same SMA as the Indicator in MT4. Attached is my script and my output file. Make sure you're using SMA instead of SMMA.

int start(){
//#################################################################
//#################################################################
int File1=FileOpen("Close200.csv",FILE_WRITE,',');
for(int a=1;a<=200;a++){
   FileWrite(File1,Close[a]);
}
//#################################################################
//#################################################################
double Simple_MA=iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,1);
FileWrite(File1,Simple_MA);Alert(Simple_MA);
FileClose(File1);
//#################################################################
//#################################################################
return(0);} 
Attached files:
  Close200.txt (1.77 KB)
Back to topics list  

To add comments, please log in or register