Hello again. If you have been following this series, you may have noticed that I haven’t yet comprehensively covered Bollinger Bands. We’ll be revisiting them in the future. For now, let’s turn our attention to one of my favorite technical indicators, the popular (but poorly-named) stochastic oscillator.
A stochastic oscillator takes three parameters and produces two outputs, known as %K and %D. The parameters are:
- A span parameter, which specifies how many bars the oscillator will cover. The most popular configuration is 14 days.
- A Ksmooth parameter, which specifies how many bars should be used for smoothing the %K oscillator. The most popular value is 3, but often people will use Ksmooth=1. This is known as the fast stochastic oscillator
- A Dsmooth parameter, which specifies how many bars should be used for smoothing the %D oscillator. The most popular value is 3. Occasionally people will use a shorthand specification where it is assumed that Ksmooth=Dsmooth. This is known as the slow stochastic oscillator
Calculation of the unsmoothed %K parameter is as follows: Look back of the last span bars and find the lowest and highest prices. Use the formula . To calculate the smoothed version, calculate the simple average of the unsmoothed %K parameter over Ksmooth days, i.e.
. Calculation of %D is similar, but rather than smoothing the unsmoothed %K parameter over Ksmooth bars, we instead smooth the smoothed %K parameter over Dsmooth bars:
The stochastic oscillator is thought to signal noteworthy events when the %K line crosses the %D line. It is thought that where the crossover occurs is also of some importance; if a crossover occurs above 0.8, it is thought to have a different meaning than a crossover that occurs below 0.2.
Calculating stochastic oscillators on all major-exchange U.S. stocks at all timepoints in the Yahoo! Finance database that I have been using for test purposes (eliminating any stocks that have ever traded below $1.00) and then calculating the geometric averages of the five-day returns of stocks meeting various criteria leads to the following table:
| 14, 3, 3 Full Stochastic Oscillator Test Results, 5-day Close-to-Close, Geometric Averages | ||
| %K Crosses Above %D | %K Crosses Below %D | |
| Above 0.8 | (0.043%) | (0.071%) |
| Below 0.2 | 0.272% | 0.387% |
| Geometric Average 5-day Return, Close-to-Close: 0.087% | ||
From this table we can see that choosing a random non-penny U.S. stock and holding it for five days is not a very good strategy. But choosing a non-penny U.S. stock at close when its %K crosses below its %D below 0.2 and then selling it at close five days later has shown in the test data (which is, admittedly, somewhat incomplete) returns averaging about 20% per year (minus commissions). While it is impossible to say with certainty how well such a strategy would perform in the real world, clearly, there is more to the stochastic oscillator than random chance.











