Download MetaTrader 5
To add comments, please log in or register
Do you have Mac OS? Find out how to install MetaTrader on it!
mini919
34
mini919 2010.03.29 17:21 

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 

Rashid Umarov
Admin
6598
Rashid Umarov 2010.03.29 17:29  
mini919
34
mini919 2010.03.29 17:57  
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;
//---
  } 

Rashid Umarov
Admin
6598
Rashid Umarov 2010.03.29 18:05  
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.
mini919
34
mini919 2010.03.29 18:45  
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 

mcai4sh3
37
mcai4sh3 2011.04.08 01:18  

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?? 

Zaven Vardanyan
502
Zaven Vardanyan 2013.05.18 11:39  
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.

Alain Verleyen
Moderator
28518
Alain Verleyen 2013.05.18 11:48  
You also have an implementation provided in this article.
Arturo Lopez Perez
158167
Arturo Lopez Perez 2013.08.23 17:02  
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?
Simon Gniadkowski
Moderator
17962
Simon Gniadkowski 2013.08.23 17:23  
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)
.
.
.
.
.
Arturo Lopez Perez
158167
Arturo Lopez Perez 2013.08.23 18:48  
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.

/ /12
To add comments, please log in or register