How Williams %R (Williams R) is calculated

Williams R calculation formula inputs lookback limitations verification.

Direct answer: the Williams %R formula

Williams %R (often written as “Williams R” or “%R”) is an oscillator that compares the current close to the recent trading range. The standard calculation uses a lookback window of length N bars.

Formula (standard form): [ \text{Williams %R} = -100 \times \frac{H_{N} - C}{H_{N} - L_{N}} ]

Where:

  • (C) = the most recent closing price (for the bar you are calculating on)
  • (H_{N}) = the highest high over the last N bars (including the current bar)
  • (L_{N}) = the lowest low over the last N bars (including the current bar)

Output range (when computable): with valid (H_{N} \neq L_{N}), the result is typically bounded between −100 and 0.

Mechanism and definition: what the inputs mean

To calculate Williams %R step by step, treat it as a normalized position inside a rolling range.

  1. Pick the lookback window (N).

    • Example assumption for an illustration: (N = 14) bars.
    • The choice of N changes how quickly the indicator responds to new highs or new lows.
  2. Find the rolling extremes over those N bars.

    • (H_{N}) is the maximum of “high” prices across the window.
    • (L_{N}) is the minimum of “low” prices across the window.
  3. Compare the current close to the range.

    • The numerator (H_{N} - C) measures how far the current close is below the window’s highest high.
    • The denominator (H_{N} - L_{N}) measures the window’s total range size.
  4. Scale to an oscillator with a negative sign.

    • Multiplying by −100 expresses the normalized position on a −100 to 0 scale.

A simple worked example (with explicit assumptions)

Assume you are calculating the indicator at a given bar with:

  • lookback window (N = 5)
  • (C = 1.2000)
  • the highest high over the last 5 bars is (H_{N} = 1.2100)
  • the lowest low over the last 5 bars is (L_{N} = 1.1950)

Compute:

  • (H_{N} - C = 1.2100 - 1.2000 = 0.0100)
  • (H_{N} - L_{N} = 1.2100 - 1.1950 = 0.0150)

Then:

  • (\frac{H_{N}-C}{H_{N}-L_{N}} = \frac{0.0100}{0.0150} = 0.6667)
  • (\text{Williams %R} = -100 \times 0.6667 \approx -66.67)

Interpretation at a purely mathematical level:

  • If (C) is closer to (H_{N}), the fraction is smaller and the value moves toward 0.
  • If (C) is closer to (L_{N}), the fraction is larger and the value moves toward −100.

Limitations and risks: where calculations can fail or mislead

Williams %R is straightforward mathematically, but practical use depends on details that affect the computed values.

1) Division-by-zero when the range collapses

If over the last N bars you have:

  • (H_{N} = L_{N})

Then the denominator (H_{N} - L_{N}) equals 0, and the formula is undefined. This can happen when prices do not vary within the window (for example, during illiquid periods or after data issues). In such cases, a platform may display “not available,” a blank value, or an alternative handling.

2) Lookback choice changes responsiveness

Because (H_{N}) and (L_{N}) come from a rolling window, different values of N alter:

  • how often new extremes enter/leave the window
  • how fast the indicator moves after price changes

This is a parameter sensitivity, not a guarantee of predictive accuracy.

3) Data definitions: high, low, and close sourcing

Williams %R depends directly on the bar’s high, low, and close values. In practice, providers can differ in how they construct bars:

  • whether values are based on bid/ask midpoints, last trades, or other feeds
  • how sessions roll over
  • how “close” is chosen for timeframes with gaps

Even if the same formula is used, different input data can produce different plotted results.

4) Historical relationships don’t imply future outcomes

Even when a computed oscillator value lines up with known past behavior, that does not establish that similar future conditions will produce the same outcome. Market conditions can change, and an indicator remains a transformation of price data rather than a direct measure of future direction.

5) Interpreting %R without considering the computed range

A common failure mode is focusing on the oscillator value without checking whether it is based on a meaningful range.

  • Early bars may not have enough history to compute (H_{N}) and (L_{N}).
  • If volatility is unusually low over the window, small price differences can produce large percentage-like changes.

Verification and next question: how to check it yourself

You can independently verify Williams %R using only the formula and the required inputs.

  1. Choose a timeframe and a bar on your chart.
  2. Fix the lookback window (N) you want to test.
  3. Manually determine (H_{N}) (highest high) and (L_{N}) (lowest low) over that window.
  4. Read or record the close (C) for the same bar.
  5. Substitute into: (\text{Williams %R} = -100 \times \frac{H_{N} - C}{H_{N} - L_{N}})
  6. Confirm whether your computed value matches what your charting tool shows (within rounding).

If it does not match, the mismatch is usually due to different handling of:

  • window inclusion (whether extremes include the current bar)
  • bar construction (how high/low/close are defined)
  • missing data or how undefined cases are treated

If you want, you can compare different settings (for example, changing (N)) to see how sensitivity changes, or review how the measure relates to other momentum oscillators.

Trading foreign exchange and CFDs involves substantial risk. Information on FoxiForex is educational and is not personal financial advice. Sponsored placements are labelled clearly.