How you store the iMA values of 0,1,2 (current, prev1bar, prev2bar)?

 
How one can store the Moving Average values for the current bar, prev1, prev2 bars?

for example, I need to compare the iMA values and I need to store them before comparing.

For every newbar start/open, I need to compare the current value of iMA in the latest bar (o) and the previous bar(1) and 2nd Previousbar (2).

How one can store these values?

Thanks
 
Store them in a double; single variables or arrays
 
Well, It is not working.

I am giving the code below. IS this correct way?

MAZERO = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, i);
MAONE = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, i-1);
MATWO = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, i-2);

or anyother way to store them? I am trying to store/get these values at every bar close using NewBa() function.

Thanks for ur help in advance.
 
Yours is almost right, see note at bottom.

If using array:

double MA[3];

MA[0] = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, 0);
MA[1] = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, 1);
MA[2] = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, 2);

The current bar is always bar 0, and going back in time is bar 1, 2, 3 etc
Reason: