rquantmod

R quantmod chartSeries can't add Bollinger Bands


In quantmod , when I using add_BBands() to add Bollinger Bands, it's show no Close column . But Close really in the dataframe . How to fix it ? Thanks!

library(quantmod)
library(TTR)
data(ttrc)
chartSeries(ttrc ,TA=c(add_BBands()))

The error message as below:

Error in Cl(xdata) : 
  subscript out of bounds: no column name containing "Close"

Solution

  • As @zx8754 commented, this is a typo. You need to use addBBands() with chartSeries(). add_BBands() (the underscore version) is meant to be used with chart_Series().

    BTW - great reproducible example!