iMAOnArray and MA on indicator values not the same

 

Hi all!

I have a problem in MQ4, that if I call iMAOnArray on an indicator's data (for example Awesome oscill, or Bulls), it doesn't return the same value as the same (exponential 3) MA that I put on the same indicator by hand. The difference is about 0.03 in both direction. My code is (for example):

double iao0=iAO(NULL, 0, 0);

double iao1=iAO(NULL, 0, 1);

double iao2=iAO(NULL, 0, 2);

ma_arr[0]=iao0;

ma_arr[1]=iao1;

ma_arr[2]=iao2;

double macurrent=iMAOnArray(ma_arr,0,3,0,MODE_EMA,0);

What could cause the problem, or what could be a solution for it?

Thank you in advance!

 
You need 3.45 * (N+1) values to create an EMA (14 values for a 3 period ema,) and you've given it 3.
 
WHRoeder:
You need 3.45 * (N+1) values to create an EMA (14 values for a 3 period ema,) and you've given it 3.

That was it, thanks!:)

(And also had to put the data reverse order into the array - it can be done with ArraySetAsSeries.)

 
RonM: (And also had to put the data reverse order into the array.)
Or make it a series array when you want the 0 element to be the newest.