[R-SIG-Finance] Problems with chartSeries when called in a function

Worik Stanton worik.stanton at gmail.com
Sun Apr 1 01:35:26 CEST 2012


Friends

I have the following sequence of commands that work as expected....

   S <- getSymbols("USD/NZD", src="oanda", auto.assign=FALSE)
   NZD.w <- to.weekly(S)
   chartSeries(NZD.w)
   po <- EMA(NZD.w)
   addTA(po)
   addCCI(n=14)

(I know I could use addEMA but I have some signal code that would be 
meaningless here in this context)


I get a three part graph:  The series as a candlestick chart and the two 
indicators each in a panel

If I use a function...


test <- function(PAIR="USD/NZD"){

   ## This function is different if called than if stepped through
   S <- getSymbols(PAIR, src="oanda", auto.assign=FALSE)
   NZD.w <- to.weekly(S)
   chartSeries(NZD.w)
   po <- EMA(NZD.w)
   addTA(po)
   addCCI(n=14)
}


and call test() I get a two part graph.

Why is it different?

cheers
Worik

-- 
Foo!



More information about the R-SIG-Finance mailing list