Search code examples
rquantmod

addADX() and addTA(ADX(symbol)$ADX) yield different output


chartSeries(HSI, subset="2017/", TA="addADX();addTA(ADX(HSI)$ADX,on=2,col=\"orange\")")

output plot:

enter image description here

The orange ADX(HSI)$ADX is off from the one shown by addADX(). What is the reason? Both functions should use the same arguments.


Solution

  • The ADX() function requires a high-low-close series. You're passing it an open-high-low-close series, so it uses the first 3 columns. Use the HLC() extractor to subset only the columns you need to pass to ADX().

    chartSeries(HSI, subset = "2017/",
                TA = "addADX();addTA(ADX(HLC(HSI))$ADX, on = 2, col = 'orange')")