Copula.mqh measures how two series move together beyond their correlation, in particular on their worst and best days. It fits five bivariate copulas by maximum likelihood on the ranks of the data (Gaussian, Student t, Clayton, Gumbel and Frank), gives Kendall's tau, the tail dependence, the probability of a joint extreme day, the AIC to choose a family, the conditional probabilities used in copula pairs trading, and random draws. No DLL; the normal and t functions come from the standard library (Math\Stat).
#include <Copula\Copula.mqh>
double x[], y[]; // returns of two symbols on the same bars
// ... fill x and y ...
double u[], v[];
CCopula::Ranks(x, u); // pseudo-observations in (0, 1)
CCopula::Ranks(y, v);
CCopula c;
c.SetData(u, v);
if(c.Fit(COPULA_STUDENT))
{
double lower = c.LowerTail(); // limit of P(y crashes | x crashes)
double joint = c.JointLower(0.05); // P(y in its worst 5% | x in its worst 5%)
double aic = c.AIC();
double h = c.H(u[ArraySize(u) - 1], v[ArraySize(v) - 1]); // P(U <= u | V = v) for the last bar
} The script CopulaReport.mq5 takes two symbols, fits the five copulas to their returns, ranks them by AIC and prints the tail dependence and the probability of a joint worst and best 5% day for each, next to what the data show, and the conditional probabilities of the last bar (picture 1). For gold and silver on D1 the Student t copula is the best; the Gaussian one, which has no tail dependence, puts the joint 5% days at 50% when the data show 67% (picture 2).


Against an independent scipy version on four simulated samples (Gaussian, Student t, Clayton and Gumbel dependence) and on gold and silver H4 returns, 25 fits:
Copula.mqh goes to MQL5\Include\Copula, CopulaReport.mq5 to MQL5\Scripts\Copula.
ChangePoint: Bayesian online change point detection
Online detection of changes in the mean or volatility (Adams-MacKay): probability of a change in the last k bars, current segment length, forecast, and an indicator.
MeanReversion: Ornstein-Uhlenbeck fit and optimal trading bands
Exact maximum likelihood of an Ornstein-Uhlenbeck spread and Bertram's optimal entry and exit levels for a given cost, with the expected length of a trade cycle.
Supply Demand Zones
Supply and demand zones for Gold (XAUUSD), EURUSD and any symbol: zones from swing highs and lows sized by ATR, fresh or tested, merged, broken ones removed, alerts and 5 buffers for EAs. Open source code.
Daily Loss Guard
Closes all trades when your daily loss reaches your limit.