**mini919 posted # :**

I am writing the customized MACD indicator and would like to use the similar function like iMaOnArray in MT4. Would you please tell me which new function is the replacement in MT5? Thanks a lot!

Cheers,

Linyi

Thanks, Rosh. I found another article which pointing to the sample indicator called "Custom Moving Average" included in MT5. It has the following function. Does it mean that iMAOnArray is not supported and we have to use this function to implement the same functionality ourselves? (it is simple although a native function would be better)

void CalculateSimpleMA(int rates_total,int prev_calculated,int begin,const double &price[])

{

int i,limit;

//--- first calculation or number of bars was changed

if(prev_calculated==0)// first calculation

{

limit=InpMAPeriod+begin;

//--- set empty value for first limit bars

for(i=0;i<limit-1;i++) ExtLineBuffer[i]=0.0;

//--- calculate first visible value

double firstValue=0;

for(i=begin;i<limit;i++)

firstValue+=price[i];

firstValue/=InpMAPeriod;

ExtLineBuffer[limit-1]=firstValue;

}

else limit=prev_calculated-1;

//--- main loop

for(i=limit;i<rates_total;i++)

ExtLineBuffer[i]=ExtLineBuffer[i-1]+(price[i]-price[i-InpMAPeriod])/InpMAPeriod;

//---

}

I am writing the customized MACD indicator and would like to use the similar function like iMaOnArray in MT4. Would you please tell me which new function is the replacement in MT5? Thanks a lot!

Cheers,

Linyi