[R-SIG-Finance] Quantstrat - Triggering chain rule with lag period

Ilya Kipnis ilya.kipnis at gmail.com
Tue Aug 2 05:42:47 CEST 2016


You might want to send a minimum reproducible example.

On Mon, Aug 1, 2016 at 11:38 PM, Mayank Singhal via R-SIG-Finance <
r-sig-finance at r-project.org> wrote:

> Hello all,
> Here is what i am trying to achieve : For every entry order (which gets
> filled, note that some might get rejected because of MaxPos criteria), i
> want to exit based on the exit rule (which is based on signal generation)
> or on a second exit rule (which is fixed no. of periods, "n",  from entry)
> depending upon whichever of these two exit criteria is met first.
>
> The result i am getting is : exit rule 2 (fixed no. of periods) triggers
> off the following day from the entry rule and not after desired "n"
> periods. Please if someone can advise - if i am doing something wrong with
> the syntax here ? Below is the code snapshot of rules
> **********************************************************************************eb3
> = TRUE
> #entry rulestrat.st <- add.rule(strat.st,name='ruleSignal',arguments = list( sigcol=c("signal4.gt.zero"),sigval=TRUE,orderqty=1,ordertype='market',orderside='long',prefer="Open",replace=FALSE,threshold=NULL,osFUN=osMaxPos),type='enter',label='enter_long_alpha5c',storefun=FALSE,enabled=eb3,path.dep
> = TRUE)
> #exit rule 1strat.st <- add.rule(strat.st,name='ruleSignal',arguments = list( sigcol=c("signal4.lt.zero"), sigval=TRUE,orderqty='all',ordertype='market',orderside='long',prefer="Open",replace=FALSE,threshold=NULL,osFUN=osMaxPos,orderset='ocolong'),type='exit',
> label='exit_long_alpha5c',storefun=FALSE,enabled=eb3,path.dep = TRUE)
> #exit rule 2 strat.st <- add.rule(strat.st,name='ruleSignal',arguments =
> list(sigcol=c("longExit"),
> sigval=TRUE,orderqty=-1,ordertype='market',orderside='long',prefer="Open",replace=FALSE,
> orderset='ocolong'), type='chain',
> parent='enter_long_alpha5c',label='Sqroff_LONG',enabled=eb3, path.dep =
> TRUE)
> *********************************************************** Note that - in
> exit rule 2 , the sigcol "longexit" is just a "n" period lag on
> "signal4.gt.zero" column
> Any guidance in this regard will be very helpful.
> Regards,Mayank
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> 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]]



More information about the R-SIG-Finance mailing list