Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2015.05.27 17:09
Libraries

Statistical Functions - library for MetaTrader 5

| English Русский 中文 Español Deutsch 日本語 Português

Views:
3510
Rating:
votes: 32
statistics.mqh (9.53 KB)view

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.

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).

BinaryWaveSign BinaryWaveSign

Semaphore signal indicator triggering when the BinaryWave indicator changes direction.

StochasticTrend_x10 StochasticTrend_x10

The StochasticTrend_x10 indicator shows the Stochastic oscillator position from ten different timeframes.

Correlate Correlate

The indicator shows correlation between currencies.

StocksBG StocksBG

StocksBG indicator displays the activity of major stock exchanges on a chart with M15 or less timeframe.