Skip to content

momentum indicator

Stochastic backtesting — Stochastic

The Stochastic Oscillator measures where the current close sits relative to its recent high-low range, on a scale from 0 to 100. Like RSI it is read as overbought and oversold, but it is built from the price range rather than gains and losses — a distinction that shows up in how the two behave, which a backtest can quantify directly.

Try Stochastic on BTC/USDT ETH/USDT SOL/USDT

How Stochastic works

The raw %K line is the close’s position within the highest-high to lowest-low range over a lookback window, expressed as a percentage — 100 means the close is at the recent high, 0 means it is at the recent low. %K can be smoothed before plotting, and %D is a further moving average of %K, producing a slower signal line. CandleTest computes both with TradingView-parity math. Traders watch %K crossing above/below %D as a signal, and readings above 80 or below 20 as overbought/oversold zones — both testable as no-code rules.

Stochastic settings

%K Lengthdefault 14

The lookback window for the high-low range %K is measured against. Shorter windows make %K swing between extremes more often; longer windows slow it down.

%K Smoothingdefault 1

Smoothing applied to the raw %K line before it is plotted. Higher values reduce noise at the cost of extra lag.

%D Smoothingdefault 3

The moving-average window used to derive %D from %K. Longer values make %D a slower, steadier signal line for %K to cross.

Example Stochastic strategies to backtest

%K/%D crossover

Enter long when %K crosses above %D. Exit when %K crosses back below %D.

Oversold long

Enter long when %K crosses above 20 (leaving oversold). Exit when %K crosses above 80.

Overbought exit

Exit an open long when %K crosses below 80 (leaving overbought), or when %K crosses back below %D — either signals momentum has topped out.

Every rule above is buildable in the no-code strategy builder — pick conditions, press run, and get win rate, drawdown and equity curve on real exchange data with fees and leverage modeled.

Stochastic FAQ

How is Stochastic different from RSI?

RSI is built from the size of recent gains versus losses, while Stochastic is built from where the close sits inside the recent high-low range. The two often agree but not always, and comparing rules built on each in a backtest shows which fits a given market better.

Does the %K/%D crossover work better than the overbought/oversold levels?

Neither is inherently superior — crossovers fire more often and earlier, while level-based rules wait for a more extreme reading. Backtesting both on the same pair and timeframe is the only way to see which trade-off produces better results for you.

What Stochastic settings should I use for crypto?

There is no fixed answer — crypto’s volatility varies a lot by pair and timeframe, so a setting that works well on one market can underperform on another. Sweep a few combinations of the lookback and smoothing settings in a backtest rather than copying a default blindly.

Is CandleTest’s Stochastic TradingView-parity?

Yes — the %K and %D calculations, including the smoothing steps, follow TradingView conventions and are unit-tested for parity against known values.

Related indicators