joshuaulrich / TTR

Technical analysis and other functions to construct technical trading rules with R
GNU General Public License v2.0
325 stars 102 forks source link

Ehler's Correlation Trend Indicator #92

Closed evelynmitchell closed 3 years ago

evelynmitchell commented 4 years ago

Description

Request to add Ehler's Correlation Trend Indicator

Expected behavior

As seen in TASC 2020-05 and https://financial-hacker.com/petra-on-programming-a-unique-trend-indicator/

Minimal, reproducible example

There's tradestation code in the second link. I haven't coded it up yet.

Session Info

Thank you!

ethanbsmith commented 4 years ago
CTI <- function(x, n = 20, slope = 1) {
  x <- try.xts(x, error = as.matrix)
  y <- slope * seq_along(x)
  r <- runCor(x = x, y = y, n = n)
  return(reclass(r, x))
}

addCTI <- newTA(CTI, preFUN = Cl)

add_CTI <- newTA(CTI, preFUN = Cl)