Download MetaTrader 5

Migrating iStdDevOnArray and iMAOnArray from MQ4 to MQ5

To add comments, please log in or register
simplex
28
simplex  

Hi Guys,

Migrating my standard libs from MQ4 to MQ5 is about to drive me crazy! At the moment I'm trying to find replacements for functions iStdDevOnArray and iMAOnArray - see code snippet.

It's the purpose of this function to normalize value inArray[sh] by standard deviation related to the relevant part (parameter normPeriod) of the array.

/* -----------------------------------------------------------
    normStdDevOnArray
    normalization by standard deviation
   ----------------------------------------------------------- */
double normStdDevOnArray(double& inArray[], const double normPeriod, const int sh) {
   double out = 0.0;
   double sdev = iStdDevOnArray(inArray, 0, normPeriod, 0, MODE_SMA, sh);
   double mean = iMAOnArray    (inArray, 0, normPeriod, 0, MODE_SMA, sh);
   out = safeDivide((inArray[sh] - mean), sdev);
   return ( out );
}

How would you migrate that?

Cheers, simplex

svengralla
116
svengralla  

The code for iMAOnArray is here:

https://www.mql5.com/en/articles/81

Migrating from MQL4 to MQL5
Migrating from MQL4 to MQL5
  • 2010.05.17
  • Sergey Pavlov
  • www.mql5.com
This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference.
simplex
28
simplex  
svengralla:

The code for iMAOnArray is here:

https://www.mql5.com/en/articles/81

Thanks svengralla!

I already found that article, but unfortunately it skips the migration of

iStdDevOnArray

Any ideas?

svengralla
116
svengralla  
Any ideas?

Unfortunately not. 

Maybe you should search for MQL5 math libraries.

Once I saw one including statistics, but dont remember where.

svengralla
116
svengralla  
https://www.mql5.com/en/code/1146
ALGLIB - Numerical Analysis Library
ALGLIB - Numerical Analysis Library
  • votes: 48
  • 2012.10.12
  • Sergey Bochkanov
  • www.mql5.com
ALGLIB math function library (v. 3.5.0) ported to MQL5.
Tadas Talaikis
50
Tadas Talaikis  
svengralla:
https://www.mql5.com/en/code/1146
I've also searched, there are no examples on iStdDevOnArray. Will try to use ALGLIB as probably this will be efficient than just converting from MQL4.
To add comments, please log in or register