[R-SIG-Finance] Using abline with chartSeries

Worik Stanton worik.stanton at gmail.com
Sun Apr 8 05:12:33 CEST 2012


>> I would like to be able to draw vertical lines on a chart resulting from
>> chartSeries.
>>
>> I can draw horrizontal lines but they do not apear in the correct place.
>>
>> In the following example I draw a dotted white horizontal line, but not
>> where I asked for it, and I get no vertical line using either of the two
>> methods.  I cannot find an answer via Google.  I am stumped
>>
[snip]
> chartSeries(IBM.m)
> addTA(.xts(TRUE,.index(IBM.m)[24]), on=1).
That sort of works.  I was hoping to draw one vertical line but I get 
two, and the start and endof the candle.  If I specify a colour it 
overwrites the candle.  But I can use this, thanks very much

But what about horizontal lines?

I tried,
addTA(xts(rep(100, nrow(IBM.m)), index(IBM.m)), on=1)

to no avail.

cheers
W
>> library(quantstrat)
>> getSymbols("IBM")
>> IBM.m<- to.monthly(IBM)
>> chartSeries(IBM.m)
>> abline(h=140, lty=2, col="white")
>> QQ<- index(IBM.m[24,])
>> abline(v=QQ, col="white", lty=2)
>> abline(v=.index(IBM.m[24,]), col="white", lty=2)
>>
> Best,
> --
> Joshua Ulrich  |  FOSS Trading: www.fosstrading.com
>
> R/Finance 2012: Applied Finance with R
> www.RinFinance.com
>


-- 
Foo!



More information about the R-SIG-Finance mailing list