Problem with EMA -ve shift - page 2

 
ravie230:


sorry i dint get u...what ur saying...can u please explain me clear...

i want -3, -2, -1,1, 2, 3 ma_shift by coding....please gave an example on code....

Thank you.


The Bars on your chart have a number The latest bar still open is bar 0

The Bar before has number 1

To calculate the value of your shifted EMA there has to be a line with a value at that point

In your picture the line is shited with -2

for bar 0 and for bar 1 the line doesn't reach those points on chart so we get there no value for your shifted EMA

You are calculating the values for bar 0 There is no value if the line is shifted with a value < 0...

calculating bar 0 MA_shift -2

EMA_20=iMA(NULL,0,20,-2,MODE_EMA,PRICE_CLOSE,0);

calculating bar 1 MA_shift -2

EMA_20.1=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,1);

The last input is for the bar you are calculating

See picture with negative shift you move the line to the past and current bar has that way no value

Reason: