Skip to main content

Stochastic Oscillator

The Stochastic Oscillator compares the closing price to its price range over a period of time.

Registration Name: "STOCH"

Parameters:

  • periodK (required): Period for %K calculation
  • periodD (optional): Period for %D moving average (default: 3)

Returns: Two components:

  • getValue(): %K line (current close relative to high/low range)
  • getDValue(): %D line (SMA of %K)
registerIndicator("STOCH", "BUILTIN", {
periodK: 14,
periodD: 3
}, "STOCH_14"); // Custom ID for this instance