Home / Guides / Stochastic oscillator

Stochastic oscillator

The stochastic oscillator is a 0 to 100 reading of where the latest close sits inside the highest and lowest prices of the last N bars. Near 100 the close is at the top of its recent range, near 0 it is at the bottom. The usual window is 14 bars, and the usual marks are 80 and 20.

A 0 to 100 scale with zones under 20 and over 80 and the three sample K readings 80, 25 and 50 from the worked example, with the D reading of 51.67.

On AUDUSD, EURUSD, GBPUSD, XAUUSD and BTCUSD hourly bars, a stochastic reading in the extreme did not hold on unseen data after costs on any market (signal matrix v2), and the v1 test of the textbook rule (the K line crossing the D line in an extreme zone) averaged above zero after costs in 9 of 30 cases with 0 beyond chance in the winning direction. The stochastic showed no reliable edge. Past results, not a forecast.

Last updated 27 Nov 2026. Reviewed by the Custom Trading Platform education desk. Worked figures are sample arithmetic, shown in full. Test figures are results from our own tests on past data, with their cases, period and cost.

The short answer in four lines

  • The stochastic compares the close with the recent range, not with past gains and losses, which is the difference from RSI.
  • It has two lines: %K, the raw reading, and %D, a 3 bar average of %K.
  • Readings above 80 are often called overbought and below 20 oversold. Those are labels, not signals.
  • In a strong trend the reading can stay at an extreme for many bars.

The formula

  • Take the highest high and the lowest low of the last N bars, usually N is 14.
  • %K equals (latest close minus lowest low) divided by (highest high minus lowest low), times 100.
  • %D equals the simple average of the last 3 values of %K.
  • If the highest high equals the lowest low, the reading is undefined.

Worked example (sample numbers)

A window of 5 bars is used so the working fits on a page. Seven bars of high, low and close: (12, 10, 11), (13, 11, 12), (14, 12, 13), (13, 11, 12), (15, 12, 14), (14, 11, 12) and (15, 12, 13).

BarWindowHighest highLowest lowClose%K working%K
5bars 1 to 5151014(14 - 10) / (15 - 10) x 10080
6bars 2 to 6151112(12 - 11) / (15 - 11) x 10025
7bars 3 to 7151113(13 - 11) / (15 - 11) x 10050

%D at bar 7 is the average of 80, 25 and 50, which is 51.67. One bar closing lower took %K from 80 to 25, a drop of 55 points, which shows how fast the raw line swings. %D, the 3 bar average, moves much less than %K, which is why many charts show both. Compare the RSI guide, which reads gains against losses instead.

Stochastic against RSI

StochasticRSI
Built fromClose inside the recent high to low rangeAverage gain against average loss
Range0 to 1000 to 100
Usual marks80 and 2070 and 30
SpeedFaster, swings moreSlower
Needs highs and lowsYesNo, closes only

Which stochastic rules held on data they had not seen (signal matrix v2)

Engine and question: signal matrix v2 asks which rules held on data they had not seen. Each rule was chosen on the first 70 of every 100 bars and counted on the rest, with a gap of 50 bars: from 2 January 2024 on AUDUSD, 12 February 2024 on EURUSD, 12 February 2024 on GBPUSD, 2 February 2024 on XAUUSD, 21 May 2024 on BTCUSD, hourly bars. A clear move is at least half the usual move over that many bars. Costs are included (for AUDUSD, EURUSD, GBPUSD and XAUUSD the spread measured from real ticks plus commission both ways, and for BTCUSD the median spread recorded on each bar), swap is excluded and real fills can be worse. In the wider set of rules tested, fewer held than luck alone would give on most markets, so any rule that held is a hypothesis, not a finding. These are results from past data and they do not predict what will happen.

RuleAUDUSDEURUSDGBPUSDXAUUSDBTCUSD
K in its lowest 10 of every 100 readings (oversold)does not holddoes not holddoes not holdholds before costs onlyholds before costs only
K in its highest 10 of every 100 readings (overbought)does not holdholds before costs onlydoes not holddoes not holddoes not hold

The rules that held, and all the others with their figures.

MarketRuleVerdictWayHorizon (bars)Clear move that way, of every 100 unseen casesFlatClear move againstUnseen cases (n)Net per trade after costs
AUDUSDK in its lowest 10 of every 100 readings (oversold)does not holdup337.830.232450minus 0.0001 of one percent
AUDUSDK in its highest 10 of every 100 readings (overbought)does not holddown5033.834.431.8198minus 0.0268 of one percent
EURUSDK in its lowest 10 of every 100 readings (oversold)does not holdup541.931.326.84700.0135 of one percent
EURUSDK in its highest 10 of every 100 readings (overbought)holds before costs onlydown138.330.431.3486minus 0.0014 of one percent
GBPUSDK in its lowest 10 of every 100 readings (oversold)does not holdup34031.228.84750.005 of one percent
GBPUSDK in its highest 10 of every 100 readings (overbought)does not holddown1032.631.835.6362minus 0.0262 of one percent
XAUUSDK in its lowest 10 of every 100 readings (oversold)holds before costs onlyup148.612.738.7401minus 0.007 of one percent
XAUUSDK in its highest 10 of every 100 readings (overbought)does not holdup5051.411.836.82120.2473 of one percent
BTCUSDK in its lowest 10 of every 100 readings (oversold)holds before costs onlyup140.929.229.97850.005 of one percent
BTCUSDK in its highest 10 of every 100 readings (overbought)does not holdup202938.132.9417minus 0.1011 of one percent

The K and D cross: the rule used in the v1 test in an extreme zone (signal matrix v1)

Engine: signal matrix v1 (what happened after the textbook rule, over all history). The rule buys at the next open when %K crosses above %D with %K under 30, and sells when %K crosses below %D with %K over 70, on closed hourly bars, 14 bar window, and measures the move 4, 12, 24, 50, 72 and 168 bars later. Events are counted only when they do not overlap. The unseen data check is the last 730 days against the earlier years, and the luck check is the beyond chance column. The v1 and v2 results answer different questions and are never added together.

MarketHorizon (bars)Cases (n)Average move before costsCostAverage move after costsShare ending ahead after costsEarlier years, after costsLast 730 days, after costsBeyond chance?
AUDUSD hourly46,237minus 0.191.17minus 1.3646.4minus 1.37minus 1.29no (t minus 0.84)
AUDUSD hourly123,4150.161.17minus 1.0148minus 0.85minus 1.69no (t 0.31)
AUDUSD hourly242,0682.171.17150.21.59minus 1.43no (t 2.33)
AUDUSD hourly501,105minus 0.11.17minus 1.2748.1minus 0.47minus 4.58no (t minus 0.06)
AUDUSD hourly727992.261.171.0951.7minus 0.544.5no (t 0.87)
AUDUSD hourly1683560.691.17minus 0.4847.50.26minus 1.16no (t 0.12)
EURUSD hourly46,0290.281.119minus 0.8448.2minus 0.79minus 1.04no (t 1.03)
EURUSD hourly123,3381.331.1190.2148.90.230.16no (t 2.17)
EURUSD hourly242,0261.791.1190.6749.50.511.2no (t 1.63)
EURUSD hourly501,0960.341.119minus 0.7848.5minus 1.563.56no (t 0.16)
EURUSD hourly7279010.421.1199.3155.37.2917.23no (t 3.36)
EURUSD hourly1683543.281.1192.1650.64.06minus 6.76no (t 0.5)
GBPUSD hourly46,041minus 0.271.241minus 1.5146.2minus 1.33minus 2.23no (t minus 0.74)
GBPUSD hourly123,315minus 0.031.241minus 1.2749.2minus 0.72minus 3.5no (t minus 0.03)
GBPUSD hourly242,0340.541.241minus 0.749.9minus 0.65minus 0.9no (t 0.35)
GBPUSD hourly501,0973.551.2412.3151.13.59minus 2.77no (t 1.22)
GBPUSD hourly727863.461.2412.22522.031.78no (t 0.83)
GBPUSD hourly168354minus 0.961.241minus 2.249.7minus 5.7539.73no (t minus 0.11)
XAUUSD hourly45,617minus 3.931.773minus 5.748.9minus 2.77minus 17.48no (t minus 2.44)
XAUUSD hourly123,142minus 10.451.773minus 12.2349.2minus 4.83minus 42.42no (t minus 2.71)
XAUUSD hourly241,910minus 14.481.773minus 16.2649.1minus 8.78minus 46.27no (t minus 1.81)
XAUUSD hourly501,036minus 9.041.773minus 10.8147.9minus 9.21minus 17.36no (t minus 0.65)
XAUUSD hourly72751minus 19.751.773minus 21.5247.39.24minus 154.04no (t minus 0.96)
XAUUSD hourly168338minus 63.921.773minus 65.6946.2minus 22.84minus 284.4no (t minus 1.63)
BTCUSD hourly46,002minus 0.431minus 1.4345.9minus 1.45minus 1.38no (t minus 2.26)
BTCUSD hourly123,474minus 1.241minus 2.2447.5minus 2.42minus 1.71no (t minus 2.73)
BTCUSD hourly242,175minus 0.981minus 1.9850.6minus 2.37minus 0.84no (t minus 1.19)
BTCUSD hourly501,203minus 1.891minus 2.8949minus 2.08minus 5.36no (t minus 1.18)
BTCUSD hourly728720.881minus 0.1250.51.41minus 4.46no (t 0.4)
BTCUSD hourly1683975.7814.7852.68.52minus 8.51no (t 1.07)

How to read the table. A pip is 0.0001 for AUDUSD, EURUSD and GBPUSD, 0.1 dollar for XAUUSD and 0.1 of one percent of the price for BTCUSD, so move sizes are not comparable across markets, only the sign and the share ending ahead are. Cost per round trip, in the same pips: AUDUSD 1.17, EURUSD 1.119, GBPUSD 1.241 (measured average spread plus 0.4 slippage plus 0.7 commission), XAUUSD 1.773 and BTCUSD 1.0 (assumptions, and a tick level spread read would refine them). Swap is not included. A row is beyond chance when its t statistic is larger than the 95th percentile of the best result found by shuffling event dates (AUDUSD 3.74, EURUSD 3.98, GBPUSD 3.75, XAUUSD 4.09, BTCUSD 3.85). The v1 tests used a flat cost per market and have not been checked independently by a second person.

What it cannot tell you

The stochastic says where the close sits in its range. It does not say which way price goes next. A trend can hold it near 100 or near 0 for long periods, and a crossing of K and D happens often, each with the cost of a trade.

Sources and method

Worked figures are sample arithmetic, shown in full, as of 27 Nov 2026, and each row was recomputed by a second method before it was kept. The v2 figures come from the signal matrix v2 requests of 27 Nov 2026 on hourly bars, and the v1 figures from the copy run of 26 Nov 2026. How we check numbers is on the methodology page, the people behind the site are on the about page, and corrections go through contact.

How we will test it

We will recompute the three rows and %D in a second spreadsheet, repeat with a window of 14 on a second set of sample bars, recalculate the v2 and v1 tables, and repeat after the next data update. Last tested: not yet, results pending.

Questions people type

What is the stochastic oscillator? A 0 to 100 reading of where the latest close sits inside the highest and lowest prices of the last N bars.

How do you calculate the stochastic oscillator? Subtract the lowest low from the close, divide by the highest high minus the lowest low, and multiply by 100. %D is a 3 bar average of that.

What does a stochastic reading above 80 mean? The close is near the top of its recent range. It is often called overbought, but a trend can hold it there.

What are the best stochastic settings? The usual setting is a 14 bar window with a 3 bar %D. The tests used it and found no reliable edge.

What is the difference between %K and %D? %K is the raw reading and %D is its 3 bar average, so %D is smoother and slower.

Is the stochastic better than RSI? It is faster, not better. In our tests neither showed a reliable edge on five markets.

Does the stochastic work? In our tests an extreme reading, or a cross in an extreme zone, did not show a reliable edge on five markets.

Related

Glossary, RSI guide, stochastic RSI, RSI indicator test, MACD indicator test, Bollinger Bands test, volatility calculator, position size calculator, stop loss calculator, disclaimer.

Start free: create a free account to get the weekly note on tools and tests.

Education only. Nothing here is financial advice or a signal.

More: all indicator guides, guides.

See also: Best RSI settings.