I've had this question a couple times off group, so I'll post this in case
anyone else needs it.

What's quirky about my package is that a user defined TTR should be a
function whose input is the data and parameters, and whose output is a
string of zeros, ones, and -ones, representing being long, short, or neutral
on the corresponding day / period.

So the following pseudo-code would NOT be acceptable:

yourBADttr <- function (x,params=c(12,26,9),burn=0,short=TRUE)
{
return(MACD(params[1:3]))
}

This would crash the methods in my package.  The following would work.  I
tested it and it runs as expected:

(BEGIN CODE)

library(ttrTests)

x <-
as.vector(getYahooData("SPY",start="20060101",end="20081231")[,"Close"])

yourGOODttr <- function(x,params=c(10,21,7,1),burn=0,short=TRUE)
{

s <- MACD(x,params[1],params[2],params[3])[,"signal"]
    s[1:26] <- 0
        ## I don't know why but MACD gives NA for the first 26 entries which
is problematic
    pos <-
(ifelse(s>params[4],1,0)+ifelse(s<=(-params[4]),1,0)*ifelse(short,-1,0))
    pos[1:(burn+1)] <- 0
    return(pos)

}
rs <-
returnStats(x,ttr=yourGOODttr,params=c(10,21,7,1),burn=0,short=TRUE,condition=NULL)


(END CODE)

With any such function defined, the methods in my package should work if you
use the name of the function as the ttr argument with no quotes.

In the future I am thinking about relaxing the ternary restriction on the
position (i.e. fractional or leveraged positions).  I am also looking to
integrate a visual of which days are long/short/neutral based on the TTR
with given parameters into a quantmod chart.  Any parties interested in
working on this, please let me know!  I have been thinking about putting
version 2.0 in pre-production on R-Forge and seeking collaborators, I just
haven't gotten around to doing it.

Cheers,
-David

	[[alternative HTML version deleted]]

