# How to get MA values that are shifted forward???

716

I use some shifted MAs, similar to alligator. I`m writing simple indicator to help me out when price crosses these MAs.

I need to call MAs values that are in front of the price, eg -3,-5,-8, but not sure how to do this. I can easy get current price + shifted back as many candles as I need, but how to go forward on chart??

These are my iMAs where i is last closed candle

``` Line_1[i]=iMA(Symbol(),0,Period1,Shift1,Metod1,Prise1,i);
Line_2[i]=iMA(Symbol(),0,Period2,Shift2,Metod2,Prise2,i);
Line_3[i]=iMA(Symbol(),0,Period3,Shift3,Metod3,Prise3,i);
Line_4[i]=iMA(Symbol(),0,Period4,Shift4,Metod4,Prise4,i);```

Any help would be much appreciated.

Cheers,

Ivo

2978

How do you expect to calculate a Moving Average (or any other indicator) based on future data that does not exist yet (negative shift)?

A positive shift looks at an older value of the moving average as is to be expected. When a MA is placed on a chart, that positive shift draws the older values at newer positions, making it look as if the MA has shifted to right visually, but is in reference to past data (not the future).

So, what you probably want is exactly that, visually it will shift to the right, but that shift is "positive" (not negative) and refers to older data.

716

Thanks for you comment, it has clear up thinks for me.

So I guess don`t even need to use shifted MAs when coding indicator, I was just used to seeing shifted MAs on my charts.

This shifted MAs is just BS

2978

ivolux:

Thanks for you comment, it has clear up thinks for me.

So I guess don`t even need to use shifted MAs when coding indicator, I was just used to seeing shifted MAs on my charts.

This shifted MAs is just BS

No, it is not BS! You just don't understand its use yet. There are actually many reasons to shift a MA. An example is to shift its "centre" to the current price.

A moving average is a lagging indicator and its "centre" is half way of the period used, so shifting it can be quite useful at times.

Obviously, in code, it can be done also by just adding the MA Shift in the "shift" parameter, instead of separately, but when done visually, one needs to have both parameters.