stoch_d

Stochastic %D (Slow Stochastic - MA of %K)

stoch_d(k_period, d_period, matype="sma")

Parameters

Stochastic %D - stoch_d(k_period, d_period, matype="sma")

The slow stochastic oscillator calculated as a moving average of %K.

This smoothed version provides more reliable signals with fewer whipsaws.

  • k_period (int): Period for %K calculation (high-low range)
  • Common values: 14 (standard), 5 (fast), 21 (slow)
  • d_period (int): Period for smoothing %K to get %D
  • Common values: 3 (standard), 5
  • matype (str, optional): Type of moving average for smoothing
  • Valid options: ["sma", "ema", "wma"]
  • Default: "sma"

Formula


%D = MA(%K, d_period)

Where:
- %K = stoch_k(k_period)
- MA = Moving average of type 'matype'

Examples


stoch_d(14, 3);  # Standard slow stochastic
stoch_d(5, 3);   # Fast stochastic
stoch_d(14, 3, matype="ema");  # EMA-smoothed %D
k = stoch_k(14); d = stoch_d(14, 3); k > d;  # Bullish crossover

Returns

Stochastic %D value (smoothed %K) ranging from 0 to 100