R Slow Stochastic quantmod

896 views Asked by At

I am trying to reproduce this chart in R using quantmod, however I cannot seem to get the same result for the slow stochastic. Here is what I have tried so far:

library(quantmod, quietly=TRUE)
getSymbols("SPY", from="2013-01-01")
chartSeries(SPY, subset='last 3 months')
addSMI(n=5,slow=5,fast=1,signal=1,ma.type="SMA")
1

There are 1 answers

1
Joshua Ulrich On BEST ANSWER

Well, first off, you're not going to be able to calculate slow stochastic with the SMI (stochastic momentum index) function. :)

Second, there's no addStochastics function. You need to use stoch to calculate the value you need, then addTA to add it to the chart. The code below seems to get fairly close to the chart in your link.

chartSeries(SPY, subset='2015', TA="addTA(stoch(HLC(SPY), 5, 1, 3, 'SMA')$slowD)")