[R-SIG-Finance] quantmod:indicators with different colors

Jeff Ryan jeff.a.ryan at gmail.com
Fri Jul 17 16:05:02 CEST 2009


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



More information about the R-SIG-Finance mailing list