The Below will work

require(quantstrat)
require(stringr)
rm(list=ls(),envir=.GlobalEnv)
getSymbols("BBVA.MC")
strategy("edu",store=TRUE)
add.indicator('edu','DonchianChannel',arguments=list(quote(cbind(Hi(BBVA.MC
),Lo(BBVA.MC))), n=20))
out <- applyIndicators('edu', BBVA.MC)
tail(out)


Regards,
Deo Jaiswal
Student of R


On Sun, Jun 16, 2013 at 4:56 PM, Eduardo Romero López <
octubre21_2@hotmail.com> wrote:

> 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,
>
> ______________________________**_________________
> R-SIG-Finance@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-sig-finance<https://stat.ethz.ch/mailman/listinfo/r-sig-finance>
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>

	[[alternative HTML version deleted]]

