Volatility Regime ZScore Indicator
- Indicatori
- Viktor Nimrichtr
- Versione: 1.0
- Attivazioni: 7
Volatility Regime ZScore Indicator
Volatility Regime ZScore is a professional volatility–regime indicator designed to classify the market into volatility regimes:
-
low risk (calm market),
-
normal conditions,
-
high risk (unstable / news / breakout environments).
This indicator answers a very specific question:
“Is the market currently calm, normal, or unusually risky?”
It does NOT predict price direction, trends, or entry points by itself.
Instead, it acts as a risk and regime filter, not signal generation.
🔹 What you see on the chart
The indicator is displayed in a separate window as a colored histogram:
-
🔵 Blue bars – Low Volatility Regime
-
Market is unusually calm relative to its own history
-
Often suitable for:
-
mean reversion
-
scalping
-
range trading
-
-
-
⚪ Silver bars – Normal Volatility Regime
-
Typical market conditions
-
Most strategies can operate normally
-
-
🔴 Red bars – High Volatility Regime
-
Market volatility is unusually high
-
Often caused by news, breakouts, panic, or strong momentum
-
Typical use:
-
reduce position size
-
widen stop-loss
-
disable mean-reversion strategies
-
-
Horizontal lines represent user-defined volatility thresholds, making regime changes visually clear.
🔹 How to use this indicator in trading (quick examples)
✔ As a strategy filter
-
Trade your normal strategy only during Blue and Silver regimes
-
Pause or limit trading during Red regimes
✔ Risk management
-
Reduce lot size when bars turn red
-
Increase caution around news events
✔ Strategy matching
-
Mean-reversion → prefer Blue / Silver
-
Breakout & momentum → often occur during Red
⚠️ Important:
This indicator does not tell you whether to buy or sell.
It tells you how risky the market environment is.
🔹 Indicator parameters (user-friendly explanation)
-
Volatility Horizons (Short / Medium / Long)
Control how fast or slow volatility is measured.
Short horizons react quickly, long horizons capture structural risk.-
ShortHorizonBars
Number of bars for short-term volatility. Reacts quickly to recent market changes. Default 15. Tip: very small values (e.g., 5–10) may cause the upside/downside components to become temporarily one-sided, which can produce sharper short-term Z-score swings. -
MediumHorizonBars
Number of bars for medium-term volatility. Balances noise and stability. Default 50. -
LongHorizonBars
Number of bars for long-term volatility. Captures structural market risk. Default 200.
-
-
Volatility Horizons Weights
These parameters define how much each horizon influences the final result.-
ShortHorizonWeight
Weight of short-term volatility horizon ShortHorizonBars in the final score. Default 0.5. -
MediumHorizonWeight
Weight of medium-term volatility horizon MediumHorizonBars. Default 0.3.
-
- LongHorizonWeight
Weight of long-term volatility horizon LongHorizonBars. Default 0.2.
Higher weight on short horizon → faster regime changes.
Higher weight on long horizon → more conservative behavior.
- Baseline and Volatility Regime Thresholds
-
BaselineWindow
Number of historical bars used to estimate normal volatility behavior. Default 200.
These parameters define what is considered “normal” volatility and when regimes change.
-
LowVolatilityZ
Z-score threshold below which the market is classified as low volatility. Default -0.5.
-
HighVolatilityZ
Z-score threshold above which the market is classified as high volatility. Default 0.5.
- Downside Risk Emphasis This parameter controls how strongly negative price movements affect the volatility score.
-
DownsideWeight
Value between 0 and 1. Higher values emphasize downside (riskier) volatility. Recommended for risk-aware trading. Default 0.
SECTION 2 – Advanced / Quantitative Description (EA & Systematic Trading)
Conceptual overviewThe indicator is based on well-established principles of financial econometrics:
-
realized variance
-
volatility clustering
-
regime normalization via robust Z-scores
It is deterministic, model-free, and does not rely on machine learning.
The indicator uses log-returns and realized variance to estimate volatility across multiple horizons.Each horizon is normalized independently using Median + MAD (Median Absolute Deviation), providing robustness against outliers, news spikes, and fat-tailed return distributions.
Multi-horizon Z-score consensus
The indicator evaluates volatility independently across three horizons, defined by parameters ShortHorizonBars, MediumHorizonBars, LongHorizonBars.
For each horizon k :
1. Log-returns and realized variance
Volatility is computed from log-returns as realized variance, separately for:
-
positive returns (upside volatility),
-
negative returns (downside volatility).
2. Log transformation
xt(k) = ln(RVt(k) + ε)This stabilizes the distribution of volatility estimates.
3. Robust normalization (BaselineWindow)
For each horizon and direction, a robust baseline is estimated using:
-
median
-
MAD (Median Absolute Deviation)
Zt(k) = (xt(k) − median) / 1.4826 ⋅ MAD
Length of the Baseline Window is defined by parameter BaselineWindow.
4. Horizon consensus (weights)
Per-horizon Z-scores are combined using Horizon wights parametrs ShortHorizonWeight, MediumHorizonWeight, LongHorizonWeight:
Zup = ∑ wk ⋅ Zup,(k)
Zdown = ∑ wk ⋅ Zdown,(k)
5. Downside-aware final score
Downside and upside volatility are merged using parameter β (DownsideWeight):
Z = β ⋅ Zdown + (1 − β) ⋅ Zup
This produces the final composite volatility score.
6. Regime classification
Using user-defined threshold parameters LowVolatilityZ, HighVolatilityZ
The final score is classified into:
-
Low volatility
-
Normal volatility
-
High volatility
This classification drives histogram colors and.
Implementation Note — Directional RV Stabilization
On short horizons, upside or downside realized variance can become extremely small when price movements are strongly one-sided. Applying a logarithmic transform to near-zero variance may lead to non-informative volatility spikes.
To prevent this effect, the indicator applies a small minimum floor to directional realized variance based on total variance scaled by the corresponding horizon length. This approach preserves volatility asymmetry while improving numerical stability and producing more robust regime classification.
EA integration and indicator buffers
The indicator exposes multiple buffers for Expert Advisors:
-
Buffer 0 — Composite Z-Score
Contains the final composite volatility score Z described in Step 5 above. -
Buffer 1 — ColorIndexBuffer
Internal buffer used to color histogram bars
(0 = low, 1 = normal, 2 = high volatility). -
Buffer 2 — RegimeBuffer
Discrete regime classification from Step 6 above:
-1 = Low volatility
0 = Normal volatility
+1 = High volatility -
Buffer 3 — Downside Volatility Z-Score
Contains the weighted downside Z-score Z d o w n Z^{down} from Step 4 above. -
Buffer 4 — Upside Volatility Z-Score
Contains the weighted upside Z-score Z u p Z^{up} from Step 4 above.
These buffers allow EA developers to:
-
enable/disable trading by regime,
-
scale position size,
-
detect tail-risk environments,
-
build volatility-aware systems.
What this indicator is (and is not)
✔ Volatility regime detector
✔ Risk and stability filter
✔ EA-friendly and deterministic
✔ Suitable for FX, indices, commodities, crypto
❌ Not a price predictor
❌ Not a trend indicator
❌ Not a standalone trading system
