<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1470064843274_51340"><span id="yui_3_16_0_ym19_1_1470064843274_51775">Sure, please find attached the sample case.</span></div> <div class="qtdSeparateBR" id="yui_3_16_0_ym19_1_1470064843274_51404"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1470064843274_51396" style="display: block;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1470064843274_51395"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1470064843274_51394"> <div dir="ltr" id="yui_3_16_0_ym19_1_1470064843274_51402"><font size="2" face="Arial" id="yui_3_16_0_ym19_1_1470064843274_51401"> On Tuesday, August 2, 2016 9:13 AM, Ilya Kipnis <ilya.kipnis@gmail.com> wrote:<br></font></div>  <br><br> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1470064843274_51393"><div id="yiv0878394286"><div id="yui_3_16_0_ym19_1_1470064843274_51392"><div dir="ltr" id="yui_3_16_0_ym19_1_1470064843274_51398">You might want to send a minimum reproducible example.</div><div class="yiv0878394286gmail_extra" id="yui_3_16_0_ym19_1_1470064843274_51391"><br clear="none"><div class="yiv0878394286yqt5620560861" id="yiv0878394286yqtfd91117"><div class="yiv0878394286gmail_quote" id="yui_3_16_0_ym19_1_1470064843274_51458">On Mon, Aug 1, 2016 at 11:38 PM, Mayank Singhal via R-SIG-Finance <span dir="ltr"><<a rel="nofollow" shape="rect" ymailto="mailto:r-sig-finance@r-project.org" target="_blank" href="mailto:r-sig-finance@r-project.org">r-sig-finance@r-project.org</a>></span> wrote:<br clear="none"><blockquote class="yiv0878394286gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;" id="yui_3_16_0_ym19_1_1470064843274_51457">Hello all,<br clear="none">
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.<br clear="none">
<br clear="none">
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<br clear="none">
**********************************************************************************eb3 = TRUE<br clear="none">
#entry <a rel="nofollow" shape="rect" target="_blank" href="http://rulestrat.st/">rulestrat.st</a> <- add.rule(<a rel="nofollow" shape="rect" target="_blank" href="http://strat.st/">strat.st</a>,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)<br clear="none">
#exit rule <a rel="nofollow" shape="rect" target="_blank" href="http://1strat.st/">1strat.st</a> <- add.rule(<a rel="nofollow" shape="rect" target="_blank" href="http://strat.st/">strat.st</a>,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)<br clear="none">
#exit rule 2 <a rel="nofollow" shape="rect" target="_blank" href="http://strat.st/">strat.st</a> <- add.rule(<a rel="nofollow" shape="rect" target="_blank" href="http://strat.st/">strat.st</a>,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)<br clear="none">
*********************************************************** Note that - in exit rule 2 , the sigcol "longexit" is just a "n" period lag on "signal4.gt.zero" column<br clear="none">
Any guidance in this regard will be very helpful.<br clear="none">
Regards,Mayank<br clear="none">
        [[alternative HTML version deleted]]<br clear="none">
<br clear="none">
_______________________________________________<br clear="none">
<a rel="nofollow" shape="rect" ymailto="mailto:R-SIG-Finance@r-project.org" target="_blank" href="mailto:R-SIG-Finance@r-project.org" id="yui_3_16_0_ym19_1_1470064843274_51855">R-SIG-Finance@r-project.org</a> mailing list<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance" id="yui_3_16_0_ym19_1_1470064843274_51782">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a><br clear="none">
-- Subscriber-posting only. If you want to post, subscribe first.<br clear="none">
-- Also note that this is not the r-help list where general R questions should go.</blockquote></div><br clear="none"></div></div></div></div><br><br></div>  </div> </div>  </div></div></body></html>