Skip to content

How far the close is below the recent high, from 0 at the top of the range to −100 at the bottom.

The same measure as the Stochastic Oscillator’s %K, turned upside down and shifted: it is %K − 100, with no signal line.

Traders read above −20 as overbought and below −80 as oversold.

%R = (highest high − close) / (highest high − lowest low) × −100, over the last periods bars

A window with no range gives 0.

Call: williamsR(periods)

Setting Chart default
periods: Periods 14

What you get: a number.

Warm-up: with williamsR(14), it asks for 15 bars of history and a run-up of 1, and its first value came on bar 16 of the example data.

Williams %R drawn by its own code on example prices

The prices are made up, hourly, and the same on every page, so the chart shows how the indicator behaves, not how a market behaved.

function onIntervalClose() {
const value = williamsR(14);
if (OPEN_POSITIONS_COUNT === 0 && value < -80 && CLOSE > sma(50)) {
openPosition("BUY", { quantity: 10000, stopLossPips: 25, takeProfitPips: 40 });
}
}