[R-SIG-Finance] Shaded regions as an indicator in quantmod

Jeff Ryan jeff.a.ryan at gmail.com
Thu Nov 27 23:58:54 CET 2008


quantmod can do this now as well:

If addTA is passed a logical vector of the same length as your series
or passed an ?xtsible object of any length it will cause bands to be
drawn.  Points in the vector/time that are TRUE will be cause event
blocks to be drawn on/under the series.

An example:

> library(quantmod)
> chartSeries(QQQQ)
> times <- timeBasedSeq(20071001/2007)  # create a Date sequence from 2007-10-01 to 2007-12-31
> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333", border=NA)

A few comments about 'addTA':

1) the 'on' argument which plot you want it drawn on.  Starting with
the main series window=1. Negative values cause the values to be drawn
under the main graphics.

2) 'col' and 'border' are arguments to the 'rect' call internal, which
draws the bands underneath.

See ?addTA for further details.

HTH
Jeff




On Thu, Nov 27, 2008 at 11:24 AM, Eric Zivot <ezivot at u.washington.edu> wrote:
> You can use the chart.TimeSeries() function in the package
> PerformanceAnalytics to do this very easily. See the examples in the help
> file for adding shading to user defined event times.
> ez
>
>  _____
>
> From: r-sig-finance-bounces at stat.math.ethz.ch
> [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Brian Lee Yung
> Rowe
> Sent: Thursday, November 27, 2008 9:19 AM
> To: r-sig-finance at stat.math.ethz.ch
> Subject: [R-SIG-Finance] Shaded regions as an indicator in quantmod
>
>
> Hi,
>
> I want to produce charts using quantmod similar to the ones available from
> FRED. Specifically, FRED has this handy feature of rendering the
> NBER-defined recession periods under the displayed time series.
>
> It seems like calling newTA with the appropriate function handle could
> produce the output necessary to define the shading bars, but I'm not sure if
> any of the existing charting types can generate the correct look and feel.
> Anybody have suggestions?
>
> Thanks,
> Brian
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> 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



More information about the R-SIG-Finance mailing list