Williams %R
How far the close is below the recent high, from 0 at the top of the range to −100 at the bottom.
What it measures
Section titled “What it measures”The same measure as the Stochastic Oscillator’s %K, turned upside down and shifted: it is %K − 100, with no signal line.
How traders read it
Section titled “How traders read it”Traders read above −20 as overbought and below −80 as oversold.
Formula
Section titled “Formula”%R = (highest high − close) / (highest high − lowest low) × −100, over the last periods barsA window with no range gives 0.
Settings and output
Section titled “Settings and output”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.
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.
In an algorithm
Section titled “In an algorithm”function onIntervalClose() { const value = williamsR(14); if (OPEN_POSITIONS_COUNT === 0 && value < -80 && CLOSE > sma(50)) { openPosition("BUY", { quantity: 10000, stopLossPips: 25, takeProfitPips: 40 }); }}