Download MetaTrader 5

iMA (mql4)

To add comments, please log in or register
We have launched Spanish and Portuguese versions of the website. Try them!
Mohammad Soubra
25009
Mohammad Soubra 2016.01.30 10:32 

In the shown pic above, Please let us know what is the difference between the (int ma_shift) in the center of function inputs & (int shift) in the last of function inputs ...

iMA (Symbol(), PERIOD_D1, 14, 0, MODE_SMA, PRICE_CLOSE, 0);
Stuart Browne
5816
Stuart Browne 2016.01.31 01:53  
Mohammad Soubra:

In the shown pic above, Please let us know what is the difference between the (int ma_shift) in the center of function inputs & (int shift) in the last of function inputs ...

The MA shift is what it says - the bar shift that the MA uses when calculating. Have a look at the input options when you apply a simple MA to a chart. It is the shift function in here.

The last shift in iMA is the bar number you want to get the MA result from. So 0 is the current bar, 1 is the previous bar etc. 

Mohammad Soubra
25009
Mohammad Soubra 2016.01.31 09:14  
Stuart Browne:

The MA shift is what it says - the bar shift that the MA uses when calculating. Have a look at the input options when you apply a simple MA to a chart. It is the shift function in here.

The last shift in iMA is the bar number you want to get the MA result from. So 0 is the current bar, 1 is the previous bar etc. 

Thanks Mr. Stuart

 

but...

 

plz look at the image below and let me know where are the twice of them

 

 

I can see only one shift !

Trinh Dat
37213
Trinh Dat 2016.01.31 13:39  
Below is 2 MA(14), red line used Shift =0, blue line used Shift= 10


Mohammad Soubra
25009
Mohammad Soubra 2016.01.31 14:07  

thanks Trinh,

the image you have been sent is like:

iMA (Symbol(), PERIOD_D1, 14, 0, MODE_SMA, PRICE_CLOSE, 10);
iMA (Symbol(), PERIOD_D1, 14, 0, MODE_SMA, PRICE_CLOSE, 0);


//------------------------------

 

but if you use the code :

 

iMA (Symbol(), PERIOD_D1, 14, 0, MODE_SMA, PRICE_CLOSE, 10);
iMA (Symbol(), PERIOD_D1, 14, 0, MODE_SMA, PRICE_CLOSE, 0);

iMA (Symbol(), PERIOD_D1, 14, 10, MODE_SMA, PRICE_CLOSE, 10);
iMA (Symbol(), PERIOD_D1, 14, 10, MODE_SMA, PRICE_CLOSE, 0);

 

 

 

 

I cannot see that referred on the pic above while looking @ a chart 

Mohammad Soubra
25009
Mohammad Soubra 2016.01.31 14:26  
Stuart Browne:

The MA shift is what it says - the bar shift that the MA uses when calculating. Have a look at the input options when you apply a simple MA to a chart. It is the shift function in here.

The last shift in iMA is the bar number you want to get the MA result from. So 0 is the current bar, 1 is the previous bar etc. 

please mr Stuart can you clarify more .

 

Marco vd Heijden
Moderator
4704
Marco vd Heijden 2016.01.31 14:37  

The bar shift is not used in the input window because the visible portion will run over all bars on the chart creating the moving average line.

For a robot, however, if you want to know the value of a specific bar, that is where the last variable comes into play.

You have to specify a single buffer position.

In summary, the first shift shifts the entire calculation over the chart (All bars), while the last shift specifies the index value of the indicator buffer (A single bar).

Trinh Dat
37213
Trinh Dat 2016.01.31 14:38  
Mohammad Soubra:

thanks Trinh,

the image you have been sent is like:

but if you use the code :

I cannot see that referred on the pic above while looking @ a chart 


No,  MA Shift = 10 , see chart below

   double ma1= iMA(NULL,0,14,0,MODE_SMA,PRICE_CLOSE,0);
   
   double ma2= iMA(NULL,0,14,10,MODE_SMA,PRICE_CLOSE,0);
   
   Comment("At Bar 0 ( or shift = 0 ) : MA1 = " + DoubleToStr(ma1,5) + " MA2 = " + DoubleToStr(ma2,5));



Mohammad Soubra
25009
Mohammad Soubra 2016.01.31 15:25  
Marco vd Heijden:

The bar shift is not used in the input window because the visible portion will run over all bars on the chart creating the moving average line.

For a robot, however, if you want to know the value of a specific bar, that is where the last variable comes into play.

You have to specify a single buffer position.

In summary, the first shift shifts the entire calculation over the chart (All bars), while the last shift specifies the index value of the indicator buffer (A single bar).

Hello my friend :) 

can you clarify imore n images

Marco vd Heijden
Moderator
4704
Marco vd Heijden 2016.01.31 15:44  

sure


Mohammad Soubra
25009
Mohammad Soubra 2016.01.31 15:49  
Marco vd Heijden:

sure


MY FRIEND !

This is not what I am exactly asking about

I am asking about the shift in the beginning

see the images below

 

 

or 

 

or

 

 

12
To add comments, please log in or register