The code for iMAOnArray is here:
https://www.mql5.com/en/articles/81
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.
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?
Any ideas?
Unfortunately not.
Maybe you should search for MQL5 math libraries.
Once I saw one including statistics, but dont remember where.
https://www.mql5.com/en/code/1146
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.
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.
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);
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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