[R-SIG-Finance] Using abline with chartSeries

Stergios Marinopoulos stergios_marinopoulos at yahoo.com
Mon Apr 9 19:55:31 CEST 2012


So how can I alter the underlying chartSeries object so that my text annotations will not be lost when the plot has to be re-drawn when I then call add* functions?


Here's how I currently add text to a chart:

chart_Series(SPY)
getSymbols("SPY", from="2012-01-01")

x <- SPY["2012-02-15", which.i=TRUE]

text(x, Lo(SPY)[x,], "2012-02-15", srt=90, c(1,0.5) )



And now when I add this TA the text disappears:

add_TA(Cl(SPY)<134,border=NA,col='#888888',on=-1)
--
sm

Stergios Marinopoulos




> So how is it done?
>
Nearly the same way as I showed you how to add a vertical line to a
chartSeries plot.

chartSeries(IBM.m)
addTA(.xts(rep(160,nrow(IBM.m)),.index(IBM.m)), on=1)



More information about the R-SIG-Finance mailing list