I am using the following code to look at the past 9 months of a stock.
library(quantmod)
getSymbols("AMZN")
candleChart(to.weekly(AMZN),multi.col=TRUE,theme="white",subset='last 9 months')
addADX()
You can see that the red line is essentially not included in the plot because it mostly lies below the value of 20. I want to modify the Y axis range of addADX
so that it always shows all three lines. How would it be possible?
The input parameters of addADX()
only control the computation of the directional movement index - not the graphical parameters which are set according to the average direction index.
A simple workaround to display the positive and negative direction index completely is to compute the directional movement index by yourself with ADX()
from the TTR
package and then add it to the previous chart with addTA()
, which allows more customisation.
library(quantmod)
getSymbols("AMZN")
dat <- to.weekly(AMZN)
candleChart(dat, multi.col = TRUE, theme = "white", subset = "last 9 months")
adx <- ADX(HLC(dat), n = 14, maType = "EMA", wilder = TRUE)[, c("DIp", "DIn", "ADX")]
addTA(adx, col = c("green", "red", "blue"), lwd = c(1, 1, 2), legend = NULL)