Thanks Joshua. How about an example of a case using add_TA()?

Here is my example, which does not work:

Inside a function ...

=====================================
  sto = stoch(Cl(S))[,2]
  plot(chart_Series(S, TA="add_TA(sto)", theme=my.theme))
=====================================

ERROR:   sto not found.

This has to do with environment context/scope. My knowledge of R is not
sufficient to know which environement to add "sto" to to make this work.
 Any ideas?

   Grodon



On Mon, Apr 23, 2012 at 10:46 AM, Joshua Ulrich <josh.m.ulrich@gmail.com>wrote:

> Gordon,
>
> On Mon, Apr 23, 2012 at 9:05 AM, Gordon Erlebacher
> <gordon.erlebach@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@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@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.
>

	[[alternative HTML version deleted]]

