First of all, I appreciate all the hard works the developers have poured
for this package. Is there anyone who could help me with this?

I have searched this question and got to the following answer provided by
Braverock.
http://r.789695.n4.nabble.com/Parameters-setting-for-multiple-indicators-with-the-same-argument-names-td3793443.html

I tried to follow his recommendation but couldn't get it work. My codes are
as follows. It appears that only the first set of parameters are repeated
over and over. External parameters (shortMA and longMA) don't seem like to
be updated at all.


input_data <- read.csv('mktdata.csv')
EURUSD <- xts(input_data[,3:6], as.POSIXct(input_data[,'Date'], tz='PST',
format='%Y-%m-%d', drop.time=F))
names(EURUSD) <- c("OPEN","HIGH","LOW","CLOSE")

shortMA = 5
longMA = 10

initDate <- as.Date('2000-01-02') - 1

stock.str <- 'EURUSD'
strat.name <- 'MAX'
initEq=1000000

dummy <- initPortf(name=strat.name,symbols=stock.str, initDate=initDate)
dummy <- initAcct(name=strat.name,portfolios=strat.name,
                  initDate=initDate, initEq=initEq)
initOrders(portfolio=strat.name,initDate=initDate)
strat <- strategy(strat.name)

*#indicators:*
strat <- add.indicator(strategy = strat, name = "SMA", arguments =
list(x=quote(Cl(mktdata)), *n=quote(shortMA))*,label= "ma_sn" )
strat <- add.indicator(strategy = strat, name = "SMA", arguments =
list(x=quote(Cl(mktdata)), *n=quote(longMA))*,label= "ma_ln")

# signals:
strat <- add.signal(strategy = strat,name="sigCrossover",
                    arguments = list(columns=c("ma_sn","ma_ln"),
relationship="gte"),
                    label="ma_sn.gt.ma_ln")
strat <- add.signal(strategy = strat,name="sigCrossover",
                    arguments =
list(column=c("ma_sn","ma_ln"),relationship="lt"),
                    label="ma_sn.lt.ma_ln")

# rules:
strat <- add.rule(strategy = strat,name='ruleSignal',
                  arguments = list(sigcol="ma_sn.gt.ma_ln",sigval=TRUE,
orderqty=1000000,
                                   ordertype='market',
orderside='long',pricemethod='market'),type='enter',path.dep=T)
strat <- add.rule(strategy = strat,name='ruleSignal',
                  arguments = list(sigcol="ma_sn.lt.ma_ln",sigval=TRUE,
orderqty=-1000000,
                                   ordertype='market',
orderside='long',pricemethod='market'),type='exit',path.deop=T)


library(PerformanceAnalytics)

ShortM <- c(5,10,15) #,20)
LongM <- c(20, 40) #, 50,60,100)

parm.comb <- expand.grid(ShortM=ShortM,LongM=LongM)
num.opts <- nrow(parm.comb)
res.vec <- rep(NA,num.opts)
res.vec2 <- res.vec


for(i in 1:num.opts) {

  # initialize portfolio and orders
  try(rm(list=ls(pos=.blotter),pos=.blotter),silent=TRUE)
  try(rm(list=ls(pos=.strategy),pos=.strategy),silent=TRUE)
  dummy <- initPortf(name=strat.name,symbols=stock.str, initDate=initDate)
  initOrders(portfolio=strat.name,initDate=initDate)

  # apply strategy
  ShortMA <- parm.comb[i,"ShortM"]
  LongMA <- parm.comb[i,"LongM"]

  if (ShortMA<LongMA) {
    out<-try(applyStrategy(strategy=strat, portfolios=strat.name,
verbose=F, parameters=list(shortMA=ShortMA, longMA= LongMA)))

    # calculate performance matric
    dummy <- updatePortf(Portfolio=strat.name,
Dates=paste('::',as.Date('2012-08-17'),sep=""))

    trading.pl <- getPortfolio(strat.name)$summary$Net.Trading.PL
    rets <- trading.pl/initEq
    omega <- as.numeric(Omega(rets))
    res.vec[i] <- omega

  }
}



--

	[[alternative HTML version deleted]]

