[R-SIG-Finance] ttrTests cReturns and SMA rule

Research risk2009 at ath.forthnet.gr
Wed Apr 21 16:08:20 CEST 2010


Hi,

I am experimenting with the above mentioned package and the cReturns 
function. When I try to alter the rule from "macd4" as per the example 
to, say, SMA (moving average) I get:


     spData <- 
as.vector(getYahooData("SPY",start="19900101",end="20081231")[,"Close"])
     cr <- cReturns(spData, ttr = "sma", params=c(20))


 > spData <- 
as.vector(getYahooData("SPY",start="19900101",end="20081231")[,"Close"])
 >
 > cr <- cReturns(spData, ttr = "sma", params=c(20))
Error in ind[t - k] <- pos[t - k + 1] - pos[t - k] :
   replacement has length zero
 >

Any clues? Am I doing something wrong?

Thanks in advance,
Costas



More information about the R-SIG-Finance mailing list