Download MetaTrader 5

meta editor using

To add comments, please log in or register
Write articles and earn money. We pay 200 USD for them!
mareks1
131
mareks1 2015.03.24 23:59 

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);

Drazen Penic
2540
Drazen Penic 2015.03.25 01:22  

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".

Bahrom Juraev
15975
Bahrom Juraev 2015.03.25 19:20  
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
To add comments, please log in or register