I know this issue has been raised before but was unable to find the right
solution. When I am trying to do addTA to a chartSeries plot, from inside a
function, it expects the arguments of addTA to be in the .GlobalEnv. Even
after wrapping the chartSeries call inside plot(), it does not work.
Following is a simple code:

*
*
*require(xts)*
*require(quantmod)*
*
*
*getSymbols('YHOO')*
*
*
*## It works fine when charting it in the GlobalEnv*
*#YHOO$MA <- rollmean(YHOO$YHOO.Close, k=50, align='right')*
*#YHOO <- na.omit(YHOO)*
*#chartSeries(YHOO, TA="addTA(YHOO$MA, col='blue', on=1)",
theme=chartTheme('white'))*
*
*
*fn_plotYHOO <- function(Data){*
*  Data$MA <- rollmean(Data$YHOO.Close, k=50, align='right')*
*  Data <- na.omit(Data)*
*  #View(Data)*
*  plot(chartSeries(Data, TA="addTA(Data$MA, col='blue', on=1)",
theme=chartTheme('white')))*
*}*
*
*
*fn_plotYHOO(Data=YHOO)*

*Error in plot(chartSeries(Data, TA = "addTA(Data$MA, col='blue', on=1)",  :
  error in evaluating the argument 'x' in selecting a method for
function 'plot': Error in addTA(Data$MA, col = "blue", on = 1) :
object 'Data' not found*



Could anyone please help me resolve this? I dont want to assign all objects
to the Global environment.
Thanks,
-Nandi


-- 
I'm a great believer in luck, and I find the harder I work the more I have
of it.  ~Thomas Jefferson

Subhrangshu Nandi
Algorithmic Stat-Arb Trader

	[[alternative HTML version deleted]]

