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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.