GUIDE

Stochastic explained, and how to write it as a condition

Momentum · 5 min read

The Stochastic oscillator answers one question: where did price close inside the range it has covered recently? This guide is what that number is, what its three settings change, and the comparisons you can build a SixOne8 condition from.

The Stochastic oscillator drawn under a price chart, %K and %D with the 20 and 80 levels, and the bar where %K crosses back above 20 highlighted
Illustrative candles. %K is the fast line, %D its average; the highlighted bar is where a "crosses above 20" condition would be true.

What it measures

Take the last N bars — fourteen by default — and find the highest high and the lowest low among them. The Stochastic is where the latest close sits between those two, on a 0 to 100 scale. A reading of 80 means the close is near the top of the recent range; 20 means it is near the bottom. That is the whole measurement: not how far price has moved, but where it finished relative to the room it has had.

Readings above 80 are conventionally called "overbought" and below 20 "oversold". As with RSI, those are names for regions of the scale and not statements about what follows: in a steady trend the close sits near the top of the range bar after bar, and the reading stays above 80 for as long as the trend lasts. In SixOne8 the reading is a number your condition compares against.

%K, %D and the three settings

The raw reading is %K. It is jumpy, so it is usually smoothed, and the app draws a second line beside it: %D, a moving average of %K, which is the "signal line" the crossing conditions refer to.

  1. %K length. How many bars the high-low range covers. Fourteen is the default. Shorter reaches 0 and 100 constantly; longer rarely leaves the middle.
  2. %K smoothing. An average applied to the raw reading. One is the default — no smoothing, the "fast" Stochastic. Three is the usual "slow" setting, which trades a bar of lag for far fewer wobbles across a level.
  3. %D smoothing. The length of the average that makes the signal line. Three is the default. It only matters to the two signal-line conditions.

Whatever you choose, the lengths are counted in bars of the timeframe the condition reads. Stochastic(14) on the 1-hour chart looks at fourteen hours; on the daily chart, fourteen days.

Writing it as a condition

These are the comparisons SixOne8 offers for the Stochastic, in the builder's own words.

  1. Greater than / less than a level. True for every bar %K is on that side of the level. A state, so an alert fires when the strategy first becomes satisfied and not again while it stays there.
  2. Crosses above / crosses below a level. True only on the bar where %K moves through the level. A moment rather than a state — the usual choice for the condition that should trigger the strategy.
  3. Rising / falling. %K is higher, or lower, than it was the bar before.
  4. Crosses above / below its signal line. %K moves through %D. This fires more often than a level crossing, because the two lines sit close together and cross on most turns.

Stochastic(14, 3) on 1h  ·  crosses above  ·  20

Read it as a sentence: on the 1-hour chart, the fourteen-bar Stochastic, smoothed over three, has just moved up through 20. That is what the scanner evaluates at each hourly close, and what the alert will say if it is the condition that completed the strategy.

Stochastic or RSI?

They are often used for the same job and they move together much of the time, but they measure different things. RSI compares the size of up-closes against down-closes; the Stochastic compares the close against the recent high and low, and ignores how price got there. The practical difference is that the Stochastic reaches its extremes far more readily — a close at the top of a quiet, narrow range reads 100 even though price barely moved. If you want a reading that only reaches the extremes on a real push, RSI is the steadier of the two; if you want one that reacts to where the close landed, this is it. Stochastic RSI, a separate indicator in the app, applies this range measurement to RSI itself, and reaches 0 and 100 more often still.

On its own, it fires often

A Stochastic condition by itself matches whenever the reading reaches the level, which on a fast timeframe is constantly. Most strategies that people keep pair it with a slower condition that describes the context — price above a long moving average on a higher timeframe, or the ADX saying a trend is in force — so the Stochastic decides the moment and the other condition decides whether that moment counts.

Before you trust it

Run an entry check. It will tell you whether, on the market you care about, the moments this condition fired moved any differently from a random moment over the history tested. That is a fact about the past on that market, and it is the only kind of fact a test here produces.

Next