# Yang-Zhang Estimator

A Volatility concept (Volatility estimators) in the LuxAlgo Library, with 1 indicator implementation.

## What is the Yang-Zhang Estimator?

The Yang-Zhang estimator is a realized-volatility estimator for OHLC bars, published by Dennis Yang and Qiang Zhang in 2000. It decomposes variance into three parts: an overnight component from close-to-open log returns, an open-to-close component, and the Rogers-Satchell range term built from each bar's high, low, open, and close. Summing them with a variance-minimizing weight fixes the two classic blind spots of range-based estimation at once: unlike the Parkinson and Garman-Klass estimators it accounts for opening gaps, and the Rogers-Satchell term keeps it unbiased when price drifts (trends) across the window.

It sits at the end of a lineage of estimators developed to squeeze more information out of each bar. Parkinson's 1980 estimator used the high-low range; Garman and Klass added the open and close the same year; Rogers and Satchell (1991) removed the zero-drift assumption; and Yang and Zhang's 2000 paper in the Journal of Business combined the pieces into an estimator that is unbiased under both drift and opening jumps, with the minimum variance among estimators of its form. It holds up in exactly the conditions that mislead simpler estimators: opening gaps and strong trends within the window.

Those properties make it a common default when a single [realized volatility](https://www.luxalgo.com/library/concept/realized-volatility/) number must come from daily bars. Because it uses the full bar rather than closes alone, it reaches a given level of statistical stability from fewer bars than close-to-close historical volatility, which matters when the lookback has to stay short. It remains a sample statistic: it describes the window it was computed over, inherits any bad opening or high/low prints in the data, and is not a forecast.

For chart-based traders the estimator fills a gap between indicator conventions. Tools like [Bollinger Bands](https://www.luxalgo.com/library/concept/bollinger-bands/) measure volatility as the standard deviation of closes and [ATR](https://www.luxalgo.com/library/concept/atr/) measures it as smoothed true range in price units; Yang-Zhang instead produces an annualized percentage comparable across instruments and directly against option-implied volatility. That makes it a natural engine for volatility targeting, regime dashboards, and any workflow where the question of how volatile a market currently is needs a number that survives gaps and trends.

## How to calculate the Yang-Zhang Estimator

The estimate combines three variance components over an n-bar window; all returns are log returns.

1. Build two return series per bar: the overnight return, log of the open divided by the prior close, and the open-to-close return, log of the close divided by the same bar's open.
2. Take the ordinary sample variance of each series across the window (deviations from each series' own mean), giving the overnight variance and the open-to-close variance.
3. Compute the Rogers-Satchell variance over the same window from each bar's high, low, open, and close; this is the drift-independent range component.
4. Combine as overnight variance plus k times open-to-close variance plus (1 minus k) times Rogers-Satchell variance, where k = 0.34 / (1.34 + (n+1)/(n-1)) as derived in the original paper. Annualize by scaling the per-bar variance by bars per year, then take the square root.

## How it's calculated

The Yang-Zhang estimator combines overnight, open-to-close, and Rogers-Satchell variances into a single volatility estimate that is independent of drift and captures opening gaps.

```
o_t = ln(O_t / C_(t-1))
c_t = ln(C_t / O_t)
u_t = ln(H_t / O_t)
d_t = ln(L_t / O_t)
Var_o = (1 / (n - 1)) × Σ over t = 1..n of (o_t - o_bar)^2
Var_c = (1 / (n - 1)) × Σ over t = 1..n of (c_t - c_bar)^2
Var_RS = (1 / n) × Σ over t = 1..n of ( u_t × (u_t - c_t) + d_t × (d_t - c_t) )
k = 0.34 / (1.34 + (n + 1) / (n - 1))
YZ = sqrt( Var_o + k × Var_c + (1 - k) × Var_RS )
YZ_ann = YZ × sqrt(A)

  t: bar index inside the n-bar window
  O_t, H_t, L_t, C_t: open, high, low, close of bar t (C_(t-1) is the prior close)
  ln(): natural logarithm
  o_t: overnight log return, prior close to open
  c_t: open-to-close log return
  u_t, d_t: high and low log returns measured from the open
  n: lookback window in bars (commonly 20 or 30)
  o_bar, c_bar: means of o_t and c_t over the window
  Var_o, Var_c: sample variances of the overnight and open-to-close returns
  Var_RS: Rogers-Satchell variance component
  k: weighting constant that minimizes the estimator's variance
  YZ: Yang-Zhang volatility per bar, as a decimal
  YZ_ann: annualized Yang-Zhang volatility
  A: periods per year for annualization (252 for daily bars)
```

From Yang and Zhang (2000); it stays unbiased when the series trends (drift) and prices in the overnight gap, whereas Parkinson and Garman-Klass assume zero drift and Rogers-Satchell ignores the gap.

Sums run over the n most recent bars; match A to the bar frequency (252 daily, 52 weekly, 12 monthly).

Some sources quote the variance (the expression under the square root) rather than the volatility; multiply by 100 to quote percent.

## How traders use it

- As the volatility input for anything scaled by realized vol: position sizing, stop distances, and band widths built on close-to-close volatility can swap in Yang-Zhang for a steadier estimate from the same data, with the biggest gains on instruments that gap overnight.
- As the engine for short-window regime work: because each bar contributes more information, shorter lookbacks become statistically usable, which sharpens multi-window comparisons and [volatility percentile ranks](https://www.luxalgo.com/library/concept/volatility-percentile-rank/).
- As a realized benchmark against implied volatility: comparing an efficient realized estimate to option-implied levels is a standard way to frame whether volatility is being priced rich or cheap, though neither side is obliged to converge on any schedule.
- As a cross-check on squeeze studies: compression flagged by [BandWidth](https://www.luxalgo.com/library/concept/bandwidth/) or the [TTM Squeeze](https://www.luxalgo.com/library/concept/ttm-squeeze/) can be verified against a Yang-Zhang series to confirm that measured volatility, gaps included, is genuinely contracting, a cleaner read on [range expansion and contraction](https://www.luxalgo.com/library/concept/range-expansion-contraction/) cycles.
- For cross-market comparison and volatility targeting: because the output is an annualized percentage, portfolios can size positions inversely to it and compare regimes across assets, something ATR's price units cannot do directly.

## Yang-Zhang vs. other volatility measures

- **Realized Volatility** (https://www.luxalgo.com/library/concept/realized-volatility/): Yang-Zhang is one estimator within the realized-volatility family. The reference implementation uses close-to-close returns only; Yang-Zhang adds the open, high, and low so each bar contributes more information, cutting sampling noise at the cost of needing clean OHLC data.
- **ATR** (https://www.luxalgo.com/library/concept/atr/): ATR is a smoothed average of true range in price units, built for stops and position sizing on charts. Yang-Zhang is a statistical variance estimator, annualized and comparable across instruments and to implied volatility. They respond to the same turbulence but answer different questions.
- **BandWidth** (https://www.luxalgo.com/library/concept/bandwidth/): BandWidth reads how wide Bollinger Bands are relative to their middle line, a chart-native squeeze detector driven by the standard deviation of closes. Yang-Zhang measures the same phenomenon from richer inputs and in absolute annualized terms rather than relative to a moving average.

## FAQ

### How is the Yang-Zhang estimator different from Garman-Klass?

Garman-Klass also uses open, high, low, and close, but it assumes no opening jump and zero drift, so overnight gaps and strong trends bias it. Yang-Zhang adds an explicit overnight variance term and swaps the drift-sensitive part for the Rogers-Satchell term, making it robust to both. On a 24-hour market with no gaps, the two behave far more alike.

### Is the Yang-Zhang estimator always better than close-to-close volatility?

It is more statistically efficient under its assumptions, meaning less sampling noise per bar, but not automatically better. It depends on clean open, high, and low prints, so thin opening auctions or bad extremes distort it. Close-to-close volatility needs only closing prices, which is why it remains the standard reference despite being noisier.

### What does the k constant in the Yang-Zhang formula do?

k is the weight that splits variance between the open-to-close term and the Rogers-Satchell term, chosen in the original paper to minimize the estimator's overall variance. It depends only on the window length n via k = 0.34 / (1.34 + (n+1)/(n-1)), so it is not a tunable parameter; for common windows it evaluates to roughly 0.13 to 0.14.

### Can you use the Yang-Zhang estimator on 24/7 markets like crypto?

Yes, but the overnight term loses its purpose. On continuous markets each daily bar's open is essentially the prior close, so the close-to-open variance is near zero and the estimate is driven by the open-to-close and Rogers-Satchell components. The estimator remains valid; it simply converges toward its gap-free relatives, and the session-boundary choice (UTC midnight versus an exchange convention) still affects the numbers.

### What lookback window is typical for Yang-Zhang volatility?

Common practice uses daily windows in the tens of bars, and the estimator's efficiency is precisely what makes the shorter end usable. Shorter windows track regime shifts faster but jump around more; longer windows are steadier but slower to react. Many workflows compute two or three windows and compare them rather than defending a single number.

### Is Yang-Zhang volatility annualized, and how?

The formula produces a per-bar variance. Multiplying by the number of bars per year (252 is the equity convention; 365 is common for crypto) and taking the square root yields the annualized percentage usually displayed. Annualization assumes independent bars, so the figure is a convention for comparability rather than a literal one-year projection.

### Does the Yang-Zhang estimator forecast volatility?

No. It is a backward-looking sample statistic describing the window it was computed over. It often serves as the input to forecasts, since volatility is persistent and recent realized levels carry information, but the estimator itself makes no forward claim, and comparing it to implied volatility is a framing exercise rather than an arbitrage signal.

## Implementations in the Library

- Yang-Zhang Estimator (LuxAlgo): https://www.luxalgo.com/library/indicator/yang-zhang-estimator/

## Related concepts

- Volatility Estimators: https://www.luxalgo.com/library/concept/volatility-estimators/
- Close-to-close Historical Volatility: https://www.luxalgo.com/library/concept/close-to-close-historical-volatility/
- EWMA Volatility: https://www.luxalgo.com/library/concept/ewma-volatility/
- Parkinson Estimator: https://www.luxalgo.com/library/concept/parkinson-estimator/
- Garman-Klass Estimator: https://www.luxalgo.com/library/concept/garman-klass-estimator/
- Rogers-Satchell Estimator: https://www.luxalgo.com/library/concept/rogers-satchell-estimator/
- Garman-Klass–Yang-Zhang Hybrid: https://www.luxalgo.com/library/concept/garman-klass-yang-zhang-hybrid/
- Jump Detection: https://www.luxalgo.com/library/concept/jump-detection/
- Volatility Signature Plot: https://www.luxalgo.com/library/concept/volatility-signature-plot/
- Volatility of Volatility: https://www.luxalgo.com/library/concept/volatility-of-volatility/

---

Source: https://www.luxalgo.com/library/concept/yang-zhang-estimator/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/