# Using the iMA Indicaor in different periods

5

Hello everybody,

i am new to meta trader 4 and i am trying to obtain some indicator data from the moving average function.

But i don't get some basic things.  If i use the M30 Period averaging over two periods shouldn't it be the H1 result for one period?

here is my example code:

`Print(" M30*2 = "+iMA("EURUSD", PERIOD_M30, 2, 0, MODE_EMA, 0, 20)+" H1 = "+iMA("EURUSD", PERIOD_H1, 1, 0, MODE_EMA, 0, 10));`

The other question is, if i use the shift argument in the right way to read the same time period for both indicator results.

My answer for the example is "File write EURUSD,M1:  M30*2 = 1.106739999999999 H1 = 1.10631".

How the iMA indicator react when i ask him to give me history data in the following format?

`inputVector[17] = (10*ep)*(iMA("EURUSD", PERIOD_M1, 60, 0, 0, 0, shift_min+181));`

where in a loop "shift_min" goes up to 720 (around one day).

Thank you for every usable advice

15009

Fufantus: If i use the M30 Period averaging over two periods shouldn't it be the H1 result for one period?

Never

At the top of the hour, m30Close[1] == H1Close[1] therefor for the SMA  (M30close[2] + m30close[1])/2 will never be equal to the m30Close[1]/1 == H1Close[1]/1

The EMA includes all other candles (to some extent) thefor they will never be the same.