OPEN-SOURCE SCRIPT
Compression / Release - Yang-Zhang percentile

A volatility-state indicator that shows whether a market is coiled or expanding. It needs no options data and works on any symbol — stocks, futures, FX, crypto.
To be clear about what it is: this measures realized volatility, not implied. It computes Yang-Zhang volatility (which uses the full OHLC bar, so it captures intrabar range and handles overnight gaps and drift — more efficient than a close-only measure) and ranks it against the instrument's own recent history. It describes the present and the past only; it carries no forward-looking or market-expectation information. Some scripts present the same math as a "synthetic IV rank," which is a misleading label — there is no implied volatility here.
What you see:
The yellow line is Compression, a 0–100 percentile. Low means current volatility is narrow relative to its own history (compressed, coiled); high means it is wide (already expanded). It uses ta.percentrank, the IV-percentile flavor that counts every day in the lookback, which is more robust to single-day spikes than range-based IV rank.
The columns are Release, drawn from a zero baseline: the change in the compression percentile over the release window. Green columns up mean volatility is expanding now; red columns down mean it is contracting now. Each bar is single-sided. This measures expansion as it happens — it does not predict it.
The green dot marks a Release start: the bar the compression line climbs back above the compression level, i.e. volatility leaving the squeeze zone.
How to read it together: the line tells you where you are (high or low in the volatility distribution), the columns tell you which way it is moving. The cleanest "loaded" state is the line near 20 with columns flat or turning green; the "already expanded" state is the line pinned near 100.
Inputs: Yang-Zhang window (default 20, ~1 month). Compression percentile lookback (default 252 ≈ 1 year — the standard IV rank/percentile convention; shorter reacts faster to regime shifts but loses the annual frame). Release window (default 10). Compression/expansion levels (20 / 80). Best read on a daily chart.
Limitations, stated plainly: direction is never implied — a release can resolve up or down, so a green column is not a buy signal. It is a measurement of state, not a timing signal; the line can stay near an extreme for a long time during sustained regimes and is not a reversal trigger. Pair it with your own trend tools for direction.
To be clear about what it is: this measures realized volatility, not implied. It computes Yang-Zhang volatility (which uses the full OHLC bar, so it captures intrabar range and handles overnight gaps and drift — more efficient than a close-only measure) and ranks it against the instrument's own recent history. It describes the present and the past only; it carries no forward-looking or market-expectation information. Some scripts present the same math as a "synthetic IV rank," which is a misleading label — there is no implied volatility here.
What you see:
The yellow line is Compression, a 0–100 percentile. Low means current volatility is narrow relative to its own history (compressed, coiled); high means it is wide (already expanded). It uses ta.percentrank, the IV-percentile flavor that counts every day in the lookback, which is more robust to single-day spikes than range-based IV rank.
The columns are Release, drawn from a zero baseline: the change in the compression percentile over the release window. Green columns up mean volatility is expanding now; red columns down mean it is contracting now. Each bar is single-sided. This measures expansion as it happens — it does not predict it.
The green dot marks a Release start: the bar the compression line climbs back above the compression level, i.e. volatility leaving the squeeze zone.
How to read it together: the line tells you where you are (high or low in the volatility distribution), the columns tell you which way it is moving. The cleanest "loaded" state is the line near 20 with columns flat or turning green; the "already expanded" state is the line pinned near 100.
Inputs: Yang-Zhang window (default 20, ~1 month). Compression percentile lookback (default 252 ≈ 1 year — the standard IV rank/percentile convention; shorter reacts faster to regime shifts but loses the annual frame). Release window (default 10). Compression/expansion levels (20 / 80). Best read on a daily chart.
Limitations, stated plainly: direction is never implied — a release can resolve up or down, so a green column is not a buy signal. It is a measurement of state, not a timing signal; the line can stay near an extreme for a long time during sustained regimes and is not a reversal trigger. Pair it with your own trend tools for direction.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.