全職奶爸

Stochastic Oscillator: %K, %D, Formula and TradingView Settings

Stochastic Oscillator: formula, smoothing and TradingView settings

TRADINGVIEW · TECHNICAL INDICATORS

The Stochastic Oscillator compares a closing price with the highest high and lowest low of a rolling window. Its raw reading runs from 0 to 100 when that range is positive. Many charts smooth this reading into %K, then average %K into %D. Those extra steps matter: a displayed %K of 40 can coexist with a current close that is already 80% of the way up its range.

Start by naming the calculation on your chart. This guide uses a 14-bar range, a 3-bar simple moving average for %K, and a second 3-bar simple moving average for %D. The familiar 20 and 80 lines describe oscillator conditions. They do not assign a probability to the next trade or set a price target.

The KDJ indicator guide adds the J-line formula and shows how recursive smoothing differs from this guide’s simple averages, including why the three pairwise line crosses occur together.

What the Stochastic Oscillator actually calculates

Choose a lookback N. Find the highest high and lowest low among the latest N bars, including the current bar. Subtract the lowest low from the current close, divide by the high–low range, and multiply by 100. This is the raw Stochastic reading, also called raw %K or RSV in some KD explanations.

Raw = 100 × (Close − Lowest Low over N bars) ÷ (Highest High over N bars − Lowest Low over N bars)
%K = SMA(Raw, K smoothing length)
%D = SMA(%K, D smoothing length)

The high and low come from bar extremes, rather than the highest and lowest closing prices. If a candle has a long upper wick, that wick can affect the denominator even when its close is much lower. Replacing highs and lows with closes creates a different indicator. Keep the price series consistent throughout a spreadsheet or script.

Suppose the highest high is 110, the lowest low is 100, and the latest close is 108. Raw Stochastic is 100 × 8 ÷ 10 = 80. It says where 108 lies inside that particular range. It does not say price rose 80%, that buyers own 80% of the market, or that a reversal has an 80% chance.

George Lane developed Stochastic in the 1950s. It is often described as a momentum indicator because traders study changes in this normalized range position. The formula is not a direct calculation of price velocity or acceleration. A different result can come from a changed close, a changed range, or the smoothing history.

For example, keep the close at 108. A three-bar window initially has a high of 110 and low of 100, giving 80. When the bar containing 110 leaves the window, the new high can become 109 while the low remains 100. The same 108 close now gives 88.89. The oscillator moved upward without a higher closing price. Before describing a turn as fresh buying pressure, check what happened to the rolling range.

A complete %K and %D calculation

The following example uses seven hypothetical bars. Every bar has a high of 110 and a low of 100. The closes are 102, 102, 102, 102, 108, 108, and 108. To keep the arithmetic short, set the lookback to 3, %K smoothing to 3, and %D smoothing to 3. These are demonstration settings, not a recommendation for a market.

BarHigh / LowCloseRaw, N = 3%K, SMA 3%D, SMA 3
1110 / 100102———
2110 / 100102———
3110 / 10010220——
4110 / 10010220——
5110 / 1001088040—
6110 / 1001088060—
7110 / 100108808060

At bar 5, the latest three raw readings are 20, 20, and 80. Their average is 40, so the plotted %K remains below the midpoint. The current close, however, is 108 inside a 100–110 range. Its raw position is 80. Only the raw reading translates directly into the current close’s position; a smoothed line also contains earlier observations.

Raw 80 can coexist with smoothed K 40Hypothetical three-bar-range example, raw readings20,20,80 atbars3,4,5. Their three-bar SMAis40. Latestclose108lies80percentupthe100to110range despiteKbelow50.Raw 80 can coexist with smoothed K 40HYPOTHETICAL · Range N = 3 · K smoothing = 3Current close 108 · Range 100–110 → Raw 80The close is in the upper half of its current range.Last three raw readings: 20, 20, 80Smoothed K = (20 + 20 + 80) ÷ 3 = 40A smoothed midpoint reading also contains previous observations.

At bar 7, the last three %K readings are 40, 60, and 80. Their average is 60, producing the first complete %D in this example. A %D of 60 is an average of already smoothed readings. It is not the close’s exact percentile in a price distribution.

With full windows and positive ranges, the first complete %D needs N + K smoothing length + D smoothing length − 2 observations. Here that is 3 + 3 + 3 − 2 = 7. Charting platforms can handle initial history and missing values differently, so this arithmetic describes the complete-window example rather than every platform’s first visible value.

If the highest high equals the lowest low, the denominator is zero. The formula has no defined numerical result. Inspect how your chosen platform treats that case before matching it to a spreadsheet. Assigning an arbitrary 0 or 50 changes the series and can change the next average or crossover.

Fast, Slow, Full and recursive KD use different smoothing

In the common Fast version, %K is the raw reading and %D is its three-bar SMA. A Slow version first averages raw Stochastic over three bars to produce Slow %K, then averages that line over another three bars to produce Slow %D. With matching lookbacks and ordinary three-bar SMA smoothing, Fast %D equals Slow %K.

The Williams %R guide shows the same raw range position on a negative scale: %R equals matching raw %K minus 100. Its worked example also separates that raw relationship from a comparison with smoothed %K.

Full Stochastic makes the lookback, %K smoothing, and %D smoothing configurable. Write those three meanings alongside the numbers. A label such as “14,3” can mean a fixed-smoothing Slow indicator on one platform and a Fast indicator on another. A bare tuple does not fully identify the algorithm.

Another KD convention uses a recursive calculation: new K = (2 × previous K + Raw) ÷ 3, followed by new D = (2 × previous D + new K) ÷ 3. That is an illustrative alternative to the SMA method. Its output depends on its starting values and prior history; it does not become a three-bar SMA just because both descriptions contain the number 3.

Apply raw values 20, 20, 80, 80, 80 after initializing both recursive lines at 50. The final recursive K is approximately 66.17 and D is 54.98. The corresponding complete-window SMA example above ends at K = 80 and D = 60. Compare formulas and seeds before treating a difference between apps as a faulty data feed.

KDJ adds a derived line, commonly J = 3K − 2D. That line can move beyond the usual 0–100 bounds. For example, valid SMA-smoothed K = 90 and D = 60 produce J = 150. Those K and D values can arise from raw readings 0, 0, 90, 90, 90: the final three K readings are 30, 60, and 90. A J value above 100 therefore does not imply ordinary %K is also outside its range.

Set up Stochastic in TradingView by field name

Open a chart, choose Indicators, search for Stochastic, and select TradingView’s built-in indicator. Check the title before adding it: Stochastic RSI and community scripts can apply different calculations. Open the indicator’s settings gear and choose Inputs.

For the baseline in this guide, enter %K Length = 14, %K Smoothing = 3, and %D Smoothing = 3. Set Timeframe = Chart so the indicator uses the chart interval. Record the state of Wait for timeframe closes, particularly when testing an indicator timeframe above the chart timeframe. Keep the same confirmation settings in the comparison you are trying to reproduce.

TradingView Stoch Inputs showing %K Length 14, %K Smoothing 1, %D Smoothing 3, Timeframe Chart and Wait for timeframe closes checked
The fast configuration shown here is 14 / 1 / 3. Enter 3 in %K Smoothing to use this guide’s 14 / 3 / 3 baseline. Open the image for the full-size controls.

The official Inputs illustration shows smoothing set to 1, which leaves %K unsmoothed. TradingView’s written explanation also describes smoothing 3 as its default. Use the explicit field values above for a reproducible setup instead of assuming the illustration documents an untouched default.

In Style, show both %K and %D and check their colors. The official illustration uses blue for K and orange for D, but your template can change them. Keep the upper, middle, and lower reference lines at 80, 50, and 20 for this baseline. Press Ok and check that the status line reflects the inputs you selected.

A 14-bar lookback on a five-minute chart covers 14 chart bars, or 70 minutes of bars when the interval is continuous. Market breaks and session filters can make the elapsed clock time longer. Regular-session and extended-session charts can produce different extremes and readings even for the same ticker and date.

The TradingView indicators guide explains the wider setup workflow. When two Stochastic panels disagree, align the symbol and exchange, candle type, chart interval, session, indicator timeframe, smoothing algorithm, and available history. Compare a closed bar with the same timestamp before judging the numbers.

What 14 / 3 / 3 and 5 / 3 / 3 change

Using the lookback / K smoothing / D smoothing convention, 14 / 3 / 3 examines a 14-bar high–low range and applies two three-bar averages. A 5 / 3 / 3 setup shortens the range window to five bars while leaving both averages unchanged. A 9 / 3 / 3 setup uses nine bars. None of those numbers chooses a profitable entry by itself.

A shorter range can respond quickly when older extremes leave the window. It can also remain unchanged while a longer window changes. Increasing smoothing changes the weighting history and adds lag to abrupt raw movements. It does not guarantee a lower number of crosses in every finite sample, because both lines and their relative positions matter.

Searches for the best Stochastic settings on a one-minute, five-minute, or fifteen-minute chart need a trading rule before they need a new number. Specify the instrument, session, trade direction, exit, and costs. Then compare a small declared set of configurations. Choosing the prettiest historical reversal after scrolling through many settings is selection, rather than evidence of an advantage.

Keep raw readings and both smoothed lines when reviewing a sample. That makes it possible to distinguish an altered price range from altered smoothing. If an experiment changes lookback, confirmation, exit, and session at once, the result cannot tell you which change mattered.

Read 20, 80 and a crossover in their price context

A reading above 80 is traditionally called overbought; below 20 is called oversold. For raw Stochastic these thresholds locate the close near an end of the selected range. For smoothed %K or %D they describe averages of recent normalized positions. A persistent high reading can accompany a sustained advance, and a persistent low reading can accompany a sustained decline.

Consider a strong upward move where most closes finish near each bar window’s high. Stochastic can stay above 80 across several bars while price makes new highs. Selling every high reading makes the label an entry rule without defining an invalidation or establishing that price has turned. The condition alone supplies neither.

A bullish K/D crossover has a specific event definition: K was at or below D on the prior evaluated bar and is above D on the current evaluated bar. A bearish crossover reverses those comparisons. “K is above D” describes a state that can last several bars; it is not a new crossover on every one of them.

For a closed-bar test, evaluate those relationships after the selected bar closes. An open candle’s close, high, and low can change, allowing a visible cross to disappear before the bar ends. A historical chart that displays the final values does not show every temporary intrabar cross that a trader might have seen live.

A range-based test could require a premarked support area, Stochastic returning above 20, and a subsequent price break above a specified signal bar. Its invalidation might be below the support structure. Define which event comes first and how long the setup remains eligible. The same oscillator movement in the middle of a wide range can offer a very different distance to invalidation and target.

A trend-pullback test instead starts with a declared trend condition and looks for a pullback in that direction. A bearish cross during an uptrend might serve as an exit condition for one method and be irrelevant for another. Keep those strategies separate in a journal; mixing them makes a common indicator name look like one coherent strategy when the trade logic differs.

Use confirmed pivots for divergence and Lane setups

Bullish divergence compares a lower price low with a higher oscillator low. Bearish divergence compares a higher price high with a lower oscillator high. Match corresponding swings and record whether you are using raw Stochastic, %K, or %D. Switching lines halfway through a comparison changes the signal you are describing.

A pivot definition can require bars to the right of the turning point. If two later bars are needed to confirm a low, the signal only becomes available after those bars exist. A backtest should not fill a trade on the original low’s timestamp using information confirmed later. Record both the pivot time and the confirmation time.

Repeated divergence can persist while price continues in its original direction. Evaluate the complete rule, including price confirmation, failed setups, costs, and exits. A chart selected because it contains a dramatic successful turn cannot tell you how often the same method failed elsewhere.

Lane’s bull setup has a different shape: price makes a lower high while Stochastic makes a higher high. A bear setup pairs a higher price low with a lower oscillator low. These patterns are observations to test with a subsequent pullback or rebound rule. They do not establish the date or price of a future turning point.

Current range, RSI and Stochastic RSI are different comparisons

The current bar belongs in the ordinary Stochastic range. Suppose earlier extremes are 100 and 110, then a new bar has a high of 114, low of 105, and close of 112. If the rolling window still contains the 100 low, the current-inclusive raw reading is 100 × 12 ÷ 14 = 85.71. Dividing by the old 100–110 range would give 120.

Include the current bar in the price rangeHypotheticalpriorrange100to110,currenthigh114low105close112with100lowstillinsidewindow.CurrentinclusiveStochastic85.71. Normalizingagainstpriorrangegives120,whichisadifferentdefinition.Include the current bar in the price rangeHYPOTHETICAL · Prior high 110 · Window low still 100Current bar: High 114 · Low 105 · Close 112Current range: 100 × (112 − 100) ÷ 14 = 85.71Using the old high of 110 gives a different result:Prior range: 100 × (112 − 100) ÷ 10 = 120The second calculation is not ordinary current-inclusive Stochastic.

The second calculation compares price with a previous range. It can be useful for a separately defined breakout question, but it is not ordinary current-inclusive Stochastic. The Donchian Channel guide develops that distinction between the current window and prior breakout boundaries. Keep the choice explicit when combining a range oscillator with breakout rules.

RSI compares smoothed upward and downward closing-price changes. Ordinary Stochastic compares a close with bar highs and lows. Both can show “overbought” labels while expressing different arithmetic. The RSI indicator guide covers its calculation and settings. There is no universal winner between RSI and Stochastic without a defined setup and evaluation sample.

Stochastic RSI applies a range-normalization calculation to RSI values instead of directly to the price high–low range. A high Stochastic RSI reading therefore locates RSI near the top of its own recent range; it does not necessarily mean the ordinary price Stochastic is high. Check whether the platform presents a 0–1 scale or multiplies it to 0–100 before copying thresholds.

CCI answers another question: how far the selected source price is from its current-window mean relative to mean absolute deviation. Its familiar ±100 levels are not Stochastic’s 0 and 100 boundaries. The CCI formula and settings guide shows why source selection and the denominator change its result. Adding several oscillators does not make their signals independent evidence.

Test a Stochastic setup before assigning it money

Write one entry rule that another person could apply without seeing the future. Include the exact fields, session, permitted direction, confirmation timing, invalidation, target or exit rule, and a maximum holding period if one is used. Decide how to handle consecutive signals while a position is already open.

Separate a development sample from an untouched evaluation sample. Include quiet sessions, directional sessions, and failed signals rather than retaining only obvious turns. For intraday futures, record commissions, spread assumptions, slippage, and contract rollover treatment. A small average gain before costs can disappear when those costs are included.

A Stochastic value does not specify a stop distance. Suppose a hypothetical trade risks $50 from entry to price invalidation per contract before costs, while the trade budget is $100. Fees and a realistic slippage allowance can make two contracts exceed that budget. Calculate quantity from price risk and costs, then check any applicable account limits. The position sizing guide covers that step.

For a PropFirm evaluation, apply the provider’s current permitted instruments, position limits, drawdown method, and trading restrictions to the same test. An oscillator trigger does not grant additional room under those rules. Compare the account structure before paying for an evaluation and use the current purchase terms for the plan you select.

Compare HDP discounts

Lucid 30% · Tradeify 30% · TPT 50%.

See current offers ↗

Eligible partner plans only.

Stochastic Oscillator FAQ

What is a Stochastic Oscillator?

It is a range-based momentum oscillator. The raw calculation locates the latest close between the highest high and lowest low of a chosen rolling window, and configurable averages produce %K and %D.

What do %K and %D mean?

%K can be the raw Stochastic reading or a smoothed version, depending on the indicator. %D is an average of %K. Name the version, smoothing method, and lengths before comparing platforms.

How is Stochastic calculated?

Raw = 100 × (Close − Lowest Low) ÷ (Highest High − Lowest Low), using N bars including the current bar. For this guide’s setup, %K is a three-bar SMA of raw and %D is a three-bar SMA of %K.

What does Stochastic 14 / 3 / 3 mean?

In the convention used here, 14 is the price-range lookback, the first 3 smooths raw into %K, and the second 3 averages %K into %D. Use field names because platform parameter conventions can differ.

What does 5 / 3 / 3 change?

It uses a five-bar high–low window while keeping both three-bar averages. It changes the range history; it does not establish a better trading result without testing a complete rule.

Is Stochastic above 80 a sell signal?

Above 80 is an overbought condition under the traditional thresholds. It can persist during an advance. A trading signal needs a separate event definition, price context, invalidation, and exit.

Does %K below 50 mean the close is in the lower half?

That interpretation applies directly to raw Stochastic. A smoothed %K also contains earlier readings: raw values 20, 20, and 80 average to %K 40 even though the current close is at 80% of its range.

What is the difference between Fast and Slow Stochastic?

Fast %K is raw, with an averaged Fast %D. The common Slow version adds a three-bar SMA to raw for Slow %K, then averages again for Slow %D. With matching three-bar SMA settings, Fast %D equals Slow %K.

Is Stochastic RSI the same indicator?

No. Ordinary Stochastic normalizes closing price against a price high–low range. Stochastic RSI normalizes RSI against its own recent RSI range, so the same displayed number answers a different question.

Is RSI better than Stochastic?

They use different inputs and calculations. Compare complete trading rules on the same instrument, sessions, costs, and evaluation period instead of selecting a universal winner from the indicator name.

What are the best settings for a five-minute chart?

There is no universally best configuration. Start with explicitly recorded settings such as a 14-bar lookback and two three-bar SMA stages, then test a small declared set against an unchanged trading rule and out-of-sample data.

Why does Stochastic move when the close stays unchanged?

An old high or low can leave the rolling window, changing the raw denominator or reference low. Earlier observations also roll through the smoothing stages. Neither mechanism requires a new closing price.

Can Stochastic go above 100?

With valid current-inclusive OHLC data, a positive range, and ordinary SMA smoothing, raw, %K, and %D stay between 0 and 100. A derived KDJ J line or a calculation using a prior range can exceed those bounds.

Why do two charts show different Stochastic values?

Check the symbol, exchange, sessions, candle type, chart and indicator timeframes, lookback, smoothing method, lengths, starting history, and bar confirmation. Recursive KD and SMA-smoothed Stochastic can differ even with similar labels.