Stochastic Oscillator

An indicator that measures the price velocity of a particular stock or market index, the stochastic oscillator essentially shows us where price is trading within a given range. The boundaries of the range would be the high and the low for a specific time period determined by the user. A stochastic of 100% would mean price is currently trading at the extreme high of the range and a stochastic of 0 would mean price is trading at the extreme low.

The Stochastic Oscillator, like the Relative Strength Index, helps us to determine whether price is overbought or oversold. When the Stochastic crosses up through the 80% line, it is considered overbought. Below 20% is considered oversold. The shorter the stochastic period, the more signals the indicator will produce. However, if your period setting is too short, the majority of your signals will be false. A moving average of the stochastic provides a basis for buy and sell signals. When an overbought stochastic turns down through its MA, a sell signal is produced. When an oversold stochastic moves up through its MA, a buy signal is produced.

The Stochastic Oscillator was developed by George C. Lane and is calculated as follows:

K = ((C - Ln)/(Hn - Ln)) * 100

Where:

K is Lane's Stochastics
C is the latest closing price of the stock
L is the n-period low price of the stock
H is the n-period high price of the stock
n can be any number (Lane suggests 5 to 21)

Furthermore, Lane recommends that the stochastic line be smoothed twice with three-period simple moving averages: SK is the three-period simple moving average of K, and SD is the three-period simple moving average of SK. You you can make these settings whatever you like.

Stochastics can be plotted three ways: Fast, Slow or Full

Fast = Period of your choosing, %K set to 1, %D set to your preference
Slow = Period of your choosing, %K set to 3, %D set to your preference
Full = Period of your choosing with %K and %D set to your preferences

When you look at stochastic plot, the two lines you see are the SK line and the SD line.

Custom PCF Formula
Base Syntax Function Version STOC(x, y, z)
x=Period, y=SMA, z=Offset
Indicator Version STOCx.y.z
Full Stochastic Simple %K STOCx.k.z
x=Period, k=%K, d=%D, z=Offset
%D AVG(STOCx.k.z, d)
Full Stochastic Other %K tAVG(STOCx.1.z, k)
t=AverageType, x=Period, k=%K, d=%D, z=Offset
%D tAVG(tAVG(STOCx.1.z, k), d)
Fast Stochastic %K STOCk.1.z
k=%K, d=%D, z=Offset
%D STOCk.d.z
Slow Stochastic %K STOCk.3.z
%D AVG(STOCk.3.z, d)

Where k is the %K period which must be an integer.

Where d is the %D period which must be an integer.

Where t is the Average Type. Leave blank for simple, X for Exponential, F for Front Weighted, H for Hull.

Where x is the Period which must be an integer.

Where y is an optional simple moving average applied to the raw stochastic which must be an integer.

Where z is the offset. An offset of 1 returns the value from 1 bar ago instead of the current value.