# Yang-Zhang Estimator

Yang-Zhang Estimator is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

Plots annualized Yang-Zhang volatility from a 20-bar OHLC window, combining the overnight-gap, open-to-close and Rogers-Satchell variance components under the variance-minimizing weight from the original 2000 paper. A 252 bars-per-year default annualizes the read; a dashed 20% threshold and an optional 60-bar comparison window drive four alerts, with components plottable separately.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Jun 5, 2026.
- Access: free.
- Concepts: [Yang-Zhang Estimator](https://www.luxalgo.com/library/concept/yang-zhang-estimator/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=xhx5eyk0wtpktj8z3be0q4gz
- Page: https://www.luxalgo.com/library/indicator/yang-zhang-estimator/

**Yang-Zhang Estimator** is the definitive clean build of the [Yang-Zhang estimator](https://www.luxalgo.com/library/concept/yang-zhang-estimator/), the OHLC realized-volatility measure that handles opening gaps and drift at once. Overnight and open-to-close log returns feed two sample variances over the window, a Rogers-Satchell range term supplies the third component, and the three combine under the paper's weight k = 0.34 / (1.34 + (n + 1) / (n - 1)) and annualize into a percentage. The line draws with a gradient fill, a dashed threshold marks your reference level, and a slower comparison estimate can overlay for regime work.

## How to Trade the Yang-Zhang Estimator?

- **Threshold crosses**: the estimate crossing above the Threshold Level marks entry into your defined high-volatility regime; crossing back below marks normalization.
- **Expansion / contraction**: the primary estimate crossing above the slower comparison estimate signals volatility expanding; crossing below, contracting.
- **Component read**: the optional component plots show where the volatility lives. On 24/7 markets the overnight term sits near zero.

It is a sizing and regime instrument, not a directional signal.

## Yang-Zhang Estimator Settings

- **Window Length** (default 20): bars n in the estimation window; shorter tracks regime shifts faster but jumps more.
- **Bars per Year** (default 252): annualization factor, matched to the symbol's clock.
- **Show Comparison Window** (default off) and **Comparison Length** (default 60): the second, slower estimate behind the expansion/contraction alerts.
- **Show Threshold** (default on) and **Threshold Level (%)** (default 20): the dashed reference line and its level.
- **Show Components** (default off): plots the annualized overnight, open-to-close and Rogers-Satchell components separately.

## Frequently Asked Questions

### Why prefer this over the Garman-Klass estimator?

The [Garman-Klass estimator](https://www.luxalgo.com/library/indicator/garman-klass-estimator/) ignores overnight gaps and loses accuracy when price drifts across the window. Yang-Zhang prices the gap in through its overnight component and inherits drift-independence from its Rogers-Satchell term, so it stays honest on gap-prone markets and trending windows alike.

### How do I set Bars per Year correctly?

Match the symbol's clock: 252 for daily bars where a trading calendar applies, 365 for daily bars on markets that never close. Intraday, use bars per day times days per year (24 x 365 = 8760 for hourly bars on a 24/7 market).

### Is 20% the right threshold?

It is a reference to start from, not a magic number. Annualized volatility regimes differ enormously across asset classes. Check where your symbol's estimate has historically ranged and place the level where elevated genuinely begins.

## Related indicators

- [Hot Zone Radar](https://www.luxalgo.com/library/indicator/hot-zone-radar/) (Volatility Percentile/rank): markdown at https://www.luxalgo.com/library/indicator/hot-zone-radar.md
- [Volatility Signature Plot](https://www.luxalgo.com/library/indicator/volatility-signature-plot/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/volatility-signature-plot.md
- [The Range Indicator](https://www.luxalgo.com/library/indicator/the-range-indicator/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/the-range-indicator.md
- [Jump Detection](https://www.luxalgo.com/library/indicator/jump-detection/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/jump-detection.md
- [Volatility of Volatility](https://www.luxalgo.com/library/indicator/volatility-of-volatility/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/volatility-of-volatility.md
- [Garman-Klass–Yang-Zhang Hybrid](https://www.luxalgo.com/library/indicator/garman-klass-yang-zhang-hybrid/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/garman-klass-yang-zhang-hybrid.md
- [GARCH-family Clustering](https://www.luxalgo.com/library/indicator/garch-family-clustering/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/garch-family-clustering.md
- [Kase Studies](https://www.luxalgo.com/library/indicator/kase-studies/) (Volatility): markdown at https://www.luxalgo.com/library/indicator/kase-studies.md

---

Source: https://www.luxalgo.com/library/indicator/yang-zhang-estimator/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
