5.8 TTR

We use ROC to compute ROC. The type can be either discrete or continuous.

roc <- ROC(Cl(AAPL),type="discrete",n=2)
tail(roc,n=3)
##              AAPL.Close
## 2012-12-26 -0.012188866
## 2012-12-27 -0.009823658
## 2012-12-28 -0.006647189

5.8.1 Trading signal

Buy signal arises when ROC changes from negative to positive.

Sell signal arises when ROC changes from positive to negative.

5.8.2 Charting

chartSeries(AAPL,
            subset='2007-05::2008-01',
            theme=chartTheme('white'))
addROC(n=7)