[R-SIG-Finance] quantstrat & custom indicators

algotr8der algotr8der at gmail.com
Tue May 3 01:10:05 CEST 2011


I have read through the documentation for quantstrat and gone through some
examples (RSI, MACD, Faber) but am a bit lost as to whether I can creatively
use the features of this package to create a custom indicator as follows:

-I have N securities 
-I want to pass each of those N securities along with N+1 constants to a
user created function called myfunction().
-the user created function myfunction() performs some arithmetic operations
and returns a single time series.

In this example, lets say N = 4

c1 <- 1
c2 <- 2
c3 <- 3
c4 <- 4
c5 <- 5

myStrat <- strategy("myStrat")
myStrat <- add.indicator(strategy = myStrat, name = "myfunction", arguments
= list(symbols[1], symbols[2], symbols[3], symbols[4], c1, c2, c3, c4, c5))

I have tried this and when I call applyStrategy I get multiple errors -

a) c1 is not found
b) when I removed c1-c5 and defined them in myfunction instead, I got:

Error in .Internal(get(x, envir, mode, inherits)) : 'x' is missing

It seems its expecting arguments in the form x=quote(Cl(mktdata)). I'm not
sure I can use that as my argument to myfunction as this user created
function needs to treat each individual time series in a unique way i.e. it
is performing a proprietary arithmetic operation.

Any guidance would be greatly appreciated.





--
View this message in context: http://r.789695.n4.nabble.com/quantstrat-custom-indicators-tp3491259p3491259.html
Sent from the Rmetrics mailing list archive at Nabble.com.



More information about the R-SIG-Finance mailing list