Problem with EMA -ve shift

 
Hay, can u please help me, how to use negative shifts in EMA....
iam getting output as 0 when i used -ve shifts in EMA and also in Bollinger Bands.

here is the code...

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

iam getting 0 as output....

please help me on this.....

Thank you.
 
ravie230:
Hay, can u please help me, how to use negative shifts in EMA....
iam getting output as 0 when i used -ve shifts in EMA and also in Bollinger Bands.

here is the code...

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


I am no expert in Technical Indicators but how do you expect to get a Moving Average partly based on bars that have not yet happened . . bars -1 and -2 ?

Perhaps you mean something like this . . . ?

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


I am no expert in Technical Indicators but how do you expect to get a Moving Average partly based on bars that have not yet happened . . bars -1 and -2 ?

Perhaps you mean something like this . . . ?


EMA_20=iMA(NULL,0,20,2,MODE_EMA,PRICE_CLOSE,-2);
This is moving EMA into the "future" with two periods so there is in futurebar -2 a value
 
deVries:

This is moving EMA into the "future" with two periods so there is in futurebar -2 a value


Thanks for information....

but we can use -ve and +ve shifts, when we are adding Moving average indicator to mt4 chart.....

why not in EA......

please look at this image.......

https://www.box.com/s/583920a09ab5b064fede

 
ravie230:


Thanks for information....

but we can use -ve and +ve shifts, when we are adding Moving average indicator to mt4 chart.....

why not in EA......

I suspect that the "shift" you are talking about in the standard MT4 MA is the int ma_shift not int shift

iMA() <--- click me

 
ravie230:

please look at this image.......

https://www.box.com/s/583920a09ab5b064fede


That offsets the whole MA 2 bars to the left, use int ma_shift to do that.
 
RaptorUK:

That offsets the whole MA 2 bars to the left, use int ma_shift to do that.

ok...thanks ....i will check it.....
 
ravie230:


Thanks for information....

but we can use -ve and +ve shifts, when we are adding Moving average indicator to mt4 chart.....

why not in EA......

please look at this image.......

https://www.box.com/s/583920a09ab5b064fede


If it fails then Tell us how do you code the the Moving average indicator into your EA.

what is your value for ma_shift and what bar do you calculate in your EA ??

If you read also the comments RaptorUK shifting of the line is with ma_shift

That picture is the line with ma_shift -2 that gets the normal line to the past and you will have no value for bar zero

With a positive ma_shift the line will be moved to the right

 
deVries:


If it fails then Tell us how do you code the the Moving average indicator into your EA.

what is your value for ma_shift and what bar do you calculate in your EA ??

If you read also the comments RaptorUK shifting of the line is with ma_shift

That picture is the line with ma_shift -2 that gets the normal line to the past and you will have no value for bar zero

With a positive ma_shift the line will be moved to the right


hi i want -3, -2, -1, 0, 1, 2,3 shifts for 20 EMA .......

it want just like in the image...

https://www.box.com/s/1cb2d36d28e0caa14924

i have given

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

EMA_1_20=iMA(NULL,0,20,-1,MODE_EMA,PRICE_CLOSE,0); ----> -1 shift

EMA_2_20=iMA(NULL,0,20,-2,MODE_EMA,PRICE_CLOSE,0); ----> -2 shift

EMA_3_20=iMA(NULL,0,20,-3,MODE_EMA,PRICE_CLOSE,0); ----> -3 shift

EMA1_20=iMA(NULL,0,20,1,MODE_EMA,PRICE_CLOSE,0); ----> 1 shift

EMA2_20=iMA(NULL,0,20,2,MODE_EMA,PRICE_CLOSE,0); ----> 2 shift

EMA3_20=iMA(NULL,0,20,3,MODE_EMA,PRICE_CLOSE,0); ----> 3 shift

iam getting 0 for -ve shifts....

Thank you

 
ravie230:


hi i want -3, -2, -1, 0, 1, 2,3 shifts for 20 EMA .......

it want just like in the image...

https://www.box.com/s/1cb2d36d28e0caa14924

i have given

EMA_20=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,0); ----> 0 shift // shift 0 ==> Bar 0 first value no value -1,-2,-3,-4..

EMA_1_20=iMA(NULL,0,20,-1,MODE_EMA,PRICE_CLOSE,0); ----> -1 shift // shift -1 ==> Bar 1 first value no value 0,-1,-2,-3,-4..

EMA_2_20=iMA(NULL,0,20,-2,MODE_EMA,PRICE_CLOSE,0); ----> -2 shift

EMA_3_20=iMA(NULL,0,20,-3,MODE_EMA,PRICE_CLOSE,0); ----> -3 shift

EMA1_20=iMA(NULL,0,20,1,MODE_EMA,PRICE_CLOSE,0); ----> 1 shift

EMA2_20=iMA(NULL,0,20,2,MODE_EMA,PRICE_CLOSE,0); ----> 2 shift

EMA3_20=iMA(NULL,0,20,3,MODE_EMA,PRICE_CLOSE,0); ----> 3 shift

iam getting 0 for -ve shifts....

Thank you


That is a good thing with -ve you are shifting the line deeper in the past

Means the value without shifting of bar 0 is with shift -ve (== -3) now to find 3 bars before bar 0

Bar 0 " .........EMA,PRICE_CLOSE,0); " You are asking the value from bar 0. It has this way no value ( Also in your Picture ) so it is correct

Do you understand how the numbering of bars is defined and do you understand how to get the value of bar 9 with ma_shift -3 ??

 
deVries:


That is a good thing with -ve you are shifting the line deeper in the past

Means the value without shifting of bar 0 is with shift -ve (== -3) now to find 3 bars before bar 0

Bar 0 " .........EMA,PRICE_CLOSE,0); " You are asking the value from bar 0. It has this way no value ( Also in your Picture ) so it is correct

Do you understand how the numbering of bars is defined and do you understand how to get the value of bar 9 with ma_shift -3 ??


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.

Reason: