Created by George Lane, the Stochastic Oscillator, also known as KDJ Index, is a momentum oscillator that compares current price with recent highs and lows and is presented on a scale of 0 to 100. [Discuss]
// usage (standard) IEnumerable<StochResult> results = quotes.GetStoch(lookbackPeriods, signalPeriods, smoothPeriods); // advanced customization IEnumerable<StochResult> results = quotes.GetStoch(lookbackPeriods, signalPeriods, smoothPeriods, kFactor, dFactor, movingAverageType);
int - Lookback period (
N) for the oscillator (%K). Must be greater than 0. Default is 14.
int - Smoothing period for the signal (%D). Must be greater than 0. Default is 3.
int - Smoothing period (
S) for the Oscillator (%K). “Slow” stochastic uses 3, “Fast” stochastic uses 1. Must be greater than 0. Default is 3.
double - Optional. Weight of %K in the %J calculation. Must be greater than 0. Default is 3.
double - Optional. Weight of %D in the %J calculation. Must be greater than 0. Default is 2.
MaType - Optional. Type of moving average (SMA or SMMA) used for smoothing. See MaType options below. Default is
Historical quotes requirements
You must have at least
N+S periods of
quotes to cover the warmup periods.
quotes is a collection of generic
TQuote historical price quotes. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.
These are the supported moving average types:
MaType.SMA - Simple Moving Average (default)
MaType.SMMA - Smoothed Moving Average
- This method returns a time series of all available indicator values for the
- It always returns the same number of elements as there are in the historical quotes.
- It does not return a single incremental indicator value.
- The first
N+S-2periods will have
nullOscillator values since there’s not enough data to calculate.
Convergence warning: The first
N+100periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods when using
MaType.SMMA. Standard use of
MaType.SMAdoes not have convergence-related precision errors.
DateTime - Date from evaluated
double - %K Oscillator
double - %D Simple moving average of Oscillator
double - %J is the weighted divergence of %K and %D:
%J = kFactor × %K - dFactor × %D
Note: aliases of
J are also provided. They can be used interchangeably with the standard outputs.
See Utilities and helpers for more information.
Results can be further processed on
Oscillator with additional chain-enabled indicators.
// example var results = quotes .GetStoch(..) .GetSlope(..);
This indicator must be generated from
quotes and cannot be generated from results of another chain-enabled indicator or method.