[R-SIG-Finance] abline for quantmod charts

Jeff Ryan jeff.a.ryan at gmail.com
Tue May 5 20:14:30 CEST 2009


Hi Haky,

wrap addTA with plot().  It is a function of being able to use the
same function from the command line, and embedded in a chartSeries
call.  Internally there is a check to see where it originates from to
take a guess as to draw it immediately or not.

addVLine = function(dtlist)
 {
   plot(addTA(xts( rep(TRUE, NROW(dtlist)), dtlist), on=1, col="#333333"))
 }

HTH
Jeff

On Tue, May 5, 2009 at 12:55 PM, Hae Kyung Im <haky.im at gmail.com> wrote:
> Hi Jeff
>
> I had to change the argument "on" to 1 for it to show the vertical
> line (I have quantmod 0.3-8)
> addTA(xts(TRUE,as.Date("2008-04-01")),on=1,col="#333333")
>
>
> Now I wanted to make it easier to call including the call to a function:
>
> addVLine = function(dtlist)
>  {
>    addTA(xts( rep(TRUE, NROW(dtlist)), dtlist), on=1, col="#333333")
>  }
>
> where dtlist is a vector with datetime type. But when the lines don't
> show up. It does plot the vertical lines when I run the command
> directly but not within the function. This is what I get on the
> command line:
>
>> addVLine(index(data.xmin)[te])
> <chobTA object: addTA>
>
>
> Do you know how to solve this?
>
> Thanks
> Haky
>
>
>
>
> On Thu, Apr 30, 2009 at 4:16 PM, Jeff Ryan <jeff.a.ryan at gmail.com> wrote:
>> Hi Hae,
>>
>> The best way to do this at the moment is with addTA:
>>
>> chartSeries(YHOO)
>> addTA(xts(TRUE,as.Date("2008-04-01")),on=-(1:2),col="#333333")
>>
>> zoomChart('200803/200804')
>>
>> You'll notice that it draws a thick line (region).  This is usually
>> more useful than just a line on quantmod charts, as the spacing is
>> between observations is padded.
>>
>> I will at some point be adding access for primitive graphics function
>> to the whole charting process, but for now this should do what you
>> want.
>>
>>
>> HTH,
>> Jeff
>>
>> On Thu, Apr 30, 2009 at 3:56 PM, Hae Kyung Im <haky.im at gmail.com> wrote:
>>> Hi,
>>>
>>> I was trying to add vertical lines to a quantmod plot using
>>>
>>> abline( v = somdatetime ) like in the following example
>>>
>>>> getSymbols("YHOO")
>>> [1] "YHOO"
>>>> chartSeries(YHOO)
>>>> abline( v=as.POSIXct("2008-04-01","%Y-%m-%d") )
>>>
>>> But nothing shows up on the chart.
>>>
>>> Any ideas on how to do this?
>>>
>>> Thanks
>>> Haky
>>>
>>> _______________________________________________
>>> 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
>>
>



-- 
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com



More information about the R-SIG-Finance mailing list