Download MetaTrader 5

mq5 indicators vs mq4 indicators

To add comments, please log in or register
Gerard Ngawati
105
Gerard Ngawati  

Hi All

Is there any advantage of the implementation of mq5 indicators compared to mq4.


The mq5 by comparison seem to be all over the place code wise and requires so much more resource coding wise. 
one call in oninit, 2 global variables.  Has anyone managed to get to get it down to one or 2 lines?  Is the call in oninit necessary? 

Are there speed advantages?  or does it make for better error checking. 

To be honest I haven't looked in detail hoping someone had a quick answer.   Hopefully I am not sounding to negative but its discouraging my transition to mq5. 

For example something like:

atr_base_line=iATR( NULL,0,atr_baseline_period,0);

compared to mql5:

double      MA[];                // array for the indicator iMA
int         MA_handle;           // handle of the indicator iMA
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   //--- creation of the indicator iMA
   MA_handle=iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE);
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   //--- filling an array MA[] with current values of iMA
   //--- Copying 100 elements
   CopyBuffer(MA_handle,0,0,100,MA);
   //--- set indexing of elements as series, as in MQL4
   ArraySetAsSeries(MA,true);  
   //--- here you can use the data of MA[] as you wish, for example: 
   if(MA[0]>MA[1])
      {
      //--- some operations
      } 
   }  

   
kypa
777
kypa  
Advantages - more timeframes, OpenCL, tick history, custom symbols, people say the tester is much better, I don't know about that; disadvantages - no short functions, real market is way more complicated than MT4 trading functions.
Alain Verleyen
Moderator
36407
Alain Verleyen  
Gerard Ngawati:

Hi All

Is there any advantage of the implementation of mq5 indicators compared to mq4.


The mq5 by comparison seem to be all over the place code wise and requires so much more resource coding wise. 
one call in oninit, 2 global variables.  Has anyone managed to get to get it down to one or 2 lines?  Is the call in oninit necessary? 

Are there speed advantages?  or does it make for better error checking. 

To be honest I haven't looked in detail hoping someone had a quick answer.   Hopefully I am not sounding to negative but its discouraging my transition to mq5. 

...

Quick answer :

double      MA[]; int         MA_handle; int OnInit() { MA_handle=iMA(NULL,0,21,0,MODE_EMA,PRICE_CLOSE); return(0); }
void OnTick() {  CopyBuffer(MA_handle,0,0,100,MA);  ArraySetAsSeries(MA,true);  if(MA[0]>MA[1]) {  /* some operations */ } }  

2 lines !

Anthony Garot
552
Anthony Garot  
Alain Verleyen:

Quick answer :

2 lines !

Ha! Perfect!

Gerard Ngawati
105
Gerard Ngawati  
Alain Verleyen:

Quick answer :

2 lines !

Figured that, can use it but still a big overhead.  Its funny how mt5 is by far superior application to mt4 but the vast majority of EA's and signals are mt4.  Filter by 3 years and it becomes even more significant.
I wonder why?  Apparently I am not the only who thinks that.

To add comments, please log in or register