Description Usage Arguments Details Value Note Author(s) References See Also Examples
The stochastic oscillator is a momentum indicator that relates the location
of each day's close relative to the high/low range over the past n
periods. Developed by George C. Lane in the late 1950s. The SMI relates
the close to the midpoint of the high/low range. Developed by William Blau
in 1993.
1 2 3 4 5 6 7 8 9 10 11 12 
HLC 
Object that is coercible to xts or matrix and contains HighLowClose prices. If only a univariate series is given, it will be used. See details. 
nFastK 
Number of periods for fast %K (i.e. the number of past periods to use). 
nFastD 
Number of periods for fast %D (i.e. the number smoothing periods to apply to fast %K). 
nSlowD 
Number of periods for slow %D (i.e. the number smoothing periods to apply to fast %D). 
maType 
Either:

bounded 
Logical, should current period's values be used in the calculation? 
smooth 
Number of internal smoothing periods to be applied before calculating FastK. See Details. 
... 
Other arguments to be passed to the 
n 
Number of periods to use. 
nFast 
Number of periods for initial smoothing. 
nSlow 
Number of periods for double smoothing. 
nSig 
Number of periods for signal line. 
If a HighLowClose series is provided, the indicator is calculated using the high/low values. If a vector is provided, the calculation only uses that series. This allows stochastics to be calculated for: (1) series that have no HLC definition (e.g. foreign exchange), and (2) stochastic indicators (e.g. stochastic RSI  see examples).
The smooth
argument is the number of periods of internal smoothing to
apply to the differences in the highlowclose range before calculating Fast
K. Thanks to Stanley Neo for the suggestion.
A object of the same class as HLC
or a matrix (if
try.xts
fails) containing the columns:
Stochastic Fast %K
Stochastic Fast %D
Stochastic Slow %D
Stochastic Momentum Index
Stochastic Momentum Index signal line
The calculation for William's %R is similar to that of stochastics' fast %K.
The value for fast %K will be 0.5 whenever the highest high and
lowest low are the same over the last n
periods.
The stochastic oscillator and SMI calculate relative value of the close versus the high/low range and the midpoint of the high/low range, respectively.
The stochastic oscillator and the stochastic momentum index are interpreted similarly. Readings below 20 (above 80) are considered oversold (overbought). However, readings below 20 (above 80) are not necessarily bearish (bullish). Lane believed some of the best sell (buy) signals occurred when the oscillator moved from overbought (oversold) back below 80 (above 20).
For the stochastic oscillator, buy (sell) signals can also be given when %K crosses above (below) %D. Crossover signals are quite frequent however, which may result in whipsaws.
Joshua Ulrich
The following site(s) were used to code/document these
indicators:
Stochastic Oscillator:
https://www.fmlabs.com/reference/StochasticOscillator.htm
https://www.metastock.com/Customer/Resources/TAAZ/?p=106
https://www.linnsoft.com/techind/stochastics
https://school.stockcharts.com/doku.php?id=technical_indicators:stochastic_oscillator_fast_slow_and_full
SMI:
https://www.fmlabs.com/reference/default.htm?url=SMI.htm
See EMA
, SMA
, etc. for moving average
options; and note Warning section. See WPR
to compare it's
results to fast %K.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  data(ttrc)
stochOSC < stoch(ttrc[,c("High","Low","Close")])
stochWPR < WPR(ttrc[,c("High","Low","Close")])
plot(tail(stochOSC[,"fastK"], 100), type="l",
main="Fast %K and Williams %R", ylab="",
ylim=range(cbind(stochOSC, stochWPR), na.rm=TRUE) )
lines(tail(stochWPR, 100), col="blue")
lines(tail(1stochWPR, 100), col="red", lty="dashed")
stoch2MA < stoch( ttrc[,c("High","Low","Close")],
maType=list(list(SMA), list(EMA, wilder=TRUE), list(SMA)) )
SMI3MA < SMI(ttrc[,c("High","Low","Close")],
maType=list(list(SMA), list(EMA, wilder=TRUE), list(SMA)) )
stochRSI < stoch( RSI(ttrc[,"Close"]) )

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.