Tail Exponent Estimator
Standard deviation treats every return the same regardless of how extreme it is, so it cannot answer a specific question that matters for risk sizing: how fat is the TAIL, specifically - how much more likely are the biggest moves than a Normal distribution would suggest? The Hill estimator answers exactly that. Given the k largest absolute returns in a window, sorted so X(1) is the smallest of those k and X(k) the largest, the Hill estimator is: alpha_hat = k / sum(i=1..k) of ln( X(i) / X_threshold ) where X_threshold is the (k+1)-th largest value (the smallest one just below the tail sample). alpha_hat is the estimated tail index: lower alpha means fatter tails (extreme moves are common - closer to Cauchy-like behaviour), higher alpha (roughly 4 and above) is closer to thin-tailed, Normal-like behaviour. This is the actual named Hill estimator formula, computed over the k largest order statistics of the rolling window - not an approximation using kurtosis or kept-simple as a rolling standard deviation with a different label. Two horizontal reference levels are drawn at alpha=2 and alpha=4 as rough orientation: below 2 marks genuinely extreme tail behaviour (a return distribution with theoretically infinite variance in the limit); above 4 is closer to what a Normal-distribution risk model would assume. Notes and limitations - Real Hill (1975) estimator over the k largest order statistics of |return| - not a kurtosis or standard-deviation-ratio proxy. - A return exactly at zero in the tail sample is skipped rather than taken through ln(0); a window where the threshold value itself is zero (a completely flat price stretch) returns no value for that bar rather than a divide-by-zero result. - The Hill estimator is known to be sensitive to the choice of k in finite samples - this indicator does not automate k-selection (e.g. via a Hill plot across many k values), which is a legitimate simplification for a CodeBase indicator; changing InpTailSize and comparing readings is the practical substitute. - Does not repaint - each bar's value only ever uses bars at or before it.
Indicator · MT4 · v1.0 · Free
About Tail Exponent Estimator
Tail Exponent Estimator is an indicator for MetaTrader 4. It has 2 settings, such as Lookback and Tail size. MQL source code included.
Files in the download: TailExponentEstimator.mq4, TailExponentEstimator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Lookback | 250 | Bars of returns in the rolling window the tail is estimated from |
| Tail size | 40 | k - number of largest |return| order statistics used (must be < InpLookback) |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: MT4 Indicator · MQL4 Source Code