Stochastic (Function)

image\trumpet2.gif Disclaimer

The Stochastic series function returns the four core values (FastK, FastD, SlowK and SlowD) associated with the Stochastic oscillator.

Syntax

Stochastic(PriceH, PriceL, PriceC, StochLength, Length1, Length2, SmoothingType, oFastK, oFastD, oSlowK, oSlowD)

Returns (Integer)

The oFastK, oFastD, oSlowK, and oSlowD output parameters return the fast and slow averages for the K and D lines.  The Stochastic function itself returns 1 if successful, otherwise -1 if both FastK=0 and SlowK=0.

Parameters

Name

Type

Description

PriceH

Numeric

Specifies which bar value (price, function, or formula) to use for the high in stochastic calculations.

PriceL

Numeric

Specifies which bar value (price, function, or formula) to use for the low in stochastic calculations.

PriceC

Numeric

Specifies which bar value (price, function, or formula) to use for the close in stochastic calculations.

StochLength

Numeric

Sets the number of bars to consider.

Length1

Numeric

Sets the constant for smoothing the fast K line.

Length2

Numeric

Sets the constant for smoothing the fast D line.

SmoothingType

Numeric

Sets the calculation method for smoothing:
1 for calculations based on the original formula.
2 to conform to legacy TradeStation calculations..

oFastK

Numeric

Outputs the value for the fast K line.

oFastD

Numeric

Outputs the value for the fast D line.

oSlowK

Numeric

Outputs the value for the slow K line.

oSlowD

Numeric

Outputs the value for the slow D line.

Remarks

The Stochastic oscillators indicate overbought and oversold areas in the market, based upon momentum or price velocity.

Stochastics are made up of four individual calculations: FastK, FastD, SlowK, SlowD. The core of the calculations is based upon the FastK value that is calculated in the following manner.

FastK = (C - L)/(H - L)*100… where

   L = Lowest Low of a specified period

   H = Highest High of a specified period

   C = Current bar Close

FastD is a smoothed average of FastK,  SlowK is equal to FastD, and SlowD is a further smoothed SlowK.

See Multiple Output Function for more information on using output parameters to return values.

Example

Outputs the FastK, FastD, SlowK, and SlowD stochastic values to the declared variables over 14 bars.

Vars: oFastK(0), oFastD(0), oSlowK(0), oSlowD(0);

Value1 = Stochastic(H, L, C, 14, 3, 3, 1, oFastK, oFastD, oSlowK, oSlowD);

Reference

Takano, Mike. Stochastic Oscillator, Technical Analysis of Stocks and Commodities. April 1991.

Stein, John. The Traders’ Guide to Technical Indicators, Futures Magazine. August 1990.