OPEN-SOURCE SCRIPT
Zaktualizowano Volatility Regime Oscillator

Volatility Regime Oscillator
OVERVIEW
A 0-100 oscillator confined to the one thing volatility truly does: measure and manage risk. It forecasts how large moves are likely to be, places that forecast on a self-normalising 0-100 percentile scale (calm → extreme), and reports the position-size multiplier a volatility-targeting approach would call for. You read it next to your own method and size accordingly. It places no orders, gives no entry/exit signals, and takes no view on direction. Volatility's only job here is how big, never which way — that restraint is the whole design.
WHY THESE METHODS BELONG IN ONE SCRIPT (mashup rationale)
This is not a folder of separate volatility studies — it is one pipeline, and each stage feeds the next:
Estimate. Range-based estimators (Yang-Zhang, Garman-Klass, Rogers-Satchell, Parkinson) measure realised volatility far more efficiently than close-to-close; combining them is more robust out-of-sample than trusting any single one.
Forecast. A HAR multi-horizon blend (with an optional measurement-error correction that shifts weight off the noisy fast term), EWMA, or window mean turns that estimate forward.
Character. Good/bad semivariance and vol-of-vol report whether the move is downside-driven and whether the volatility itself is stable — context a single number can't carry.
Regime. A percentile rank converts the forecast into a self-normalising 0-100 read, so the same calm/normal/high/extreme bands work on any symbol or timeframe.
Size. Volatility targeting turns the forecast into an exposure multiplier — blended toward constant exposure and gated down in extremes, the robust drawdown-reducing form.
A forecaster without a regime frame is just a number; a regime read without sizing is just a gauge; sizing without the de-risk gates is the naive targeting the research shows underwhelms. Chained, they answer one question end to end: how big is risk now, and what does that imply for size? Remove a stage and the chain breaks.
HOW IT IS DIFFERENT FROM A PLAIN VOLATILITY FORECASTER
Most volatility tools answer "what will volatility be?" This one answers "where does volatility sit, and how much should I size?" The forecast is only the input; the output is a regime percentile plus a position-sizing multiplier — vol targeting, conditional targeting, a managed/constant blend, downside scaling, and an optional stress gate — wrapped in a risk-management frame. It is a sizing and regime gauge, not a forecasting study.
HOW TO USE
Oscillator 0-100 = where current forecast vol sits in its own history (percentile). Bands: <25 calm, 25-65 normal, 65-90 high, ≥90 extreme.
Dotted marker = where your target vol sits in that distribution. Line above the marker = vol above target → size down; below = room to size up.
Suggested exposure (dashboard) = the vol-target multiplier of equity a long would use now (1.0× = 100%). Apply it to your own side.
Optional expected-move envelope on the price chart shows the size of the likely move (for stop placement) — symmetric, regime-coloured, never a direction or target.
UNIVERSAL ACROSS MARKETS
The estimators read OHLC, so it runs on any instrument and timeframe out of the box. An optional Analyse symbol input reroutes the calculation to a different instrument than the one charted. Annualisation is derived from the chart timeframe by default (so the forecast-vol % and the target marker read sensibly on any timeframe), with a manual bars-per-year override available. The India VIX stress gate is OFF by default because it reads an India-specific implied-vol symbol that would mislead on other markets — turn it on only for NIFTY / BANKNIFTY.
ACCURACY — AN HONEST NOTE
This contains the most advanced volatility methods genuinely computable from price bars. It does not and cannot contain the options-data frontier — rough-volatility calibration (rough Heston / fractional Brownian), deep-learning forecasters, or implied-vol-surface models — none of which run on chart OHLC. Even at its best, realised-vol forecasting explains only a minority of realised-vol variance. Treat this as a sharper estimate and a disciplined risk gauge, not a precise or certain forecast. The "suggested exposure" is context for your own risk process, not an instruction; the research is explicit that full vol-targeting often fails to beat constant exposure out of sample — the keepable part is tail/drawdown reduction, which is why sizing is blended toward constant exposure by default.
ORIGINALITY
The individual methods are public and credited below. The original work is the assembly: a single self-normalising oscillator that chains efficient range estimators → a measurement-error-corrected HAR forecast → a semivariance/vol-of-vol character read → a percentile regime → a blended, gated volatility-targeting exposure, with a regime-coloured expected-move envelope — a risk-and-sizing gauge rather than a forecast or a directional signal. No third-party Pine code is reused.
CONCEPT CREDIT
Volatility estimators — M. Parkinson (1980); Garman & Klass (1980); Rogers & Satchell (1991); Yang & Zhang (2000). HAR forecaster — Fulvio Corsi (2009); measurement-error (HARQ) correction — Bollerslev, Patton & Quaedvlieg (2016). EWMA / RiskMetrics — J.P. Morgan (1996). Good/bad realised semivariance — Barndorff-Nielsen, Kinnebrock & Shephard; Patton & Sheppard (2015). Path-dependent leverage effect — Julien Guyon & Jordan Lekeufack (2023). Volatility targeting / conditional targeting — Moreira & Muir (2017); Harvey et al. (2018); robustness caveats — Cederburg et al. (2020); Wang & Yan (2021). Assembly, oscillator framing, regime bands and the target marker are the author's own work. Not affiliated with, nor endorsed by, any third party.
DISCLAIMER
Educational risk-management gauge. NOT financial advice, NOT a signal, and NO guarantee of any outcome. Estimates from price can be wrong, especially through structural breaks and on low-history symbols. Trading carries risk of loss. Do your own research and manage your own risk. The author accepts no liability for any use of this script.
OVERVIEW
A 0-100 oscillator confined to the one thing volatility truly does: measure and manage risk. It forecasts how large moves are likely to be, places that forecast on a self-normalising 0-100 percentile scale (calm → extreme), and reports the position-size multiplier a volatility-targeting approach would call for. You read it next to your own method and size accordingly. It places no orders, gives no entry/exit signals, and takes no view on direction. Volatility's only job here is how big, never which way — that restraint is the whole design.
WHY THESE METHODS BELONG IN ONE SCRIPT (mashup rationale)
This is not a folder of separate volatility studies — it is one pipeline, and each stage feeds the next:
Estimate. Range-based estimators (Yang-Zhang, Garman-Klass, Rogers-Satchell, Parkinson) measure realised volatility far more efficiently than close-to-close; combining them is more robust out-of-sample than trusting any single one.
Forecast. A HAR multi-horizon blend (with an optional measurement-error correction that shifts weight off the noisy fast term), EWMA, or window mean turns that estimate forward.
Character. Good/bad semivariance and vol-of-vol report whether the move is downside-driven and whether the volatility itself is stable — context a single number can't carry.
Regime. A percentile rank converts the forecast into a self-normalising 0-100 read, so the same calm/normal/high/extreme bands work on any symbol or timeframe.
Size. Volatility targeting turns the forecast into an exposure multiplier — blended toward constant exposure and gated down in extremes, the robust drawdown-reducing form.
A forecaster without a regime frame is just a number; a regime read without sizing is just a gauge; sizing without the de-risk gates is the naive targeting the research shows underwhelms. Chained, they answer one question end to end: how big is risk now, and what does that imply for size? Remove a stage and the chain breaks.
HOW IT IS DIFFERENT FROM A PLAIN VOLATILITY FORECASTER
Most volatility tools answer "what will volatility be?" This one answers "where does volatility sit, and how much should I size?" The forecast is only the input; the output is a regime percentile plus a position-sizing multiplier — vol targeting, conditional targeting, a managed/constant blend, downside scaling, and an optional stress gate — wrapped in a risk-management frame. It is a sizing and regime gauge, not a forecasting study.
HOW TO USE
Oscillator 0-100 = where current forecast vol sits in its own history (percentile). Bands: <25 calm, 25-65 normal, 65-90 high, ≥90 extreme.
Dotted marker = where your target vol sits in that distribution. Line above the marker = vol above target → size down; below = room to size up.
Suggested exposure (dashboard) = the vol-target multiplier of equity a long would use now (1.0× = 100%). Apply it to your own side.
Optional expected-move envelope on the price chart shows the size of the likely move (for stop placement) — symmetric, regime-coloured, never a direction or target.
UNIVERSAL ACROSS MARKETS
The estimators read OHLC, so it runs on any instrument and timeframe out of the box. An optional Analyse symbol input reroutes the calculation to a different instrument than the one charted. Annualisation is derived from the chart timeframe by default (so the forecast-vol % and the target marker read sensibly on any timeframe), with a manual bars-per-year override available. The India VIX stress gate is OFF by default because it reads an India-specific implied-vol symbol that would mislead on other markets — turn it on only for NIFTY / BANKNIFTY.
ACCURACY — AN HONEST NOTE
This contains the most advanced volatility methods genuinely computable from price bars. It does not and cannot contain the options-data frontier — rough-volatility calibration (rough Heston / fractional Brownian), deep-learning forecasters, or implied-vol-surface models — none of which run on chart OHLC. Even at its best, realised-vol forecasting explains only a minority of realised-vol variance. Treat this as a sharper estimate and a disciplined risk gauge, not a precise or certain forecast. The "suggested exposure" is context for your own risk process, not an instruction; the research is explicit that full vol-targeting often fails to beat constant exposure out of sample — the keepable part is tail/drawdown reduction, which is why sizing is blended toward constant exposure by default.
ORIGINALITY
The individual methods are public and credited below. The original work is the assembly: a single self-normalising oscillator that chains efficient range estimators → a measurement-error-corrected HAR forecast → a semivariance/vol-of-vol character read → a percentile regime → a blended, gated volatility-targeting exposure, with a regime-coloured expected-move envelope — a risk-and-sizing gauge rather than a forecast or a directional signal. No third-party Pine code is reused.
CONCEPT CREDIT
Volatility estimators — M. Parkinson (1980); Garman & Klass (1980); Rogers & Satchell (1991); Yang & Zhang (2000). HAR forecaster — Fulvio Corsi (2009); measurement-error (HARQ) correction — Bollerslev, Patton & Quaedvlieg (2016). EWMA / RiskMetrics — J.P. Morgan (1996). Good/bad realised semivariance — Barndorff-Nielsen, Kinnebrock & Shephard; Patton & Sheppard (2015). Path-dependent leverage effect — Julien Guyon & Jordan Lekeufack (2023). Volatility targeting / conditional targeting — Moreira & Muir (2017); Harvey et al. (2018); robustness caveats — Cederburg et al. (2020); Wang & Yan (2021). Assembly, oscillator framing, regime bands and the target marker are the author's own work. Not affiliated with, nor endorsed by, any third party.
DISCLAIMER
Educational risk-management gauge. NOT financial advice, NOT a signal, and NO guarantee of any outcome. Estimates from price can be wrong, especially through structural breaks and on low-history symbols. Trading carries risk of loss. Do your own research and manage your own risk. The author accepts no liability for any use of this script.
Informacje o Wersji
Volatility Regime OscillatorWhat it is. A volatility-regime gauge: where current realised volatility sits in its own recent range, with a forward-looking forecast and a suggested exposure read. It is a risk context tool, not a trade signal — and by design it carries no entry calibration.
What's new in this update
Proper forecast scoring. The one-step volatility forecast is now scored with the standard volatility loss function (lower is better) and shown as skill versus a naive benchmark, so the reader can see whether the forecast is actually adding value over a random-walk guess.
Implied-volatility blend (optional). Where an implied-volatility series is available, it can be blended into the forecast with a configurable weight — consistent with the evidence that an implied/uncertainty input can sharpen out-of-sample volatility forecasts, while the heterogeneous-autoregressive core remains the robust baseline.
How the parts work together. The realised-volatility estimators, the forecast, and the new scoring/blend form one honest loop: the forecast proposes, the scoring keeps it accountable, and the implied blend adds forward-looking information without overriding the robust core.
Reusable outputs. Volatility percentile, annualised volatility, exposure read, the forecast score, the skill-vs-naive read and the blended forecast are published to the Data Window for cross-script use.
Defaults & sources. The implied-volatility symbol is India-specific and is off by default so the script is correct on any market; turn it on only for NIFTY/BANKNIFTY. Estimator choice and windows are NIFTY-tuned.
Educational risk-context tool — not a signal and not financial advice.
Informacje o Wersji
v3.0 — Rough-volatility core: fractional-kernel forecaster, GARCH(1,1), measured vol-roughness, and a model horse-raceROUGH-VOLATILITY forecaster (Gatheral-Jaisson-Rosenbaum): a power-law / fractional kernel weights past variance by (lag)^(H−0.5), where H is the measured roughness of realised log-vol. Rougher vol (low H) puts more weight on the most recent bars; H = 0.5 reproduces a flat window mean. Built on the range-based realised measure, so it inherits the efficiency of the Yang-Zhang / Garman-Klass estimators.
VOL ROUGHNESS (H) is now measured live from the scaling of realised log-vol increments across lags 1/2/4/8 (E[(Δlogσ)²] ∝ Δ^2H) and shown on the panel — equity vol is typically "very rough" (H ≈ 0.1). Exported as EXP_VolH.
GARCH(1,1) forecaster with variance targeting (Bollerslev; Engle-Mezrich): σ²ₜ = ω + α·r²ₜ₋₁ + β·σ²ₜ₋₁, with ω pinned to the long-run variance so it mean-reverts. α, β and the long-run window are inputs.
MODEL HORSE-RACE: every forecaster (HAR / Rough / GARCH / EWMA / SMA) is scored by out-of-sample QLIKE on THIS instrument; the panel shows the current best model, and a new "Auto (best QLIKE)" forecaster option always tracks whichever is winning.
The estimator combination now averages all five forecasters for extra out-of-sample robustness (more model diversity). HARQ measurement-error correction, semivariance character, path-dependent tilt, vol-targeting exposure, expected-move bands, theme and non-repaint behaviour are all unchanged.
New exports: EXP_VolH, EXP_GarchVolPct, EXP_BestModel.
Note: still a realised-vol tool — it does NOT calibrate the options-implied rough-Heston surface (that needs options data). Risk gauge, not a signal, not investment advice.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.