# How to Calculate Stochastics and Make a Stochastic Oscillator Chart

In stock trading, *stochastics* or *stochastic analysis* refers to interpreting the oscillations in closing prices. A stochastic oscillator is a graph that charts these fluctuations over a period of time, usually several months. Stock traders use stochastic analysis to decide when they should buy and sell stocks. The key assumption behind is that when a stock's current closing price is near its past high, the next day's price will not be drastically higher. Or when the closing price is near a past low, then the next day's price will not be drastically lower.

The steps below will show you how stock stochastics are computed and how you can chart stochastic oscillations. You can use Excel, Mathematica, Matlab, or a statistical analysis program to generate stochastic indicators. You can also use Had2Know.org's free online stochastic oscillator calculator.

**Stock Stochastic Indicators Are Moving Averages**

A stochastic oscillator charts two line graphs that are derived from the daily closing prices. One of the lines represents the change in closing price with respect to the high and low of the past N days (including the current day). This is called *Fast %K*. The other line represents the average of the Fast %K values over the past M days. This is called either *Slow %K* or *Fast %D*, it is the M-period moving average of Fast %K. Stock traders who use stochastic analysis usually set N=14 and M=3. Some may also set N=9 or N=5.

The formula for Fast %K for a particular day is given by the equation:

(Today's CP) - (Lowest CP Over Past N Days) | |

Fast %K = | ---------------------------------------------------------------------------- |

(Highest CP Over Past N Days) - (Lowest CP Over Past N Days) |

The abbreviation "CP" stands for closing price. For instance, suppose the following list represents a stock's closing price over a period of 20 days. The last seven days of the period are labeled by day of the week.

5, 3, 5, 8, 2, 4, 6, 3, 5, 5, 3, 4, 7, 3 (Th), 4 (F), 3 (Sa), 3 (Su), 6 (M), 7 (Tu), 4 (W)

Then if we use N=14, the Fast %K values for the last seven days are

Thursday Fast %K = (3-2)/(8-2) = 0.17 or 17%

Friday Fast %K = (4-2)/(8-2) = 0.33 or 33%

Saturday Fast %K = (3-2)/(8-2) = 0.17 or 17%

Sunday Fast %K = (3-2)/(8-2) = 0.17 or 17%

Monday Fast %K = (6-2)/(7-2) = 0.80 or 80%

Tuesday Fast %K = (7-3)/(7-3) = 1.00 or 100%

Wednesday Fast %K = (4-3)/(7-3) = 0.25 or 25%

Next, you can calculate the Slow %K/Fast %D values of the last five days by computing the average of the Fast %K values for the past three days:

Saturday Slow %K = (0.17+0.33+0.17)/3 = 0.22 or 22%

Sunday Slow %K = (0.17+0.17+0.33)/3 = 0.22 or 22%

Monday Slow %K = (0.80+0.17+0.17)/3 = 0.38 or 38%

Tuesday Slow %K = (1.00+0.80+0.17)/3 = 0.65 or 65%

Wednesday Slow %K = (0.25+1.00+0.80)/3 = 0.68 or 68%

To make a chart or graph of these stochastic oscillations, simply plot these numbers on a graph with horizontal axis labeled by day, and the vertical axis labeled with a scale from 0 to 1.

You can also plot a line called the

*Slow %D*, which is the 3-day moving average of the Slow %K values. For example, the Slow %D values for Monday, Tuesday, and Wednesday are

Monday Slow %D = (0.38+0.22+0.22)/3 = 0.27 or 27%

Tuesday Slow %D = (0.65+0.38+0.22)/3 = 0.42 or 42%

Wednesday Slow %D = (0.68+0.65+0.38)/3 = 0.57 or 57%

To learn how these metrics signal when you should buy or sell, see How to Interpret the %K and %D Lines on a Stochastic Oscillator.

© *Had2Know 2010
*