Utilizing the chartSeries function in the quantmod package, I want to modify the RSI oscillator. Given an xts object containing OHLC price data, here is the call that I am using:
chartSeries(plot_report[, 1:4],
name = substr(ticker, 1, nchar(ticker) - 4),
theme = chartTheme('white.mono', grid.col = NA),
TA = c(addRSI(n = 14, maType = "SMA")),
type = "line",
bar.type = 'ohlc',
major.ticks = 'months',
show.grid = FALSE,
log.scale = TRUE)
Generating this chart:
I have four questions:
How can I change the default color of blue to something else? I have tried: c(addRSI(n = 14, maType = "SMA", col = "black")). However, I get the "unused argument" error.
Can I draw horizontal lines in the oscillator panel? Traditional RSI's have a horizontal red line at a y-axis value of 70 and a horizontal green line at a y-axis value of 30 to indicate overbought/oversold levels.
Is it possible to plot another calculation as an oscillator line below the chart? I have some proprietary oscillators that I want to visualize instead of the RSI or any of the indicators in the TTR package.
How can I get involved in improving the quantmod charting functionality; is this project being actively maintained?
...
to the arguments for addRSI
and modify the body of the function to use ...
appropriately. A work-around is to calculate RSI
manually, then call addTA
as done in the answer to Change line colors of technical indicators made by R quantmod TTR?.addLines
:getSymbols("SPY"); chartSeries(SPY, TA="addRSI();addLines(h=c(30,70), on=2)")
addTA
with the object containing your proprietary data.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