TTR has some excellent TA indicators. Is there a package or function that calculates and charts different types of Support and resistance levels? Preferably a probability distribution for the likely support and resistance levels
Here's an example to follow up on my comment.
Calculate pivots using monthly data. Each month, use the Support and Resistance calculated from the previous month's data. (Of course, it doesn't have to be monthly pivots with daily data. You could use daily pivots, and an intraday price series)
library(quantmod)
getSymbols("SPY", from="2010-05-01", to="2012-06-15")
mSPY <- to.monthly(SPY, drop.time=TRUE)
# pivots() is excluded from the TTR build because it uses quantmod functions,
# but you can still get it from GitHub by running:
#source("https://raw.githubusercontent.com/joshuaulrich/TTR/master/R/pivots.R")
piv <- lag(pivots(mSPY, lagts=FALSE))
#merge, and fill forward pivot values so that there is a value for each day
dat <- cbind(SPY, piv)
dat[, 7:11] <- na.locf(dat[, 7:11])
chartSeries(OHLC(SPY), theme='white')
addTA(dat$S1, on=1, col='lightblue')
addTA(dat$S2, on=1, col='blue')
addTA(dat$R1, on=1, col='pink')
addTA(dat$R2, on=1, col='red')
That will produce:
Donchian Channels could also be seen as support and resistance
chartSeries(OHLC(SPY), theme='white')
dc <- lag(DonchianChannel(cbind(Hi(SPY), Lo(SPY))))
addTA(dc$low, on=1, col='blue')
addTA(dc$high, on=1, col='red')
Most of the technical analysis indicators in quantmod come from the TTR package, which I wrote. I did not include subjective indicators like support/resistance lines. That said, quantmod has an addLines
function you can use.
library(quantmod)
getSymbols("SPY", from="2012-01-01", to="2012-06-15")
chartSeries(SPY, TA="addLines(h=c(134,141))", theme="white")
Which produces:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With