Shift iMA

114547

Hi there,

I was wondering if anyone knows the difference between the following arguments for iMA: "ma_shift" vs "shift". All I want to do is to calculate the value for 9 bar Moving Averages for current bar, previous bar, and previous to previous bar. But I am not too sure whether I should use "ma_shift" or "shift". I would appreciate if someone can provide an explanation.

iMA is defined as follow:
double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)

ma_shift - MA shift. Indicators line offset relate to the chart by timeframe.
shift - Shift relative to the current bar (number of periods back), where the data should be taken from.

Thanks in advance
114547

114547

Thank you Slawa!

So, I can use both ma_shift and shift but in reverse signage. In other words in your above example, ma_shift=8 is the same as shift = -8, and vice versa.

correct?
114547

no. there are difference. "ma_shift" shifts moving average line relative to beginning of chart. "shift" is number of bar (from current bar) from wich You take ma_value. another example:

iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,0)
is the same
iMA(NULL,0,13,0,MODE_SMMA,PRICE_MEDIAN,8)

or
iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,-8)
is the same
iMA(NULL,0,13,0,MODE_SMMA,PRICE_MEDIAN,0)

you can check it