meta editor using

 

I am sorry for this question. I am new. Can anybody explain me how to change the followig to get result for the previous candle (moving avarage)?

double MA6_2=iMA(Symbol(),0,ma_fast_period,0,ma_fast_method,ma_fast_price,1);

 

From the help:

 

double  iMA(
   string       symbol,           // symbol
   int          timeframe,        // timeframe
   int          ma_period,        // MA averaging period
   int          ma_shift,         // MA shift
   int          ma_method,        // averaging method
   int          applied_price,    // applied price
   int          shift             // shift
   );

 

Parameter "shift" is the candle index. Current candle has index 0, previous candle has index 1, and so on back in time.

Your code, as is, actually returns moving average value for the candle previous to the current candle.

If you get unexpected result, then you should check values for the variables "ma_fast_period",  "ma_fast_method" and "ma_fast_price".

 
mareks1:

I am sorry for this question. I am new. Can anybody explain me how to change the followig to get result for the previous candle (moving avarage)?

double MA6_2=iMA(Symbol(),0,ma_fast_period,0,ma_fast_method,ma_fast_price,1);

the last parameter - change it from 1 to 2    3      4    ...  and  you get past values