Which function replaced the iMaOnArray in MT4?

 

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 

 
 
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;
//---
  } 

 
mini919 posted # :

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)

Yes, it is. You can use any implementation which you need. There are lots of possibilities and functions in the MQL5, we consider that it's not nessesary to make such functions.
 
Rosh posted # :
Yes, it is. You can use any implementation which you need. There are lots of possibilities and functions in the MQL5, we consider that it's not nessesary to make such functions.

Hi, Rosh

 Thanks a lot for your great help. I wrote an article in Chinese on my blog to share our discussion and my analyze with Chinese traders. Here is the link: http://blog.sina.com.cn/s/blog_661cb0c50100i4ge.html

Cheers,

Linyi 

 

I still don't understand why iMAOnArray is not within mt5?

 

Taking such a function away and expecting us to develop this functionality when it was there previously is crazy?? 

 
mcai4sh3:

I still don't understand why iMAOnArray is not within mt5?

 

Taking such a function away and expecting us to develop this functionality when it was there previously is crazy?? 

What about code like this?

#include <MovingAverages.mqh>

 and then use:

SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);

 Look at Indicators/Examples/MACD.

 
You also have an implementation provided in this article.
 
mcai4sh3:

I still don't understand why iMAOnArray is not within mt5?

Taking such a function away and expecting us to develop this functionality when it was there previously is crazy?? 

I just bumped into the same issue migrating some MT4 indicators. I am all in for new functions and improvements, but why removing old ones?
 
PzTrading:
I just bumped into the same issue migrating some MT4 indicators. I am all in for new functions and improvements, but why removing old ones?

It probably wasn't removed,  just not coded for mql5 . . .  mql4 probably wasn't converted to mql5,  mql5 was created from scratch.

The code does exist though,  as angevoyageur said (follow his link)  . . .

double iMAOnArrayMQL4(double &array[],
                      int total,
                      int period,
                      int ma_shift,
                      int ma_method,
                      int shift)
  {
   double buf[],arr[];
   if(total==0) total=ArraySize(array);
   if(total>0 && total<=period) return(0);
   if(shift>total-period-ma_shift) return(0);
   switch(ma_method)
.
.
.
.
.
 
RaptorUK:

It probably wasn't removed,  just not coded for mql5 . . .  mql4 probably wasn't converted to mql5,  mql5 was created from scratch.

The code does exist though,  as angevoyageur said (follow his link)  . . .

I just tested it, and it is x10 times slower than his MT4 cousin. I will just code it myself.

MT5 has really cool new features, but imo, it has some setbacks, like this.

Did you used ImaOnArray? Now code it yourself. LOL

People is going to use MT4 for a long, long time.

Reason: