Hi all,

I would need your help to solve the following problem. I get this error when
I run my code for quantstrat (cf hereunder):
*
Error in do.call(opr, list(data[, colNums[1]], data[, colNums[2]])) :
  'what' must be a character string or a function*

I would really appreciate your help.
Maybe two comments regarding my code:

   - the aim is to have an indicator that can take different values, for
   example -2,-1,0,1,2 (currently only -1,0,1 are implemented). And according
   to this indicator, I would like to have a position of Indicator*100 shares
   (hence the maybe too complicated "minusOne", "minusZero", etc episode). Any
   suggestion to improve my not-so-elegant solution is welcome.
   - I actually first started to implement and test my strategies with
   blotter. But, as it is rather slow in terms of testing, I decided to
   transfer my Indicator into the quantstrat environment. So if there is an
   easy solution to transfer "blotter"-code into "quantstrat"-code, this would
   be the best solution for me (or any other way to speed things up with
   blotter).

Again, thank you very much for your help, you're doing a great job with this
forum.

And this is the code that generates the error mentioned above (as you might
easily notice, I am not exactly a "professional" R-user...):

*require(quantstrat)

try(rm("order_book.Test",pos=.strategy),silent=TRUE)
try(rm("account.Test","portfolio.Test",pos=.blotter),silent=TRUE)
try(rm("Test","Test","symbols","stratTest","initDate","initEq","endDate",'start_t','end_t'),silent=TRUE)
rm(list=ls(envir=.blotter),envir=.blotter)


#Initiate Portfolio guidelines
initDate='2007-11-01'
endDate='2010-11-30'
initEq=1000000
currency("USD")

#Define variables
parameter1 = 50  # number of periods for EMA

#Define Indicator
Indicator<-function(Data,Parameter1) {
    intermediaryResult<-Data-EMA(Data,Parameter1)
    intermediaryResult<-sign(intermediaryResult)
    result<-intermediaryResult
    Indicator<-result
    }

#Prepare mktdata
stock("AAPL",currency="USD",multiplier=1)
symbols=c("AAPL")
getSymbols(symbols, from=initDate, to=endDate,
index.class=c("POSIXt","POSIXct"))
AAPL = adjustOHLC(AAPL)
AAPL$Indicator<-Indicator(Cl(AAPL),parameter1)
AAPL$Indicator[parameter1-1]<-0
AAPL$minusOne<--1.1
AAPL$minusZero<--0.1
AAPL$plusZero<-0.1
AAPL$plusOne<-1.1
initPortf("Test", symbols=symbols, initDate=initDate)
initAcct("Test",portfolios="Test", initDate=initDate,initEq=initEq)
initOrders(portfolio="Test",initDate=initDate)


#Strategy definition
stratTest <- strategy("Test")

stratTest <- add.indicator(strategy = stratTest, name = "Indicator",
arguments = list(Data=quote(Cl(mktdata)), Parameter1=parameter1) )

stratTest <- add.signal(strategy = stratTest,name="sigCrossover",arguments =
list(column=c("minusOne","minusZero","Indicator"),relationship="op"),label="signal.sell1")
stratTest <- add.signal(strategy = stratTest,name="sigCrossover",arguments =
list(column=c("minusZero","plusZero","Indicator"),relationship="op"),label="signal.neutral")
stratTest <- add.signal(strategy = stratTest,name="sigCrossover",arguments =
list(column=c("plusZero","plusOne","Indicator"),relationship="op"),label="signal.buy1")

#Rules
stratTest <- add.rule(strategy = stratTest,name='ruleSignal', arguments =
list(sigcol="signal.sell1",sigval=TRUE, orderqty=-100, ordertype='market',
orderside='short', threshold=NULL),type='enter')
stratTest <- add.rule(strategy = stratTest,name='ruleSignal', arguments =
list(sigcol="signal.neutral",sigval=TRUE, orderqty=all, ordertype='market',
orderside='short', threshold=NULL),type='exit')

stratTest <- add.rule(strategy = stratTest,name='ruleSignal', arguments =
list(sigcol="signal.buy1",sigval=TRUE, orderqty=100, ordertype='market',
orderside='long', threshold=NULL),type='enter')
stratTest <- add.rule(strategy = stratTest,name='ruleSignal', arguments =
list(sigcol="signal.neutral",sigval=TRUE, orderqty=all, ordertype='market',
orderside='long', threshold=NULL),type='exit')


out<-try(applyStrategy(strategy=stratTest , portfolios="Test"))*


Many thanks,

Emanuel

	[[alternative HTML version deleted]]

