[R] abline(h=whatever) not working in candleChart() (in quantmod)?

David Winsemius dwinsemius at comcast.net
Sun Nov 21 20:56:09 CET 2010


On Nov 21, 2010, at 10:50 AM, David L. Van Brunt, Ph.D. wrote:

> Hello, all--
>
> I am having some fun playing with the graphing in quantmod-- very  
> nice! I am
> writing a function to calculate (and hopefully plot) support and  
> resistance
> lines, but the usual plot call of "abline(h=value)" does not seem to  
> work.
> Here's my code:
>
> require(quantmod)
> AAPL<-getYahooData("AAPL")
> candleChart(AAPL,subset="last 3 months",theme="white")
> addMACD()
> abline(h=290,col="red")

Looks to me that chartSeries is an S4 function that works on objects  
of class chob. So try seeing if these widen your perspective :

?"chob-class"
?TA
?newTA

>
>
> The same sequence works fine if I'm just using a plain vanilla  
> "plot" call,
> however.
>
> What am I missing? Do I need to call the line as a technical study  
> using
> addTA?

That's what it looks like from here.

> Not sure how to make a straight line constant doing that...
>
> I'm sure it should be obvious, since my searching on google hasn't  
> turned up
> anything. So I'm getting ready for a "face-palm" moment if anyone  
> can point
> me in the right direction!
>
> ---------------------------------------
> David L. Van Brunt, Ph.D.
> mailto:dlvanbrunt at gmail.com
>
trimmed the irrelevant material from another posting
> .

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list