[英]R quantmod chartseries 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 lag
是关键
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 结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.