Trevor Harnett
posted this on June 05, 2010 22:31
The Description
Stochastic measures the position of a stock compared with its most recent trading range over the period specified (Raw K period). Specifically, it measures the relationship between the closing price of a stock and its high and low during a specific number of bars (minutes, days, weeks, etc). As a stock price rises, the closing price tends to be closer to the extreme highs of the stock, and as prices fall, the closing price tends to fall closer to the extreme lows. This raw stochastic value is called Raw K. The Raw K is then smoothed with a simple moving average (using the Fast D period specified) to produce the Fast D. A second simple smoothing can then be performed on the Fast D to produce the stochastics Slow D value. Stochastics values indicate overbought and oversold regions.
Mathematically, the Raw K stochastic indicator is calculated as follows:
Raw K = 100 * [CL - MIN(LO, n)] / [MAX(HI, n) - MIN(LO, n)]
where n = Raw K Period
The Raw K line is then smoothed with a simple moving average to yield a Fast D line. The Fast D line is optionally smoothed again with a simple moving average to yield a Slow D line.
Fast D = MA(Raw K, Simple, Fast D Period)
Slow D = MA(Fast D, Simple, Slow D Period)
The Fast D value (single-smoothed raw stochastics) represents the value most people are referring to when they mention Stochastics. When the Fast D crosses above the 75 line, this is considered overbought condition and a possible selling opportunity. The closing price is near the top of the recent trading range and a correction could be coming. When the Fast D starts falling, the top may have been established, and a new downtrend is considered when the Fast D indicator crosses the below the 75 line
When the Fast D crosses below the 25 line, this is considered oversold condition and a possible buying opportunity. The closing price is near the bottom of the recent trading range and a correction could be coming. When the Fast D starts rising, the bottom may have been established, and a new uptrend is considered when the Fast D indicator crosses above the 25 line.
Price trend reversals can be signaled when the Fast D line diverges from price. That is, when price makes a new high while Fast D is falling, a change of trend to the downside is indicated. If price makes a new low with Fast D rising, look for a reversal to the upside. Actual buy/sell signals are indicated when the Fast D line crosses above (buy) or below (sell) the Slow D line.
Signals are also produced when the Fast D crosses it's moving average (the Slow D). A buy signal is given when the Fast D crosses above Slow D, and a sell signal is given when the Slow D moves above Fast D.
Retracement Based
The classic Lane Stochastic calculation method dictates that the RawK represent the position of current price in relation to a recent range. This position is measured as the percentage of the distance from the low to the high. If the low of the period was 50 and the high was 70, then a current price of 65 would represent RawK of 75% while a current price of 55 would represent a RawK of 25%. From a retracement perspective, Stochastic always assumes that the high occurred first, the trend was a downtrend, and retracement is now occurring back towards the high. The RawK of the Stochastic indicator is not smart enough to know which came first, the high or the low. The “Retracement Based” checkbox in the Stochastic preferences gives the RawK value this knowledge, and therefore results in a value that represents the true retracement percentage based on the RawK period specified. This option is very similar to the “auto-retracement” option of the Fibonacci Retracement study, except it gives the ability to view the values historically, and to reference them historically in the RTL language.
Unbounded Stochastic
A new checkbox has been added to the Stochastic indicator preferences. When checked, the RawK values are allowed to go outside the 0 to 100 boundaries imposed by the standard stochastic indicator. The RawK is computed as a relative position of the closing price within the range of the "previous" n bars (n being the RawK period). The only difference being that the range of the unbounded stochastic does not consider the current bar, thus allowing the close to go outside of that range. The standard stochastic indicator includes the current high and low in its calculation of that range, thus never allowing the closing price to exceed the bounds of that range (since it must lie between the high and low of current bar). The difference between the calculations can be seen in the expressions below:
Standard Stochastic
Raw %K = 100 * [CL - MIN(LO, n)] / [MAX(HI, n) - MIN(LO, n)]
Unbounded Stochastic
Raw %K = 100 * [CL - MIN(LO.1, n)] / [MAX(HI.1, n) - MIN(LO.1, n)]
The unbounded stochastic provides additional information as to the strength of the move/trend that the standard stochastic can often hide. The unbounded option makes it easy to spot strong breakouts with values below 0 or above 100.
The Presentation - more on Charts

The Preferences

RTL Token
The Stochastics indicator has 3 tokens in RTL to represent the raw stochastics (RAWK), the smoothed stochastics (FASTD), and the double-smoothed stochastics (SLOWD). When using RAWK, only the RAWK period is relevant. When using FASTD, only the RAWK and FASTD periods are relevant. When using SLOWD, all three periods are used. For example, if you were looking for the FASTD to cross above the SLOWD line (a buys signal), you would use the following syntax in a scan.
FASTD > SLOWD AND FASTD.1 <= SLOWD.1
To find the Stochastics of RSI, the following syntax would be used in a custom indicator...
FASTD(RSI)
To draw the Stochastics Oscillator, the following syntax would be used in a custom indicator...
FASTD - SLOWD
Comments
Further Ideas
1. FASTD falls below 25. The region below 25 is considered oversold.
Should the buy signal occur when FASTD crosses below the 25 line...
FASTD < 25 AND FASTD.1 >= 25
....when FASTD bottoms out (swings up)...
FASTD > FASTD.1 AND FASTD.1 <= FASTD.2
...or when the FASTD rises back above the 25 level...
FASTD > 25 AND FASTD.1 <= 25
2. FASTD crosses above SLOWD
FASTD > SLOWD AND FASTD.1 <= SLOWD.1
or maybe...
3. FASTD crosses above SLOWD below the 25 line....
FASTD < 25 AND FASTD > SLOWD AND FASTD.1 <= SLOWD.1
Classic buy signals on Stochastics are:
- below 20 and turn up (the 'stochastic hook')
- cross up thru 20 from below
- FASTD crosses above SLOWD below 20
FASTD > SLOWD AND FASTD.1 <= SLOWD.1 AND FASTD < 20
- divergence relative to price (lower low in price, higher low in stochastic)