A momentum oscillator that asks where the current close sits relative to the high-low range over a lookback window. If today's close is at the top of that range, the indicator reads near 100. At the bottom, near 0.
What it measures
- Position within the range. Where the current close falls between the period's high and low. A normalized "where in the recent envelope" reading.
- Momentum direction. Rising %K means recent closes are climbing toward the top of the range; falling %K means the opposite.
- Crossover signals. The fast %K crossing its smoothed signal %D is a common entry trigger.
Formula
Inputs in AlgoLift
| Setting | Default | Range | Notes |
|---|---|---|---|
| Type | Slow | Fast / Slow / Full | Slow applies smoothing to the raw value; Fast doesn't; Full exposes the inner smoothing parameter. |
| %K Period | 14 | 1–500 | Lookback for the high-low range. |
| %K Smoothing | 3 | 1–500 | Only visible in Full mode. Smoothing applied to Raw %K. |
| %D Period | 3 | 1–500 | Smoothing for the signal line. |
Recommended settings
- (Slow, 14, 3) — default: The textbook configuration. Works well for swing setups on 1h–daily bars.
- (Slow, 5, 3): Intraday short-term — more sensitive, more whipsaws.
- (Full, 14, 3, 3): When you want to tune the inner smoothing independently.
Outputs in AlgoLift
| Handle | Type | Plotted | Notes |
|---|---|---|---|
| %K (Fast Line) | Numeric | Always | The main oscillator line. |
| %D (Signal Line) | Numeric | Always | Smoothed %K — the lagging signal. |
| %J (Acceleration) | Numeric | On select | 3×K − 2×D. Faster than %K, more volatile. Used by KDJ traders. |
| Raw %K | Numeric | On select | Unsmoothed value — useful for inspection. |
| Slope | Numeric | On select | Rate of change of %K. |
How to read it
- %K > 80: Close is near the top of the recent range. Often called "overbought" — but in a strong trend, %K can stay above 80 for many bars.
- %K < 20: Close is near the bottom of the recent range. "Oversold" with the same caveat.
- %K crosses %D from below: Bullish crossover. Strongest when it occurs in the oversold zone (%K < 20) before crossing.
- %K crosses %D from above: Bearish crossover. Strongest in the overbought zone (%K > 80).
- Divergence: Price makes a new high but %K makes a lower high — bearish divergence. Inverse for bullish.
Stochastic is a range-bound indicator that excels in chop and fails in trends. Pair it with a trend filter before using it as a primary signal — the extremes-as-reversal interpretation is only true when there's no strong trend in progress.
Best in / worst in
Best in range-bound markets, on instruments with clear value zones, and during low-volatility regimes. Stochastic extremes mean something specific in chop — price is bumping against the bounds of a range.
Worst in trending markets. A strong uptrend will keep %K above 80 for days at a time, and selling every overbought reading will lose money continuously. The single most common stochastic mistake.
Three setups
1. Crossover in the extreme zone
The canonical entry: %K and %D cross with the prior reading in an extreme zone.
- Long: %K crosses above %D AND %K was < 20 within the last 3 bars.
- Short: %K crosses below %D AND %K was > 80 within the last 3 bars.
The "was recently extreme" requirement filters out crossovers happening in the middle of the range, which are noise.
2. Divergence setup
Price makes a new high or low but %K doesn't follow.
- Bearish divergence: Price closes at a 20-bar high, but %K is below its value from 5 bars ago. Suggests momentum is weakening.
- Bullish divergence: Price closes at a 20-bar low, but %K is above its value from 5 bars ago.
Divergence is one of the few stochastic signals that holds up reasonably well in mild trends.
3. Stochastic as a pullback timer in a trend
Use a trend filter to set direction, then use stochastic oversold/overbought as the pullback entry timing.
- Long (uptrend): Price > EMA(50) AND %K crosses above %D AND %K was < 30 within last 3 bars.
- Short (downtrend): Price < EMA(50) AND %K crosses below %D AND %K was > 70 within last 3 bars.
The trend filter prevents the "selling overbought in a bull market" failure mode.
Advanced patterns in AlgoLift
Stochastic divergence gated by a regime filter. Combine bullish divergence detection with a long-term regime check (price > SMA(200)). When divergence fires and the regime supports it, the signal is meaningfully better than divergence alone. Wire Bars Ago Modifier to compare %K against its value 5 bars ago, then AND the result with the regime check.
%J for fast confirmation, %K for the entry trigger. %J flips direction earlier than %K. Use a %J slope flip as a "get ready" signal that primes a Set Variable flag, and use the %K/%D crossover that follows as the actual entry. Reduces false starts by requiring two-stage confirmation.
Multi-timeframe stochastic. Add a 1h data series alongside your 5m execution. Only allow 5m stochastic entries when the 1h %K is in the corresponding extreme zone (long entries when 1h %K < 30, short entries when 1h %K > 70). The higher-timeframe state filters most noise on the execution timeframe. See the multi-series Visual Builder pattern.
Common mistakes
- Trading every overbought / oversold reading. %K above 80 in a strong uptrend isn't a sell signal — it's confirmation the uptrend is working. Always check the trend context first.
- Using stochastic alone on a trending instrument. A stochastic-only system on NQ during a sustained 2020-style rally lost money continuously because every "overbought" was followed by more upside.
- Ignoring %D. Bare %K is noisy. The whole point of the %D line is to filter out single-bar spikes — strategies that trigger on %K alone leave the filter unused.
- Optimizing the periods too tightly. Stochastic at (14, 3, 3) is a sensible default. A strategy that only works at exactly (13, 4, 2) is overfit. See overfitting in trading.