7.4 Charting with Indicators

7.4.1 Charting SMA

We use the function addSMA() to put

chartSeries(AAPL,
            subset='2007-05::2009-01',
            theme=chartTheme('white'))

addSMA(n=30,on=1,col = "blue")

addSMA(n=200,on=1,col = "red")

7.4.2 Charting EMA

chartSeries(AAPL,
            subset='2007-05::2009-01',
            theme=chartTheme('white'))

addEMA(n=30,on=1,col = "blue")

addEMA(n=200,on=1,col = "red")

7.4.3 Charting Bollinger band

chartSeries(AAPL,
            subset='2007-05::2009-01',
            theme=chartTheme('white'))

addBBands(n=20,sd=2)

7.4.4 Charting Momentum

chartSeries(AAPL,
            subset='2007-05::2009-01',
            theme=chartTheme('white'))

addMomentum(n=1)

7.4.5 Charting ROC

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

addROC(n=7)

7.4.6 Charting MACD

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

addMACD(fast=12,slow=26,signal=9,type="EMA")

7.4.7 Charting RSI

chartSeries(AAPL,
            subset='2007-05::2009-01',
            theme=chartTheme('white'))

addRSI(n=14,maType="EMA")

7.4.8 Charting Custom TA

sma <- SMA(Cl(AAPL),n=14)
chartSeries(AAPL,
            subset='2007-05::2009-01',
            theme=chartTheme('white'))

addTA(sma, on=1, col="red")