闲言碎语不要表,看看代码就知晓。keltner channel的代码如下
stock.calcKC <- function(dat){
ma <- EMA((Hi(dat) + Lo(dat) + Cl(dat)) / 3, n = 20)
tr <- (ATR(HLC(dat), n = 10, maType="EMA"))[,2]
rslt <- data.frame(as.vector(ma + (2 * tr)), as.vector(ma + tr), as.vector(ma - tr), as.vector(ma - (2 * tr)))
colnames(rslt) <- c("KU2xA", "KU1xA", "KD1xA", "KD2xA")
return(rslt)
}
更多基础功能代码,请电联: xyz2abc@163.com,有偿出售。
原文:https://www.cnblogs.com/xyz2abc/p/14402702.html