Loading…

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

SettingDefaultWhat it does
Vol period10Bars in the short realised-volatility window
Lookback100Prior windows ranked to build the percentile
Calm pct33.0Percentile at/below this = Calm
Stress pct67.0Percentile at/above this = Stressed
Hysteresis8.0Margin required to fall back toward Normal
AlertstrueAlert once when the regime changes
CornerCORNER_LEFT_UPPERPanel corner
X distance10Panel horizontal offset, pixels
Y distance20Panel vertical offset, pixels
Font size10Panel font size

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Trailing Stop & Break-even · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria