Oposum
Oposum

Reputation: 1243

Add full stochastic curves to quantmod chart

Using R and the quantmod package, I am trying to add a full stochastic curve to the chart as it is displayed on http://www.stockta.com, which includes variables: %K(14,3) %D(3).

The documentation for addSMI lists four arguments:

n       periods
slow    slow
fast    fast
signal  signal 

I am not sure how I should translate the variables %K(14,3) %D(3) into addSMI to get the same stochastic curves as in http://www.stockta.com.

Any help would be appreciated.

Upvotes: 1

Views: 1419

Answers (1)

Joshua Ulrich
Joshua Ulrich

Reputation: 176648

addSMI adds the stochastic momentum index, not regular stochastics. It doesn't look like there's currently an addStoch function, but you can always use addTA

require(quantmod)
getSymbols("SPY")
chartSeries(SPY, subset='2015/')
addTA(stoch(HLC(SPY)), col=2:4)

enter image description here

The default values for stoch arguments nFastK, nFastD, and nSlowD are the same as the values you listed (14, 3, 3; respectively).

Upvotes: 2

Related Questions