Change the color of the lines of technical indicators made by R quantmod TTR?

I tried to build a chart using charts in the R-quantum module and add SMI strings using the addSMI () method. SMI generates two lines: the solid line is visible, and the dashed line is not. Can anyone suggest a way to change the color of the dashed line to make it more visible? Here are the codes. I also added the created image.

library(quantmod) x<-getSymbols("IBM", src='yahoo', from="2014-11-20", to="2015-05-20", auto.assign=FALSE) chartSeries(x, name=paste(stockFirmName,"(",stock,")"), line.type = "l", TA=c(addSMI()), theme = chartTheme("white", up.col='red',dn.col="blue"), major.ticks="months", color.vol=FALSE, multi.col = FALSE) title(main="", cex.main=2.5, font.main=4, col.main="gold", sub="", cex.sub=1.5, font.sub=4, col.sub="blue", xlab="", ylab="",col.lab="blue", cex.lab=1) 

See below two lines in the bottom SMI diagram.

! enter image description here

Editing: Robert's method made it work. Here is the latest code and diagram.

 library(quantmod) x<-getSymbols("IBM", src='yahoo', from="2014-11-20", to="2015-05-20", auto.assign=FALSE) chartSeries(x, name=paste("IBM"), line.type = "l", TA=NULL, theme = chartTheme("white", up.col='red',dn.col="blue"), major.ticks="months", color.vol=FALSE, multi.col = FALSE) addTA(SMI(HLC(x)),col=2:3) title(main="", cex.main=2.5, font.main=4, col.main="gold", sub="", cex.sub=1.5, font.sub=4, col.sub="blue", xlab="", ylab="",col.lab="blue", cex.lab=1) 

The graph is as follows. enter image description here

Now the question arises: a chart can be generated by executing line by line. If I "source" the source code in batch mode, the SMI subtitle does not appear at all. Any ideas?

+3
source share
1 answer

Try the following:

 chartSeries(x, name=paste(stockFirmName,"(",stock,")"), line.type = "l", TA=NULL, theme = chartTheme("white", up.col='green',dn.col='red'), major.ticks="months", color.vol=FALSE) addTA(SMI(HLC(x)),col=2:3) 
+1
source

All Articles