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

Mayank Singhal msinghal_22 at yahoo.com
Tue Aug 2 05:38:10 CEST 2016


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]]



More information about the R-SIG-Finance mailing list