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

Jeff Ryan jeff.a.ryan at gmail.com
Fri Nov 28 14:26:36 CET 2008


Hi Brian,

Try version 0.3-7 from CRAN (released last week sometime...)

http://cran.r-project.org/web/packages/quantmod/index.html

Jeff

On Fri, Nov 28, 2008 at 6:28 AM, Brian Lee Yung Rowe <brian at muxspace.com> wrote:
> Hi Jeff,
>
> This sounds promising, but I couldn't get it to work.
>
>> chartSeries(QQQQ)
>> times <- timeBasedSeq('20071001/2007')
>> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333",
>> border=NA)
> Warning message:
> In plot.xy(xy.coords(x, y), type = type, ...) :
>   "border" is not a graphical parameter
>> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333")
> Warning message:
> In plot.xy(xy.coords(x, y), type = type, ...) :
>   "border" is not a graphical parameter
>
> 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.
>
>> chartSeries(QQQQ)
>> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333")
>
> I'm using version 0.3-6 revision 433. Any thoughts on what I'm doing wrong?
>
> Brian
>
>
> ----- Original message -----
> Sent: 2008/11/27 17:58:54
> Subject: Re:Re: [R-SIG-Finance] Shaded regions as an indicator in quantmod
>
> 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 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



-- 
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com



More information about the R-SIG-Finance mailing list