What Is the Stochastic Oscillator? Formula, %K and %D Worked on Real SPY Prices
The stochastic oscillator measures where the current close sits inside the highest high and lowest low of the last 14 bars, as a number from 0 to 100. A reading near 100 means price closed near the top of that range and a reading near 0 means it closed near the bottom.
Covered on this page: TradingView.
The stochastic oscillator is a 0 to 100 reading of where the latest close sits between the highest high and the lowest low of the last 14 bars. Near 100 means the close was at the top of that range, near 0 at the bottom, and 50 means it closed halfway.
That is the whole calculation, and it explains everything the tool does well and badly. Below, the formula is run by hand on SPY’s real closes for the last two weeks of October 2026, then on every SPY session since 1993 to see what readings above 80 and below 20 were actually followed by.
How it works
The oscillator asks one question of each bar: of the distance between the recent floor and the recent ceiling, how far up did today close? It is credited to George Lane, who developed it in the late 1950s.
Step 1, raw %K. Take the last 14 bars, today included. Find the highest high and the lowest low.
raw %K = 100 x (close - lowest low) / (highest high - lowest low)
Step 2, the %K line. Most charts do not plot the raw number. TradingView’s default inputs are 14, 3, 3: a 14-bar lookback, a 3-bar simple average of raw %K (that average is the %K line you see), and a 3-bar simple average of that line, which is %D. StockCharts calls this the full stochastic.
Step 3, %D. Average the last three %K values. %D carries no new information; it is %K slowed down, so a cross between them is one series passing a lagged copy of itself.
Fast, slow and full: one formula, three names
| name | %K line | %D line | settings written as |
|---|---|---|---|
| Fast | raw %K | 3-bar average of raw %K | 14, 3 |
| Slow | 3-bar average of raw %K | 3-bar average of that | 14, 3 (or 14, 3, 3) |
| Full | X-bar average of raw %K | Y-bar average of that | 14, X, Y |
The slow version is what TradingView draws by default, and it is the one used for every number on this page. Setting the smoothing input to 1 turns it back into the fast version.
What the number does not contain
There is no price in it, no volume, and no idea of direction beyond the window. A reading of 90 says the close is near the 14-bar ceiling. It cannot say whether the ceiling is a top or a step on the way up, which is why the market structure read has to come from price.
Worked example: SPY’s %K and %D by hand, 30 October 2026
These are SPY’s real daily bars for the 14 sessions ending 30 October 2026, from Yahoo Finance (split-adjusted, not dividend-adjusted).
| date | high | low | close |
|---|---|---|---|
| 13 Oct | $778.75 | $775.95 | $778.01 |
| 14 Oct | $776.35 | $766.71 | $769.60 |
| 15 Oct | $772.87 | $764.43 | $771.79 |
| 16 Oct | $773.25 | $760.64 | $763.25 |
| 19 Oct | $770.46 | $765.82 | $766.48 |
| 20 Oct | $772.29 | $764.25 | $769.05 |
| 21 Oct | $774.44 | $768.40 | $773.09 |
| 22 Oct | $767.71 | $761.17 | $763.96 |
| 23 Oct | $763.47 | $758.68 | $759.97 |
| 26 Oct | $767.73 | $761.63 | $765.37 |
| 27 Oct | $771.14 | $765.21 | $769.66 |
| 28 Oct | $773.36 | $769.24 | $772.31 |
| 29 Oct | $770.76 | $766.62 | $769.36 |
| 30 Oct | $761.46 | $750.36 | $755.72 |
The range. The highest high in the window is $778.75 on 13 October. The lowest low is $750.36, set on 30 October itself. The range is $778.75 - $750.36 = $28.39.
Raw %K for 30 October. The close was $755.72 - $750.36 = $5.36 above the low. 100 x 5.36 / 28.39 = 18.88. On the raw number alone, SPY closed in the bottom fifth of its range.
The %K line. The same sum on the two previous sessions, each with its own 14-bar window, gives raw readings of 65.72 on 28 October and 51.54 on 29 October. The plotted %K is their average with today’s: (65.72 + 51.54 + 18.88) / 3 = 45.38.
%D. The %K line read 50.31 on 28 October and 56.73 on 29 October, so %D = (50.31 + 56.73 + 45.38) / 3 = 50.81.
What a chart showed that evening. %K at 45.38 had dropped under %D at 50.81, having been above it (56.73 against 45.77) the day before. That is a downward cross in the middle of the scale, the kind most guides tell you to ignore because it did not happen near 80.
The lesson in the gap. A $13.64 fall in one session put the close near the bottom of the range, yet the default line still read mid-scale. The smoothing that removes jitter also delays the news by a day or two.
The textbook signal just before it. On 26 October %K was 17.90, under 20, and on 27 October it rose to 30.27, above %D at 25.04: a cross up from oversold, at a close of $769.66. Three sessions later SPY closed at $755.72. One case proves nothing in either direction, which is exactly why the next section counts all of them.
The original data
We computed the 14, 3, 3 stochastic for every SPY session from 29 January 1993 to 30 October 2026, 8,497 daily bars (8,480 with a reading, from 24 February 1993). The full SPY stochastic data lists every bar’s raw %K, %K and %D.
How often SPY sat in each zone
| %K reading | sessions | share |
|---|---|---|
| above 80 | 3,148 | 37.12% |
| 20 to 80 | 4,381 | 51.66% |
| below 20 | 951 | 11.21% |
Overbought was more than three times as common as oversold. That is not a flaw in the fund; a market that rose for three decades closes near the top of its recent range more often than near the bottom.
Overbought also lasted. There were 425 separate stretches above 80. The median ran 6 sessions, 123 ran 10 sessions or more, and 21 ran 20 or more. The longest was 29 sessions, 3 November to 14 December 1995, during which SPY’s close rose 4.96%. The longest stretch below 20 was 19 sessions, 19 June to 16 July 2008, and SPY’s close fell 7.78% across it.
In 2026 alone, %K was above 80 on 70 of 209 sessions and below 20 on 18.
What came after a move into 80 or 20
The test. Take every session where %K moved above 80 after being at or below 80 the session before (423 of them with 20 sessions of data after), and the mirror case under 20 (261). Then check whether SPY closed higher 20 sessions later, and compare with all sessions.
| starting point | cases | higher 20 sessions later | median 20-session change |
|---|---|---|---|
| all sessions | 8,460 | 63.84% | +1.28% |
| %K just moved above 80 | 423 | 66.90% | +1.23% |
| %K just moved below 20 | 261 | 64.37% | +1.71% |
Read it plainly. A move into overbought was not followed by more falls than an ordinary day; SPY closed higher a little more often, not less. The gap is about 1.3 standard errors from the all-sessions rate, within what chance produces.
Keeping only entries at least 20 sessions apart, so no two windows overlap, gives 167 of 239 higher (69.87%), about 1.9 standard errors: still not a clear result on one fund. The oversold side was 64.37%, almost exactly the base rate.
What this does and does not say. It is one ETF, on daily bars, with the 14, 3, 3 settings. It says the zone label alone carried no measurable warning about the next month on SPY. It does not test a full trading plan with exits, and it is not evidence that buying overbought readings is a plan either.
Which setting changes the signal count
The common advice is that a shorter lookback gives many more crossings. On SPY from January 1994 to October 2026 (8,263 sessions), it barely did:
| settings | %K and %D crossings |
|---|---|
| 5, 3, 3 | 2,252 |
| 14, 3, 3 (default) | 2,120 |
| 21, 3, 3 | 2,072 |
| 14, 1, 3 (fast) | 3,418 |
| 5, 1, 3 (fast) | 3,558 |
Cutting the lookback from 14 to 5 added about 6% more crossings. Removing the %K smoothing added about 61%. At the default, the lines crossed roughly once every four sessions; in 2026 they crossed 54 times in 209 sessions. A crossover by itself is a frequent event, not a rare one.
Overbought in an uptrend, oversold in a downtrend
The zone counts above are the arithmetic behind a point every trader meets the hard way. In an uptrend each new close lands near the top of a window that keeps rising, so %K stays high for as long as the move lasts. The 29-session stretch in late 1995 is that case: a sell on the first reading over 80 sold the start of it.
The mirror is just as true. In a falling market the close keeps landing near the floor, and the 2008 stretch shows %K under 20 for almost four weeks while SPY kept falling.
So decide the condition first. In a trading range, the floor and ceiling in the formula are levels price keeps returning to, so a reading near 0 or 100 marks a real edge with a price you can name. In a trend, the same reading only confirms the trend.
Divergence, the signal Lane put first
A bullish divergence is a lower low in price with a higher low in the oscillator; a bearish divergence is a higher high in price with a lower high in the oscillator. StockCharts notes that Lane ranked divergence as his first and most important signal, ahead of the 80 and 20 levels.
In terms of the formula, a bullish divergence means the close sat higher in its 14-bar range at the second low than at the first. This page does not count divergences on SPY, because what counts as a swing low depends on a rule each trader sets, and a different rule would give a different count.
Bollinger Bands and VWAP also report where price sits against a reference, and the trap is the same: a position is not a forecast. The filter in VWAP strategies runs into the same question of whether the day is trending.
Choosing settings
- 14, 3, 3 is the TradingView default and the one most guides assume. Start there so your readings match what other people quote.
- The lookback sets how much history defines the range. Match it to how long you hold: a 5-bar range on a daily chart is one week, a 21-bar range is about a month.
- The %K smoothing is the input that changes behavior most. At 1 the line reacts on the same bar and crosses %D far more often; at 3 it lags a day or two, as on 30 October.
- The 80 and 20 levels are conventions, not measured edges. Some traders use 85 and 15.
For step-by-step reading of the panel on a live chart, the how to use the stochastic guide covers the order of checks.
When it fails
Selling the first reading over 80 in an uptrend. On SPY the median overbought stretch lasted 6 sessions and 21 lasted 20 sessions or more. The reading was describing the rise, not ending it.
Counting a crossover as two signals agreeing. %D is built from %K, so the cross is one series against its own delay. At the default it happened about once every four sessions on SPY.
Using it with no price level. The oscillator cannot give an invalidation point because it contains no price. The stop has to come from the chart: a close beyond the range edge you marked.
Changing settings until the past looks clean. Some combination always fits the last few swings. The crossing counts above show how little the lookback alters and how much the smoothing does.
Questions people ask
What is the best setting for the stochastic oscillator?
There is no measured best. 14, 3, 3 is the default on TradingView and in most guides, and on SPY since 1994 changing the lookback from 14 to 5 changed the crossing count by about 6%, while dropping the smoothing changed it by about 61%.
What is the difference between the fast and slow stochastic?
The fast stochastic plots raw %K and a 3-bar average of it. The slow version smooths raw %K first, then averages again for %D. Slow is smoother and later; fast is noisier and crosses more often.
Is the stochastic better than RSI?
They answer different questions: the stochastic measures position in the range, RSI compares the size of up closes to down closes. The RSI vs stochastic page sets them side by side, and the stochastic RSI runs this formula on RSI instead of price.
What does a stochastic reading above 80 mean?
That the latest close is in the top fifth of the 14-bar range. On SPY that was true on 37.12% of sessions since 1993, and moves into that zone were followed by a higher close a month later about as often as any other day.
Is the stochastic a leading or lagging indicator?
Lagging. Every input is a past bar, and the default smoothing adds two more averages, which is why the 30 October 2026 reading trailed the day’s drop.
Related
RSI is the other 0 to 100 oscillator traders pair with this one, measuring the balance of gains and losses rather than position in a range. Williams %R is the stochastic turned upside down, and the stochastic vs Williams %R page shows why the two lines match. Stochastic RSI vs Williams %R pits two faster relatives against each other.
For the wider picture, technical analysis explains why indicators built from the same closes are not independent confirmation, and market structure is the read that tells you whether a range exists before the oscillator is worth a look.
The thing to hold on to is that it does not know what a trend is. It only knows where today closed inside the last fourteen bars, so in a market going up every day it reads high every day, and that is correct rather than a warning. I use it in a range and I ignore it in a trend, and if I cannot tell which one I am in then the oscillator is not the tool that will tell me.
— Michael Whitman
This page is educational, not financial advice. Test every idea on your own charts before risking money. Some links on this page earn a commission if you buy through them. It costs you nothing and it does not decide what appears here or in what order — how these pages are made is set out in our methodology.