Volatility Regime Classifier
Ranking current volatility against its own trailing distribution and cutting that ranking into three labelled buckets is straightforward. What breaks a naive version of this is a percentile that happens to sit right on a bucket boundary: a plain threshold relabels the regime almost every bar, which is worse than no label at all. This indicator fixes that with an asymmetric rule - entering a more extreme bucket (Normal to Stressed, or Normal to Calm) happens the instant the percentile crosses the boundary, but falling back toward Normal requires the percentile to clear that same boundary by a configurable margin (InpHysteresis) first. Extremes are reported immediately; recoveries have to prove themselves. The underlying measure is realised volatility - the standard deviation of single-bar log returns over a short window - ranked against InpLookback prior readings taken the same way, expressed as a 0-100 percentile. That percentile is plotted directly as the oscillator; the three-state regime with its hysteresis lives in the corner panel, coloured blue for Calm, silver for Normal and crimson for Stressed. Notes and limitations - The percentile rank scan compares the current reading against InpLookback prior windows computed the same way; a very large InpLookback noticeably slows the first calculation on a long chart history. - Percentile thresholds are relative to this symbol's own recent history, not an absolute volatility level - Calm on a quiet pair and Calm on a naturally volatile one are different numbers underneath. - The regime label describes what volatility has been doing over the lookback window, not what it will do next. - This does not size a position or place a stop; it only classifies the current volatility environment.
Indicator · MT5 · v1.0 · Free
About Volatility Regime Classifier
Volatility Regime Classifier is an indicator for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 10 settings, such as Vol period, Lookback and Calm pct. MQL source code included.
Files in the download: VolatilityRegimeClassifier.ex5, VolatilityRegimeClassifier.mq5, VolatilityRegimeClassifier.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Vol period | 10 | Bars in the short realised-volatility window |
| Lookback | 100 | Prior windows ranked to build the percentile |
| Calm pct | 33.0 | Percentile at/below this = Calm |
| Stress pct | 67.0 | Percentile at/above this = Stressed |
| Hysteresis | 8.0 | Margin required to fall back toward Normal |
| Alerts | true | Alert once when the regime changes |
| Corner | CORNER_LEFT_UPPER | Panel corner |
| X distance | 10 | Panel horizontal offset, pixels |
| Y distance | 20 | Panel vertical offset, pixels |
| Font size | 10 | Panel font size |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 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: Trailing Stop & Break-even · Alerts · MT5 Indicator · MQL5 Source Code