Stochastic

Where the close sits in the recent high-low range, from 0 to 100.

Stochastic oscillator: raw %K = 100 × (close − lowest low) ÷ (highest high − lowest low) over the last k_length candles (current included); %K = SMA(raw %K, k_smooth); %D = SMA(%K, d_length). A flat window (highest = lowest) is not ready, never 50; a window holding one is skipped. Mirror: midpoint 50 (a mirrored price turns the close's place in the range around).

Settings

SettingDefaultRangeWhat it does
k_length141 to 500Candles of the high-low window.
k_smooth31 to 100SMA length of %K.
d_length31 to 100SMA length of %D.

What it gives

OutputWhat it is
%K%K, 0–100.
%D%D, 0–100.

What it reads

It reads the whole candle (open, high, low, close and volume).

Warm-up

With its default settings, Stochastic needs 20 closed candles before its first value. A backtest loads them before its start date, so the first trade can already use it.

Related indicators

Used to build: KDJ, Stochastic RSI

Test it

Copy this sentence into the Algonney chat to backtest it:

Backtest a strategy on BTC that uses Stochastic with its default settings