Open ethanbsmith opened 3 years ago
interesting momentum indicator based on smoothing the first derivative of price. https://school.stockcharts.com/doku.php?id=technical_indicators:true_strength_index
I crufted up a quick and dirty version to play with. Leaving this as a placeholder for a proper version when i get time
TSI <- function(x, n.first = 25, n.second = 13, n.signal = 7) { #True Strength Indicator #https://school.stockcharts.com/doku.php?id=technical_indicators:true_strength_index x <- try.xts(x, error = as.matrix) pc <- x - lag.xts(x, na.pad = T) #force lag.xts to get na padding dspc <- EMA(EMA(pc, n = n.first), n = n.second) dsapc <- EMA(EMA(abs(pc), n = n.first), n = n.second) tsi <- 100 * (dspc/dsapc) signal <- EMA(tsi, n = n.signal) r <- cbind(tsi, signal) r <- reclass(r, x) if (!is.null(dim(r))) colnames(r) <- c("tsi", "signal") return(r) } addTSI <- newTA(TSI, preFUN = Cl, col = c("blue", "red"))
interesting momentum indicator based on smoothing the first derivative of price. https://school.stockcharts.com/doku.php?id=technical_indicators:true_strength_index
I crufted up a quick and dirty version to play with. Leaving this as a placeholder for a proper version when i get time