Where is price within its recent range? Stochastic, Williams %R and Stochastic RSI
Short answerThe stochastic oscillator, Williams %R and Stochastic RSI all answer one question: where does the latest value sit inside its own range over a lookback, usually 14 bars? The stochastic puts the close on a 0 to 100 scale, from the lowest low to the highest high. Williams %R measures the same distance down from the top, on a −100 to 0 scale, and equals the stochastic's raw line minus 100. Stochastic RSI applies the formula to RSI values instead of prices, so small RSI moves swing it between extremes. A reading near the top only says the close is near the top of the recent range, not that a reversal is due: in this lesson's synthetic uptrend, %K stayed above 80 on 40 of 41 days while price rose 25.1%.
All three are sold as "overbought and oversold" tools. Read them as a position in the range, not as buying or selling pressure, and check the trend before you fade an extreme reading or act on a flip caused by noise.
Valmy noteValmy's v1 strategy language includes the simple moving average and no other indicator, so the stochastic oscillator, Williams %R and Stochastic RSI are taught here for reading charts (as of 26 November 2026).
Stochastic oscillator: where the close sits in its recent high-low range#
The stochastic oscillator measures where the latest close sits between the highest high and the lowest low of the last n bars. It is associated with George C. Lane, who described it in a 1984 article, "Lane's Stochastics", in Technical Analysis of Stocks & Commodities. Its inputs are the high, low and close. Raw %K = 100 × (close − lowest low) ÷ (highest high − lowest low), a percentage of the range from 0 to 100. %D is a 3-bar simple moving average of %K, used as a signal line. The common default is 14 bars, and the full stochastic is written (14, 3, 3): a 14-bar range, 3-bar smoothing of %K and 3-bar smoothing for %D. Readings above 80 are conventionally called overbought and below 20 oversold.
A reading of 50 means the close is exactly halfway between the 14-bar high and low. A reading of 100 means the close is the highest price of the window, which says nothing about how far price has traveled or how strong the buying was.
Fast, slow and full stochastic versions#
The three names describe how much smoothing is applied, and platforms label them differently:
- Fast stochastic: %K is the raw %K, and %D is its 3-bar average. Settings (14, 3).
- Slow stochastic: %K is the 3-bar average of raw %K (the fast %D), and %D is the 3-bar average of that. Settings (14, 3).
- Full stochastic: the slow version with adjustable smoothing. Settings (14, 3, 3) reproduce the slow stochastic.
StockCharts and TradingView's help pages list (14, 3, 3) as their defaults. TA-Lib's STOCH function defaults to a 5-bar range with 3 and 3 smoothing, so check the lookback before comparing values across tools. If the highest high equals the lowest low, the formula divides by zero; TA-Lib outputs 0 in that case, and other tools may choose differently.
Calculating the stochastic oscillator step by step#
To calculate the stochastic oscillator: for each bar, find the highest high and lowest low of the last n bars, compute raw %K = 100 × (close − lowest low) ÷ (highest high − lowest low), then average raw %K over 3 bars to get slow %K and average slow %K over 3 bars to get %D. The example below uses n = 5 instead of 14 to keep the table short. The prices are invented for the example. At bar 9 it gives raw %K 70.59, slow %K 86.01 and %D 73.45.
| Bar | High | Low | Close | 5-bar high | 5-bar low | Raw %K | Slow %K | %D |
|---|---|---|---|---|---|---|---|---|
| 1 | 50.8 | 49.6 | 50.4 | |||||
| 2 | 51.5 | 50.1 | 51.2 | |||||
| 3 | 51.9 | 50.7 | 50.9 | |||||
| 4 | 51.0 | 49.8 | 50.0 | |||||
| 5 | 50.6 | 49.2 | 49.5 | 51.9 | 49.2 | 11.11 | ||
| 6 | 50.9 | 49.4 | 50.7 | 51.9 | 49.2 | 55.56 | ||
| 7 | 52.2 | 50.5 | 52.0 | 52.2 | 49.2 | 93.33 | 53.33 | |
| 8 | 52.6 | 51.6 | 52.4 | 52.6 | 49.2 | 94.12 | 81.00 | |
| 9 | 52.5 | 51.3 | 51.6 | 52.6 | 49.2 | 70.59 | 86.01 | 73.45 |
- Bar 5. The window is bars 1 to 5. The highest high is 51.9 (bar 3) and the lowest low is 49.2 (bar 5), a range of 2.7. The close of 49.5 is 0.3 above the low: raw %K = 100 × 0.3 ÷ 2.7 = 11.11.
- Bar 7. The window is bars 3 to 7. Bar 7's high of 52.2 is the new top, so the range is 52.2 − 49.2 = 3.0, and the close of 52.0 gives 100 × 2.8 ÷ 3.0 = 93.33.
- Bar 9. The window is bars 5 to 9: high 52.6 (bar 8), low 49.2 (bar 5). The close of 51.6 gives 100 × 2.4 ÷ 3.4 = 70.59.
- Smoothing. Slow %K at bar 9 = (93.33 + 94.12 + 70.59) ÷ 3 = 86.01. %D at bar 9 = (53.33 + 81.00 + 86.01) ÷ 3 = 73.45.
Notice that raw %K fell from 94.12 to 70.59 on bar 9 while slow %K still rose, from 81.00 to 86.01. Smoothing makes the line calmer and later.
Reading the stochastic oscillator on a chart#
On a chart, %K and %D sit in a panel below price with lines at 80 and 20. A common reading treats %K crossing below %D from above 80 as a sell signal and crossing above %D from below 20 as a buy signal. In a market moving sideways, those crossings tend to come near the ends of swings. Figure 1 shows 36 days of synthetic swings between closes of 93.09 and 102.64, followed by an uptrend.
The changes below run from the next day's open to the close five days after the signal day.
- Point A, day 8. %K (14.2) crossed above %D (8.9) after dipping below 20. From the next open of 94.96, price rose to 102.18 five days later, +7.6%.
- Point B, day 15. %K (82.0) crossed below %D (89.3) after rising above 80. From the next open of 99.26, price fell to 96.46, −2.8%.
- Days 27 and 33. A sell crossing near 80 was followed by −2.7%, and a buy crossing near 20 by +5.4%.
In this designed range, all four crossings were followed by a move in the expected direction. The next section shows the same signals in a trend.
When the stochastic misleads: pinned at the top of a trend#
In an uptrend, each new close tends to sit near the newest highs, so the stochastic stays near 100 for long stretches. "Overbought" then means only that the trend is intact, and sell crossings near 80 keep failing. In the shaded part of Figure 1, from day 37 to day 77, the close rose from 101.44 to 126.86 (+25.1%). %K was above 80 on 40 of the 41 days and never fell below 75.4.
%K crossed below %D from above 80 five times, on days 41, 46, 54, 62 and 72. Five days after each, the close was higher than the next open: +4.3%, +0.2%, +2.2%, +3.3% and +3.0%. A trader who sold on each crossing would have been wrong five times in a row. StockCharts notes that securities can stay overbought in strong uptrends and suggests trading in the direction of the larger trend. It also reports that Lane gave most weight to divergences between %D and price, not to the 80 and 20 levels alone.
Williams %R: the same range position measured from the top#
Williams %R (Williams percent range), created by the trader Larry Williams, measures how far the latest close sits below the highest high of the last n bars, as a percentage of the high-low range. Its inputs are the high, low and close. %R = −100 × (highest high − close) ÷ (highest high − lowest low), so it runs from −100 (close at the lowest low) to 0 (close at the highest high). The default lookback is 14 bars, with no smoothing. Readings above −20 are conventionally called overbought and below −80 oversold. On the same bars and lookback, %R = raw %K − 100: it is the fast stochastic's raw line drawn on a scale shifted down by 100, so it carries exactly the same information.
The identity follows from the formula. The distance from the close to the high equals the whole range minus the distance from the low to the close. Dividing by the range and multiplying by 100 gives %R = −(100 − raw %K) = raw %K − 100.
Calculating Williams %R step by step#
To calculate Williams %R: find the highest high and lowest low of the last n bars, then compute −100 × (highest high − close) ÷ (highest high − lowest low). Using the same nine invented bars and a 5-bar lookback as the stochastic example:
| Bar | 5-bar high | 5-bar low | Close | Williams %R(5) | Raw %K(5) |
|---|---|---|---|---|---|
| 5 | 51.9 | 49.2 | 49.5 | −88.89 | 11.11 |
| 6 | 51.9 | 49.2 | 50.7 | −44.44 | 55.56 |
| 7 | 52.2 | 49.2 | 52.0 | −6.67 | 93.33 |
| 8 | 52.6 | 49.2 | 52.4 | −5.88 | 94.12 |
| 9 | 52.6 | 49.2 | 51.6 | −29.41 | 70.59 |
At bar 9 the close of 51.6 is 1.0 below the 5-bar high of 52.6 in a range of 3.4: %R = −100 × 1.0 ÷ 3.4 = −29.41. Raw %K at the same bar is 70.59, and 70.59 − 100 = −29.41. Every row shows the same relationship.
Reading Williams %R on a chart#
On a chart, %R sits below price on a −100 to 0 scale, with lines at −20 and −80. Values near 0 mean the close is at or near the top of the last 14 bars, and values near −100 mean it is near the bottom. Figure 2 shows a quiet synthetic market.
- Day 4. The close of 100.73 was almost at the 14-day high, so %R was −2.3.
- Day 11. The close of 101.50 gave −16.2, just inside the "overbought" zone.
- Day 12. One candle traded up to 104.75, 3.2% above its open, then closed at 100.67. That high became the top of the 14-day window, and %R fell to −72.1 even though the close was only 0.83 below the day before.
When Williams %R misleads: a spike that leaves the window#
%R, like the stochastic, depends on the most extreme high and low in its window, and a single bar can set either one for 14 bars. When that bar leaves the window, the reading can jump with no change in price. In Figure 2 the day 12 spike to 104.75 stayed in the window from day 12 to day 25. Closes in that time stayed between 99.89 and 101.01, and %R stayed between −94.7 and −72.3, near "oversold", because the reference high was far above them.
On day 26 the spike dropped out. The window's high fell from 104.75 to 101.28, and with a window low of 99.71:
- Day 25: %R = −100 × (104.75 − 101.01) ÷ (104.75 − 99.71) = −74.2.
- Day 26: %R = −100 × (101.28 − 100.97) ÷ (101.28 − 99.71) = −19.7.
The close fell 0.04%, yet %R jumped 54.5 points into the "overbought" zone. A trader reading −19.7 as a sign of strong buying would be reading the calendar of the window, not the market. Checking which bar sets the window's high and low, and when it will leave, avoids this. The same effect hits the stochastic oscillator, because it uses the same window. Crypto charts can show such one-bar wicks during sudden liquidations or thin trading, and a wick printed on one exchange may not appear on another.
The same bars read through the raw stochastic give 25.8 on day 25 and 80.3 on day 26, the %R values plus 100.
Stochastic RSI: where RSI sits within its own recent range#
Stochastic RSI (StochRSI) applies the stochastic formula to the relative strength index (RSI) instead of to price. It was introduced by Tushar Chande and Stanley Kroll in their 1994 book The New Technical Trader. StochRSI = (RSI − lowest RSI) ÷ (highest RSI − lowest RSI) over the last n bars. Its input is the close, through RSI, which is explained in What does RSI measure, and why do "overbought" signals fail? In the original definition it runs from 0 to 1 with no smoothing, usually with a 14-bar RSI and a 14-bar lookback, and 0.8 and 0.2 are the conventional extreme levels. Many platforms instead show a smoothed version, often on a 0 to 100 scale. TA-Lib's STOCHRSI, for example, returns values from 0 to 100 with a 5-bar fast %K and a 3-bar %D by default, and TradingView's help page lists 3-bar smoothing of %K and %D as its defaults.
StochRSI is two steps removed from price. RSI already summarizes 14 closes, and StochRSI then asks where today's RSI sits among the last 14 RSI values. If RSI has moved only a few points over two weeks, a move of one or two points can push StochRSI from one end of its scale to the other.
Calculating Stochastic RSI step by step#
To calculate Stochastic RSI: compute RSI for each bar, find the lowest and highest RSI of the last n bars, then compute (RSI − lowest) ÷ (highest − lowest). The table uses RSI(14) values from days 60 to 67 of the synthetic market in Figure 3, rounded to two decimals, with a 5-day lookback to keep it short. StochRSI goes from 0.51 to 0.00, 0.40 and 1.00 in four days.
| Day | Close | RSI(14) | 5-day lowest RSI | 5-day highest RSI | StochRSI(5) |
|---|---|---|---|---|---|
| 60 | 100.05 | 52.77 | |||
| 61 | 100.15 | 53.79 | |||
| 62 | 99.82 | 49.97 | |||
| 63 | 99.91 | 51.00 | |||
| 64 | 99.99 | 51.93 | 49.97 | 53.79 | 0.51 |
| 65 | 99.62 | 47.41 | 47.41 | 53.79 | 0.00 |
| 66 | 99.76 | 49.21 | 47.41 | 51.93 | 0.40 |
| 67 | 100.28 | 55.34 | 47.41 | 55.34 | 1.00 |
- Day 64. The window is days 60 to 64. RSI ranged from 49.97 to 53.79, a span of 3.82 points. Today's 51.93 is 1.96 above the low: 1.96 ÷ 3.82 = 0.51.
- Day 65. RSI fell to 47.41, the lowest in the window, so StochRSI = 0.00.
- Day 66. Day 61's 53.79 has left the window. RSI of 49.21 sits 1.80 above the low of 47.41 in a span of 4.52 points: 0.40.
- Day 67. RSI rose to 55.34, the highest in the window, so StochRSI = 1.00.
From day 65 to day 67, the close rose 0.66% and RSI rose about 8 points, from a neutral 47 to a neutral 55. StochRSI went from its minimum to its maximum.
Reading Stochastic RSI on a chart#
On a chart, StochRSI usually sits below RSI or below price, with lines at 0.8 and 0.2 (or 80 and 20 on a ×100 scale). A reading of 1 means RSI is at its highest level of the lookback, and 0 means its lowest. Figure 3 shows a quiet synthetic market whose closes stayed between 98.66 and 101.59 for 71 days, a range of 3.0%.
- RSI stayed between 39.7 and 60.7 for all 71 days, never close to 30 or 70.
- Raw StochRSI was exactly 1 on 9 days and exactly 0 on 7 days. It was at or above 0.8 on 16 days and at or below 0.2 on 19 days.
- Days 65 to 67 (shaded) repeat the worked example with the standard 14-day lookback: 0.00 on day 65 (RSI 47.4) and 1.00 on day 67 (RSI 55.3).
- The smoothed line (3-day average, the way many platforms show %K, here divided by 100) read 26.5 on day 65, 39.0 on day 67 and 91.3 on day 69. It crossed the extremes less often, above 80 on 7 days and below 20 on 16, but it arrived two days later.
When Stochastic RSI misleads: flipping between extremes on noise#
Because StochRSI magnifies small RSI moves, it can flip between "overbought" and "oversold" on ordinary day-to-day noise. In Figure 3, raw StochRSI moved from at or below 0.2 to at or above 0.8, or back, 11 times in 71 days, while price stayed within a 3.0% band. A trader treating each extreme as a signal would have traded 11 times in a market that went nowhere, paying fees and spreads each time.
The opposite mistake happens in trends. On day 72 of Figure 1's uptrend, RSI(14) was 78.0, above Wilder's overbought level, and the slow stochastic %K was 92.4. StochRSI was 0.00, its most "oversold" reading, because 78.0 was the lowest RSI value of the previous 14 days, which had ranged up to 91.4. Calling that oversold would have been a misreading of a market trading near its highs. StockCharts describes StochRSI as fast and volatile, producing more signals, good and bad, than RSI; it suggests smoothing and confirmation from other analysis.
Comparing the three range-position oscillators#
All three put a value inside its recent high-low range, but they use different inputs and scales, so they can disagree on the same day.
| Stochastic oscillator | Williams %R | Stochastic RSI | |
|---|---|---|---|
| Measures | Close within the n-bar high-low range | The same, measured from the top | RSI within its own n-bar range |
| Inputs | High, low, close | High, low, close | Close (through RSI) |
| Scale | 0 to 100 | −100 to 0 | 0 to 1 originally; 0 to 100 on many platforms |
| Usual settings | (14, 3, 3) | 14, unsmoothed | RSI 14, lookback 14; often smoothed 3 and 3 |
| Conventional extremes | 80 and 20 | −20 and −80 | 0.8 and 0.2 |
| Main weakness | Pinned near 100 or 0 in trends | Same, plus jumpy without smoothing | Flips between extremes on small RSI moves |
On day 72 of Figure 1, raw %K was 81.0 (Williams %R −19.0), slow %K 92.4, RSI 78.0 and StochRSI 0.00. The price-based readings said the close was near the top of its range; StochRSI said RSI was at the bottom of its own range. Both statements were true at once.
Range-position oscillators on stock and crypto charts#
The range in these oscillators is built from bars, so the way a market trades changes what they show.
- Overnight gaps on stocks. When a US stock opens well above the previous day's high, the new close can sit above the entire 14-day range up to that point, so %K jumps to or near 100 in one bar. A gap down does the same toward 0. Crypto pairs trade continuously and have no overnight gaps on daily charts.
- Calendar span. Fourteen daily bars cover 14 calendar days on a crypto pair but almost three weeks on a US stock, which trades about 252 days a year.
- One-bar wicks. A brief spike sets the window's high or low for the whole lookback, as Figure 2 shows. Crypto venues can print such wicks during sudden liquidations or thin trading, and because each exchange has its own order book, a wick on one venue may not appear on another, so the same oscillator can differ across exchanges.
- StochRSI inherits RSI's dependence on the closing price. A crypto daily close is set by the platform's chosen cutoff, so values can differ between platforms that use different cutoffs.
Check your understanding: stochastic, Williams %R and Stochastic RSI#
Question.
- Stochastic. Over the last 14 days, a token's highest high is 64.0 and its lowest low is 58.0. Today it closes at 63.1. What is raw %K?
- Williams %R. What is %R for the same day? The 64.0 high was set 13 days ago, so it leaves the window tomorrow, and the next-highest high in the window is 63.4. If tomorrow's close is again 63.1 and no new high or low is made, what are raw %K and %R?
- Stochastic RSI. The last five RSI(14) values are 48.0, 49.5, 50.2, 49.0 and 48.6. What is StochRSI with a 5-day lookback, and what would a platform that multiplies by 100 show? What does the reading tell you?
Show the answers
Answer.
- Raw %K = 100 × (63.1 − 58.0) ÷ (64.0 − 58.0) = 100 × 5.1 ÷ 6.0 = 85.0. The close is 85% of the way from the 14-day low to the 14-day high.
- %R = −100 × (64.0 − 63.1) ÷ 6.0 = −15.0, which is 85.0 − 100. Tomorrow the range becomes 63.4 − 58.0 = 5.4, so raw %K = 100 × 5.1 ÷ 5.4 = 94.4 and %R = −5.6. Both oscillators rise by 9.4 points with no change in price, only because the old high left the window.
- StochRSI = (48.6 − 48.0) ÷ (50.2 − 48.0) = 0.6 ÷ 2.2 = 0.27, or 27.3 on a ×100 scale. RSI near 49 is neutral: gains and losses have been nearly balanced. StochRSI near the oversold zone only reflects that RSI has moved within a 2.2-point band and sits near the bottom of it. It is not evidence of heavy selling.
Related lessons#
- Before this lesson: What does RSI measure, and why do "overbought" signals fail?
- Next: What do CCI and the Ultimate Oscillator add to RSI?
- See also: What do Bollinger Bands measure, and does touching a band mean anything?, whose %B is another way of locating price within a range
- See also: What do TSI and the Awesome Oscillator smooth out?
- See also: How strong is this trend? ADX, the directional indicators and Aroon, for judging whether a trend may keep these oscillators pinned
- See also: Is this market trending or stuck in a range?
- See also: Why did my backtest work when live trading didn't? Overfitting and data snooping