<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.1">
</HEAD>
<BODY>
<FONT COLOR="#000000">Hi Jeff,</FONT><BR>
<BR>
<FONT COLOR="#000000">This sounds promising, but I couldn't get it to work. </FONT><BR>
<BR>
<FONT COLOR="#000000">> chartSeries(QQQQ)</FONT><BR>
<FONT COLOR="#000000">> times <- timeBasedSeq('20071001/2007')</FONT><BR>
<FONT COLOR="#000000">> </FONT>addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333", border=NA)<BR>
<FONT COLOR="#000000">Warning message:</FONT><BR>
<FONT COLOR="#000000">In plot.xy(xy.coords(x, y), type = type, ...) :</FONT><BR>
<FONT COLOR="#000000"> "border" is not a graphical parameter</FONT><BR>
<FONT COLOR="#000000">> </FONT>addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333")<BR>
<FONT COLOR="#000000">Warning message:</FONT><BR>
<FONT COLOR="#000000">In plot.xy(xy.coords(x, y), type = type, ...) :</FONT><BR>
<FONT COLOR="#000000"> "border" is not a graphical parameter</FONT><BR>
<BR>
<FONT COLOR="#000000">Re-executing the sequence without the border parameter removes the error message, but I don't see any bars. The series name does appear in the legend area, though.</FONT><BR>
<BR>
<FONT COLOR="#000000">> chartSeries(QQQQ)</FONT><BR>
<FONT COLOR="#000000">> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333")</FONT><BR>
<BR>
<FONT COLOR="#000000">I'm using version 0.3-6 revision 433. Any thoughts on what I'm doing wrong?</FONT><BR>
<BR>
<FONT COLOR="#000000">Brian</FONT><BR>
<BR>
<BR>
----- Original message ----- <BR>
Sent: 2008/11/27 17:58:54 <BR>
Subject: Re:Re: [R-SIG-Finance] Shaded regions as an indicator in quantmod <BR>
<BR>
quantmod can do this now as well: <BR>
<BR>
If addTA is passed a logical vector of the same length as your series <BR>
or passed an ?xtsible object of any length it will cause bands to be <BR>
drawn. Points in the vector/time that are TRUE will be cause event <BR>
blocks to be drawn on/under the series. <BR>
<BR>
An example: <BR>
<BR>
> library(quantmod) <BR>
> chartSeries(QQQQ) <BR>
> times <- timeBasedSeq(20071001/2007) # create a Date sequence from 2007-10-01 to 2007-12-31 <BR>
> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333", border=NA) <BR>
<BR>
A few comments about 'addTA': <BR>
<BR>
1) the 'on' argument which plot you want it drawn on. Starting with <BR>
the main series window=1. Negative values cause the values to be drawn <BR>
under the main graphics. <BR>
<BR>
2) 'col' and 'border' are arguments to the 'rect' call internal, which <BR>
draws the bands underneath. <BR>
<BR>
See ?addTA for further details. <BR>
<BR>
HTH <BR>
Jeff <BR>
<BR>
<BR>
<BR>
<BR>
On Thu, Nov 27, 2008 at 11:24 AM, Eric Zivot wrote: <BR>
> You can use the chart.TimeSeries() function in the package <BR>
> PerformanceAnalytics to do this very easily. See the examples in the help <BR>
> file for adding shading to user defined event times. <BR>
> ez <BR>
> <BR>
> _____ <BR>
> <BR>
> From: r-sig-finance-bounces@stat.math.ethz.ch <BR>
> [mailto:r-sig-finance-bounces@stat.math.ethz.ch] On Behalf Of Brian Lee Yung <BR>
> Rowe <BR>
> Sent: Thursday, November 27, 2008 9:19 AM <BR>
> To: r-sig-finance@stat.math.ethz.ch <BR>
> Subject: [R-SIG-Finance] Shaded regions as an indicator in quantmod <BR>
> <BR>
> <BR>
> Hi, <BR>
> <BR>
> I want to produce charts using quantmod similar to the ones available from <BR>
> FRED. Specifically, FRED has this handy feature of rendering the <BR>
> NBER-defined recession periods under the displayed time series. <BR>
> <BR>
> It seems like calling newTA with the appropriate function handle could <BR>
> produce the output necessary to define the shading bars, but I'm not sure if <BR>
> any of the existing charting types can generate the correct look and feel. <BR>
> Anybody have suggestions? <BR>
> <BR>
> Thanks, <BR>
> Brian <BR>
> <BR>
> [[alternative HTML version deleted]] <BR>
> <BR>
> _______________________________________________ <BR>
> R-SIG-Finance@stat.math.ethz.ch mailing list <BR>
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance <BR>
> -- Subscriber-posting only. <BR>
> -- If you want to post, subscribe first. <BR>
> <BR>
<BR>
<BR>
<BR>
-- <BR>
Jeffrey Ryan <BR>
jeffrey.ryan@insightalgo.com <BR>
<BR>
ia: insight algorithmics <BR>
www.insightalgo.com
</BODY>
</HTML>