Extreme Value Theory (EVT) risk magnitude tool
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-14 00:09:41 +00:00
Experts/EVT initial commit 2026-06-27 13:21:14 +00:00
Include/EVT initial commit 2026-06-27 13:22:00 +00:00
Indicators/EVT initial commit 2026-06-27 13:20:16 +00:00
README.md Add README 2026-08-14 00:09:41 +00:00

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.mq5 reads the fitted tail as a live gauge.
  • EVTRiskOverlay.mq5 sizes 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.