- MQL5 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| Experts/EVT | ||
| Include/EVT | ||
| Indicators/EVT | ||
| README.md | ||
EVT
Extreme Value Theory tail-risk tooling for MetaTrader 5. Fits a Generalised Pareto Distribution to the tail of the return distribution instead of assuming a normal one.
Companion code for the MQL5 article: https://www.mql5.com/en/articles/23278
What it does
Normal-assumption risk numbers underestimate the tail, and they underestimate it worst exactly when it matters. Peaks-Over-Threshold takes a different route: ignore the body of the distribution entirely, keep only the exceedances beyond a high threshold, and fit a GPD to those.
CGPDModel does the fit and exposes Value at Risk and Expected Shortfall from
it. Two consumers sit on top:
EVTCrashGauge.mq5reads the fitted tail as a live gauge.EVTRiskOverlay.mq5sizes positions from it.
The article includes the limitations, which are real: threshold choice matters, and a tail fitted on data that contains no crash cannot tell you much about crashes.
Layout
Include/EVT/GPDModel.mqh GPD fit, VaR, Expected Shortfall
Indicators/EVT/EVTCrashGauge.mq5 live tail gauge
Experts/EVT/EVTRiskOverlay.mq5 position sizing from the fitted tail
Copy the folders into your terminal's MQL5 directory and compile.
Disclaimer
Educational code. Past behaviour of any model or dataset says nothing about future results. Test on your own data and broker conditions before drawing conclusions.