Skip to content
All library documents

Estimating Crash Risk with Peaks-Over-Threshold Extreme Value Theory

Article MQL5 code base

Summary

This document describes an MQL5 indicator that estimates downside tail risk using the Peaks-Over-Threshold method. It converts price changes into loss magnitudes, selects a high quantile as a threshold, and fits a Generalized Pareto Distribution to losses that exceed it. Maximum-likelihood fitting estimates the tail’s shape and scale, which are then used to calculate extrapolated Value at Risk and Expected Shortfall. A chart panel displays those readings and a color-coded shape estimate, while a sub-window plots VaR over time.

The document explains when the indicator withholds a reading: it requires at least 30 exceedances, rejects failed fits, and reports no Expected Shortfall when the fitted shape implies that the tail mean diverges. It gives an example showing that a longer lookback can provide enough tail observations where a shorter one does not. Recommended settings and configurable inputs are outlined. The method’s results depend on the threshold and available tail data; the indicator measures loss magnitude rather than direction or timing, so its readings are not trading signals.

Key ideas

  • Peaks-Over-Threshold fitting models only losses above a selected threshold using a Generalized Pareto Distribution.
  • Maximum-likelihood estimates of tail shape and scale support extrapolated VaR and Expected Shortfall calculations.
  • The indicator withholds readings when there are too few exceedances or when fitting fails.
  • Tail estimates depend on the threshold and the amount of usable historical data.
  • A rising tail index describes heavier downside risk, not a directional forecast.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.