library(quantmod)
library(PerformanceAnalytics)
s <- get(getSymbols('SPY'))["2012::"]
s$sma20 <- SMA(Cl(s) , 20)
head(s,3)
s$dc <- DonchianChannel(s[,c("SPY.High","SPY.Low")])
head(s,3)
Question 1: i get the following and last column is named dc instead of low. why and how do i fix it?
SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted sma20 high mid dc
2012-01-03 127.76 128.38 127.43 127.50 193697900 105.2762 NA NA NA NA
2012-01-04 127.20 127.81 126.71 127.70 127186500 105.4413 NA NA NA NA
2012-01-05 127.01 128.23 126.43 128.04 173895000 105.7221 NA NA NA NA
when i rerun the following command,
s$dc <- DonchianChannel(s[,c("SPY.High","SPY.Low")])
i get Error in NextMethod(.Generic) :
number of items to replace is not a multiple of replacement length
i have to remove the last 3 columns before rerunning the donchian indicator method. why?
s<-subset(s,select=-c(high,mid,dc))