[R-SIG-Finance] Annotations to chart_Series data

Joshua Ulrich josh.m.ulrich at gmail.com
Mon Apr 23 16:46:49 CEST 2012


Gordon,

On Mon, Apr 23, 2012 at 9:05 AM, Gordon Erlebacher
<gordon.erlebach at gmail.com> wrote:
> Thanks Brian. I am surprised that each call to add_* rerenders. What
> command actually does the rerendering? Isn't it possible to rewrite the
> functions so that commands accumulate and rendering is done only once? R is
> already an inefficient language (everything is done via copies as opposed
> to references), and rerendering multiple times slows everything down
> further and likely unnecessarily.
>
> Thanks,
>   Gordon
>
Use the TA= argument to chart_Series to add to the plot without
rendering.  For example:
# use this
chart_Series(SPY, TA="add_SMA(50); add_SMA(200)")
# instead of this
chart_Series(SPY); add_SMA(50); add_SMA(200)

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com

R/Finance 2012: Applied Finance with R
www.RinFinance.com


> On Mon, Apr 23, 2012 at 9:23 AM, Brian G. Peterson <brian at braverock.com>wrote:
>
>> On Mon, 2012-04-23 at 09:02 -0400, Gordon Erlebacher wrote:
>> > However, if I add the stochastic chart using "add_TA" (uncomment two
>> > lines in the above code), my text annotations disappear. Of course, I
>> > could probably create a special function to add them, similar to what
>> > is done with add_SMA, but is there another way?
>> >
>> You need to either let the chob object know about your chart layer as
>> the add_* functions do, or you need to put your text or other overlays
>> on the chart *last*.
>>
>> Each call to add_* function will rerender the chart, using the
>> information stored in the chob.  So, if you don't want to work wit hthe
>> chob, your overlay needs to be added later.
>>
>> Regards,
>>
>>  - Brian
>> >
>> --
>> Brian G. Peterson
>> http://braverock.com/brian/
>> Ph: 773-459-4973
>> IM: bgpbraverock
>>
>>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list