[R-SIG-Finance] Quantstrat - Error while applying strategy

me me at censix.com
Sat May 5 17:20:54 CEST 2012


Dear Bhavna

I had quick look at your code. If you define your T3 function like
this (as Brian has already suggested), the whole thing runs fine (and
fast), as long as you also reduce your 'nseData' to a single column,
i.e. the Close. If you need all OHLC columns then you need to have a
closer look at what their names are and if you use those names
directly in another indicator/signal in your strategy. I remember there
was a tiny bug in quantstrat where the output of indicator or signal
functions would not get renamed as indicated in the 'label' argument.
But then again, maybe this has already been fixed.

nseData <- Cl(nseData)


`T3` <-
function(x, n=3) {

  # T3 indicator

  a <- 0.7
  alpha <- 2/(n+1)
  mavg1  <- EMA(x, n)
  mavg2  <- EMA( mavg1, n )
  mavg3  <- EMA( mavg2, n )
  mavg4  <- EMA( mavg3, n )
  mavg5  <- EMA( mavg4, n )
  mavg6  <- EMA( mavg5, n )
  
  res <-
  -(a*a*a)*mavg6+(3*a*a+3*a*a*a)*mavg5-(6*a*a+3*a+3*a*a*a)*mavg4+(1+3*a+a*a*a+3*a*a)*mavg3

  return(res)
}




Cheers

------------------------------------------------------------------
Soren Wilkening

http://censix.com



More information about the R-SIG-Finance mailing list