Migrating iStdDevOnArray and iMAOnArray from MQ4 to MQ5
The code for iMAOnArray is here:
https://www.mql5.com/en/articles/81
- 2010.05.17
- Sergey Pavlov
- www.mql5.com
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?
Unfortunately not.
Maybe you should search for MQL5 math libraries.
Once I saw one including statistics, but dont remember where.
- votes: 48
- 2012.10.12
- Sergey Bochkanov
- www.mql5.com
https://www.mql5.com/en/code/1146
You can definitely use Math\Alglib\alglib.mqh
double mean, variance, tmp1, tmp2;
CAlglib::SampleMoments(tempArray, mean, variance, tmp1, tmp2);
which will give you the variance of the array. Since the StdDev is the sq root of varianace, it's then a simple process of:
double stdDev = MathSqrt(variance);
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