Statistical Functions – library MetaTrader 5

Set of statistical functions which allows you to calculate some values describing timeseries like correlation between two time series, linear regression, standard deviation etc. It includes also more advanced functions like definite integral.

Header file “Statistics.mqh” includes following functions:

Syntax Description Return type
 mean(T &arr[])  Mean  (generic) 
 std(double &arr[])  Standard deviation  double
 correlation(&arr1[], &arr2[])  Correlation coefficient  double
 detrend(arr[], resultArray[])  Timeseries decomposition  void
 regression(&arr1[], &arr2[], &res[])  Regression line  void
 regression(double &arr1[], double &arr2[], double &res[], double &aCoeff,double &bCoeff)  Regression line with coefficients  void
 dickeyFuller(double &arr[])   Dickey-Fuller test for stationarity  bool
 engleGrangerTest(double &arr1[], double &arr2[],double &cointCoeff)   Engle-Granger 2-step method for testing cointegration  bool
 AR1(double &arr[])  Autoregressive model with lag 1  double
 signedIntegral(double a, double b, int n) *  Definite integral  double
 erf(double x)   Error function  double
 normDistZ(double z)   Probability that variable is from normal distrbution  double

* You should add your own implementation of “foo” function which you want to integrate. Default function is: f(x) = x.

Alternative:  Fractal_RSI_HTF - indicator MetaTrader 5

You should also remember that timeseries avaliable in MQL are indexed in a way that the newest data have a 0 index. It’s a good idea to reverse the order of such arrays and is absolutely necessay in AR model (arrays are not reversed inside of the method to avoid confusion).

📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks