[R-SIG-Finance] chart_Series: Adding multiple custom indicators

Mike m|ke9 @end|ng |rom po@teo@n|
Wed Jul 5 22:10:53 CEST 2023


Some time ago I wrote an R script where I added custom indicators to
a main chart by putting them into a list like this:

CODE:
data (sample_matrix, package="xts")
data <- as.xts (sample_matrix)

ta <- list ()
ta[[1]] <- "add_TA (SMA (data$Close, 20), col='#BB0000')"
ta[[2]] <- "add_TA (SMA (data$Close, 3), col='#00BB00')"

co <- chart_Series (data, name='test data', TA=ta)
plot (co)


After some updates, and now running
> packageVersion('quantmod')
[1] '0.4.23'
I started the code again and got this:

Error in !is.null(TA) && nchar(TA) > 0 : 
  'length = 2' in coercion to 'logical(1)'

I don't get the error when I add one indicator only.

On an older machine running quantmod 0.4.20 I get this message as a
warning instead of an error.


What causes the error and what is the best practice to plot a chart
(using the new chart_Series) with multiple custom indicators?

Mike



More information about the R-SIG-Finance mailing list