[R-SIG-Finance] Error when I run the strategy.
Eduardo Romero López
octubre21_2 at hotmail.com
Sun Jun 16 22:56:16 CEST 2013
Hi all,
I am trying to run a strategy very simple.
if Cl() > DonchianChannel(Cl(x), n = xx)[,"mid"]
Open "long"
Close Trailing Stop
but I do not get to do that strategy works. I get this error:
> correr.estrategia <- applyStrategy(
+ strategy=objeto.estrategia,
+ portfolios=mi.estrategia
+ )
Error en function (x, xx) : el argumento(s) no fue utilizado(s) (n = 30)
Además: Mensajes de aviso perdidos
In applyIndicators(strategy = strategy, mktdata = mktdata, parameters =
parameters, :
some arguments stored for f.dc.mid do not match
I am using that code:
mi = as.xts(read.zoo("mini.ibex.csv",
sep="\t", format="%d/%m/%y", header=TRUE))
colnames(mi) <- c("Open", "High", "Low", "Close", "Volume")
tail(mi)
currency("USD")
stock("mi", currency='USD',multiplier=1)
mi.estrategia <- "nombre.estrategia"
initPortf(
mi.estrategia,
'mi',
initDate='1997-12-31'
)
initAcct(
mi.estrategia,
portfolios=mi.estrategia,
initDate='1997-12-31',
initEq=1000
)
initOrders(
portfolio = mi.estrategia,
initDate='1997-12-31'
)
objeto.estrategia <- strategy(mi.estrategia, store=TRUE)
mid= 30
threshold=30
txnfees = -6
orderqty = 1000
summary(objeto.estrategia)
f.dc.mid <- function(x,xx){
a<-DonchianChannel(Cl(x), n = xx)[,"mid"]
return(a)
}
objeto.estrategia <- add.indicator(
strategy = objeto.estrategia,
name = "f.dc.mid",
arguments = list(x = quote(Cl(mktdata)[,1]), n = mid),
label="nmid"
)
summary(objeto.estrategia)
objeto.estrategia <- add.signal(
objeto.estrategia,
name='sigCrossover',
arguments = list(columns=c("Close","nmid"),relationship="gt"),
label='long'
)
summary(objeto.estrategia)
objeto.estrategia <- add.rule(
objeto.estrategia,
name='ruleSignal',
arguments=list(
sigcol='long',
sigval=TRUE,
orderside='long',
ordertype='market',
#prefer='High',
threshold=NULL,
orderqty= orderqty,
replace=FALSE
),
type='enter',
label='EntradaLargo'
)
summary(objeto.estrategia)
objeto.estrategia <- add.rule(
objeto.estrategia,
name='ruleSignal',
arguments = list(
sigcol="long",
sigval=TRUE,
orderqty='all',
ordertype='stoptrailing',
orderside='short',
threshold=-threshold,
tmult=FALSE,
orderset='exitTS'
),
type='chain',
parent='enter',
label='trailingexit')
summary(objeto.estrategia)
correr.estrategia <- applyStrategy(
strategy=objeto.estrategia,
portfolios=mi.estrategia
)
if anyone can help me, thank very much.
Eduardo,
More information about the R-SIG-Finance
mailing list