library(quantmod)
getSymbols("SPY", from="2013-01-01", to=Sys.Date())
chartSeries(SPY, TA="addSMA(20)")
Is there a way of shifting a moving average to the left and right?
library(quantmod)
getSymbols("SPY", from="2013-01-01", to=Sys.Date())
chartSeries(SPY, TA="addSMA(20)")
Is there a way of shifting a moving average to the left and right?
lag
is key here
s <- get(getSymbols('SPY'))
sma <- SMA(Cl(s),20)
chart_Series(s ,subset="2013::")
add_TA(sma , on = 1)
add_TA(lag(sma,10) , on = 1 , col ='red')
add_TA(lag(sma,-10) , on = 1 , col = 'blue')
outcome