quantmod:indicators with different colors
Good idea. I modified it a bit, then got the effect I want.
library(quantmod)
getSymbols("SBUX")
pos <- which(OpCl(SBUX) > 0)
barChart(SBUX)
addTA(OpCl(SBUX), col=4, type='h', lwd=1)
addTA(OpCl(SBUX)[pos], col=4, type='h', lwd=1,on=3)
addTA(OpCl(SBUX)[-pos], col='red', type='h', lwd=1, on=3)
Thanks. Michael
On Fri, Jul 17, 2009 at 10:05 PM, Jeff Ryan<jeff.a.ryan at gmail.com> wrote:
Try:
library(quantmod)
getSymbols("SBUX")
pos <- which(OpCl(SBUX) > 0)
barChart(SBUX)
addTA(OpCl(SBUX)[pos], col=4, type='h', lwd=1)
addTA(OpCl(SBUX)[-pos]*-1, col='red', type='h', lwd=1, on=3)
HTH,
Jeff
On Fri, Jul 17, 2009 at 5:54 AM, michael li<michaellibeijing at gmail.com> wrote:
Is it possible to plot an indicator with two different colors in quantmod? ?one for positive numbers, and another for negative numbers? Just like the style of addCMF()?
library(quantmod)
getSymbols('SBUX')
barChart(SBUX)
addTA(OpCl(SBUX), col=4, type='h', lwd=2)
The last line plot the indicator in one color only. Thanks. Michael ? ? ? ?[[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
-- Jeffrey Ryan jeffrey.ryan at insightalgo.com ia: insight algorithmics www.insightalgo.com