Financial Trading in R
Ilya Kipnis
Professional Quantitative Analyst and R programmer
TTR: toolbox of classical trading indicators
SMA (Simple Moving Average)
Popular for CTA’s: 200-day moving average
# Compute a simple moving average (SMA) across 200 days
sma <- SMA(x = Cl(LQD), n = 200)
# Add the SMA line to your plot of LQD closing price
plot(Cl(LQD))
lines(sma, col = "red")
Financial Trading in R