Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSI (True Strength Index) Indicator #103

Open
ethanbsmith opened this issue Sep 6, 2020 · 0 comments
Open

TSI (True Strength Index) Indicator #103

ethanbsmith opened this issue Sep 6, 2020 · 0 comments

Comments

@ethanbsmith
Copy link
Contributor

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"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant