<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div id="yiv1482923494"><div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494yui_3_7_2_23_1398322589540_55" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id3783 yiv1482923494yui_3_7_2_23_1398322589540_56" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id3540 yiv1482923494ms__id3784 yiv1482923494yui_3_7_2_23_1398322589540_57" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color:
 rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id779 yiv1482923494ms__id3541 yiv1482923494ms__id3785 yiv1482923494yui_3_7_2_23_1398322589540_58" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id6673 yiv1482923494ms__id780 yiv1482923494ms__id3542 yiv1482923494ms__id3786 yiv1482923494yui_3_7_2_23_1398322589540_59" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id5843 yiv1482923494ms__id6674 yiv1482923494ms__id781 yiv1482923494ms__id3543 yiv1482923494ms__id3787 yiv1482923494yui_3_7_2_23_1398322589540_60" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div
 id="yiv1482923494"><div><div class="yiv1482923494ms__id4976 yiv1482923494ms__id5844 yiv1482923494ms__id6675 yiv1482923494ms__id782 yiv1482923494ms__id3544 yiv1482923494ms__id3788 yiv1482923494yui_3_7_2_23_1398322589540_61" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id2201 yiv1482923494ms__id4977 yiv1482923494ms__id5845 yiv1482923494ms__id6676 yiv1482923494ms__id783 yiv1482923494ms__id3545 yiv1482923494ms__id3789 yiv1482923494yui_3_7_2_23_1398322589540_62" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id1039 yiv1482923494ms__id2202 yiv1482923494ms__id4978 yiv1482923494ms__id5846 yiv1482923494ms__id6677 yiv1482923494ms__id784 yiv1482923494ms__id3546 yiv1482923494ms__id3790
 yiv1482923494yui_3_7_2_23_1398322589540_63" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id9976 yiv1482923494ms__id1040 yiv1482923494ms__id2203 yiv1482923494ms__id4979 yiv1482923494ms__id5847 yiv1482923494ms__id6678 yiv1482923494ms__id785 yiv1482923494ms__id3547 yiv1482923494ms__id3791 yiv1482923494yui_3_7_2_23_1398322589540_64" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id2642 yiv1482923494ms__id9977 yiv1482923494ms__id1041 yiv1482923494ms__id2204 yiv1482923494ms__id4980 yiv1482923494ms__id5848 yiv1482923494ms__id6679  yiv1482923494ms__id786 yiv1482923494ms__id3548 yiv1482923494ms__id3792 yiv1482923494yui_3_7_2_23_1398322589540_65" style="color: rgb(0, 0, 0); font-family:
 arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id3549 yiv1482923494ms__id3793 yiv1482923494yui_3_7_2_23_1398322589540_66" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id788 yiv1482923494ms__id3550 yiv1482923494ms__id3794 yiv1482923494yui_3_7_2_23_1398322589540_67" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div><div class="yiv1482923494ms__id6682 yiv1482923494ms__id789 yiv1482923494ms__id3551 yiv1482923494ms__id3795 yiv1482923494yui_3_7_2_23_1398322589540_68" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div
 id="yiv1482923494"><div><div class="yiv1482923494ms__id5852 yiv1482923494ms__id6683  yiv1482923494ms__id790 yiv1482923494ms__id3552 yiv1482923494ms__id3796 yiv1482923494yui_3_7_2_23_1398322589540_69" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div id="yiv1482923494yui_3_7_2_47_1398249746282_51"><div class="yiv1482923494ms__id791 yiv1482923494ms__id3553 yiv1482923494ms__id3797 yiv1482923494yui_3_7_2_23_1398322589540_70" id="yiv1482923494yui_3_7_2_47_1398249746282_52" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div id="yiv1482923494yui_3_7_2_47_1398249746282_53"><div class="yiv1482923494ms__id677 yiv1482923494ms__id2648 yiv1482923494ms__id9983 yiv1482923494ms__id1047 yiv1482923494ms__id2210 yiv1482923494ms__id4986 yiv1482923494ms__id5854
 yiv1482923494ms__id6685 yiv1482923494ms__id792 yiv1482923494ms__id3554 yiv1482923494ms__id3798 yiv1482923494yui_3_7_2_23_1398322589540_71" id="yiv1482923494yui_3_7_2_47_1398249746282_54" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div id="yiv1482923494yui_3_7_2_47_1398249746282_55"><div class="yiv1482923494ms__id4987 yiv1482923494ms__id5855 yiv1482923494ms__id6686 yiv1482923494ms__id793 yiv1482923494ms__id3555 yiv1482923494ms__id3799 yiv1482923494yui_3_7_2_23_1398322589540_72" id="yiv1482923494yui_3_7_2_47_1398249746282_56" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div id="yiv1482923494yui_3_7_2_47_1398249746282_57"><div class="yiv1482923494yui_3_7_2_23_1398322589540_73" id="yiv1482923494yui_3_7_2_47_1398249746282_58" style="color: rgb(0,
 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div id="yiv1482923494yui_3_7_2_47_1398249746282_59"><div class="yiv1482923494ms__id3801 yiv1482923494yui_3_7_2_23_1398322589540_74" id="yiv1482923494yui_3_7_2_47_1398249746282_60" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color: rgb(255, 255, 255);"><div id="yiv1482923494"><div id="yiv1482923494yui_3_7_2_47_1398249746282_61"><div class="yiv1482923494ms__id2652 yiv1482923494ms__id9987 yiv1482923494ms__id1051 yiv1482923494ms__id2214 yiv1482923494ms__id4990 yiv1482923494ms__id5858 yiv1482923494ms__id6689 yiv1482923494ms__id796 yiv1482923494ms__id3558 yiv1482923494ms__id3802 yiv1482923494yui_3_7_2_23_1398322589540_75" id="yiv1482923494yui_3_7_2_47_1398249746282_62" style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 10pt; background-color:
 rgb(255, 255, 255);"><div id="yiv1482923494yui_3_7_2_54_1398236568429_49"><span id="yiv1482923494yui_3_7_2_47_1398249746282_63"></span></div><div><br></div><div id="yiv1482923494yui_3_7_2_27_1398279131177_50">Hi
 IIya,</div><div id="yiv1482923494yui_3_7_2_27_1398279131177_51"><br></div><div><br></div><div id="yiv1482923494yui_3_7_2_54_1398236568429_66">I
 have run optimizations for GBPUSD 30min data, 3528 (8*21*21)
 combinations. Thereafter, I divided the tradeStats on the nSlowD variable and generated heat-maps & 3D-Graphs for various parameters, viewing lowThresh vs highThresh. Maybe there's a better way of doing this. I have checked the values given via the optimizations with an individual run
 of the strategy and the results equate. Please check?  As of only 10 days of data, the strategy does not generate many trades. It's up to the reader to determine values for nSlowD,
 lowThresh & highThresh given the plethora of graphs; indeed rationale for 'optimal' values along these lines is given on p51-p55  Jaekle & Tomasini (2009). With more data I'd like to do an IS vs OOS test, in addition to a periodic optimized walk-forward, that's for later; of course being mindful of the pitfalls of over-optimization and non-parsimony. </div><div id="yiv1482923494yui_3_7_2_54_1398236568429_61"><br></div><div id="yiv1482923494yui_3_7_2_31_1398249746282_50"><br></div><div id="yiv1482923494yui_3_7_2_54_1398236568429_67">Question:<br></div><div id="yiv1482923494yui_3_7_2_37_1398262446017_50"><br></div><div id="yiv1482923494yui_3_7_2_37_1398262446017_51">(a) Are the inequalities correct with regard to add.distribution ?</div><div id="yiv1482923494yui_3_7_2_23_1398271135197_49"><br></div><div id="yiv1482923494yui_3_7_2_54_1398236568429_60">The
 inequalities in the
 add.distributions for
 the long-only GBPUSD (enter a trade buy GBP sell USD; and to exit a trade sell GBP and buy USD) strategy are:</div><div id="yiv1482923494yui_3_7_2_33_1398262446017_51">slowD.stoch.ind.gt.20</div><div id="yiv1482923494yui_3_7_2_33_1398262446017_52">slowD.stoch.ind.gte.80</div><div id="yiv1482923494yui_3_7_2_37_1398262446017_52"><br></div><div><br></div><div id="yiv1482923494yui_3_7_2_33_1398262446017_56">Likewise, to include a short-side (enter a trade sell GBP buy USD; and to exit a trade buy GBP and sell USD) the add.distributions would be:</div><div id="yiv1482923494yui_3_7_2_33_1398262446017_55">slowD.stoch.ind.lte.20</div><div id="yiv1482923494yui_3_7_2_33_1398262446017_57">slowD.stoch.ind.lt.80</div><div id="yiv1482923494yui_3_7_2_37_1398262446017_53"><br></div><div><br></div><div id="yiv1482923494yui_3_7_2_37_1398262446017_54"><br></div><div id="yiv1482923494yui_3_7_2_54_1398236568429_63">Attached
 are:</div><div id="yiv1482923494yui_3_7_2_54_1398236568429_65">(a) program for calculating the optimizations & generating the graphs. NB: half-way in the program the reader can load the RData tradeStats data and simply generate the graphs not running the optimizations.</div><div id="yiv1482923494yui_3_7_2_39_1398249746282_50">(b) RData file with tradeStats of 3528 optimizations</div><div id="yiv1482923494yui_3_7_2_54_1398236568429_76"><br></div><div><br></div><div id="yiv1482923494yui_3_7_2_54_1398236568429_72">Please check if all is okay with optimizations. If there's a better way of graphing be free to make the improvements.</div><div id="yiv1482923494yui_3_7_2_33_1398262446017_64"><br></div><div id="yiv1482923494yui_3_7_2_33_1398262446017_63"><br></div><div id="yiv1482923494yui_3_7_2_47_1398268778959_50">Thereafter I'd like to get the timefilter optimized. </div><div
 id="yiv1482923494yui_3_7_2_54_1398236568429_73"><br></div><div id="yiv1482923494yui_3_7_2_37_1398262446017_55"><br></div><div><br></div><div id="yiv1482923494yui_3_7_2_54_1398236568429_69">Amarjit</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br id="yiv1482923494yui_3_7_2_54_1398236568429_50"></div>  <div class="yiv1482923494ms__id2215 yiv1482923494ms__id4991 yiv1482923494ms__id5859 yiv1482923494ms__id6690 yiv1482923494ms__id797 yiv1482923494ms__id3559 yiv1482923494ms__id3803 yiv1482923494yui_3_7_2_23_1398322589540_76" id="yiv1482923494yui_3_7_2_54_1398236568429_52" style="font-family: arial, helvetica, sans-serif; font-size: 10pt;"> <div class="yiv1482923494ms__id9989 yiv1482923494ms__id1053 yiv1482923494ms__id2216 yiv1482923494ms__id4992 yiv1482923494ms__id5860 yiv1482923494ms__id6691 yiv1482923494ms__id798 yiv1482923494ms__id3560 yiv1482923494ms__id3804 yiv1482923494yui_3_7_2_23_1398322589540_77"
 style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <div style="margin: 5px 0px; padding: 0px; border: 1px solid rgb(204, 204, 204); border-image: none; height: 0px; line-height: 0; font-size: 0px;"></div> 
 <font face="Arial" size="2"> <b><span style="font-weight: bold;">From:</span></b> amarjit chandhial <a.chandhial@btinternet.com><br> <b><span style="font-weight: bold;">To:</span></b> Ilya Kipnis <ilya.kipnis@gmail.com>;
 "r-sig-finance@r-project.org" <r-sig-finance@r-project.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, 21 April 2014, 8:03<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [R-SIG-Finance] Fw: stochastic oscillator OBOS -
 intraday data & optimization<br> </font> </div> <div class="yiv1482923494y_msg_container"><br><br>Hi IIya,<br><br><br>Have reinstalled quantstrat and I get results! Hooorrraaayyy ;-)<br><br>I will try on GBPUSD, produce graphs, and then try a relevant intraday timefilter with optimization.<br><br><br>Amarjit<br><br> <br><br><br><br><br>________________________________<br> From: Ilya Kipnis <<a href="mailto:ilya.kipnis@gmail.com" target="_blank" rel="nofollow" ymailto="mailto:ilya.kipnis@gmail.com">ilya.kipnis@gmail.com</a>><br>To: amarjit chandhial <<a href="mailto:a.chandhial@btinternet.com" target="_blank" rel="nofollow" ymailto="mailto:a.chandhial@btinternet.com">a.chandhial@btinternet.com</a>>; "<a href="mailto:r-sig-finance@r-project.org" target="_blank" rel="nofollow" ymailto="mailto:r-sig-finance@r-project.org">r-sig-finance@r-project.org</a>" <<a href="mailto:r-sig-finance@r-project.org" target="_blank" rel="nofollow"
 ymailto="mailto:r-sig-finance@r-project.org">r-sig-finance@r-project.org</a>> <br>Sent: Sunday, 20 April 2014, 23:38<br>Subject: Re:
 [R-SIG-Finance] Fw: stochastic oscillator OBOS - intraday data & optimization<br><br><br><br>Amarjit,<br><br>Can you reinstall the quantstrat package and copy and paste the applyStrategy call from inside apply.paramset says?<br><br>Thanks.<br><br>-Ilya<br><br><br>On Sun, Apr 20, 2014 at 2:25 PM, amarjit chandhial <<a href="mailto:a.chandhial@btinternet.com" target="_blank" rel="nofollow" ymailto="mailto:a.chandhial@btinternet.com">a.chandhial@btinternet.com</a>> wrote:<br><br><br>><br>>Hi IIya,<br>><br>><br>><br>><br>>Have run the program as in email and I cannot generate results on either windows or linux. <br>><br>><br>><br>>with <br>><br>><br>><br>>error calling combine function:<br>><simpleError in fun(result.1, result.2, result.3, result.4, result.5, result.6,    <br> result.7, result.8, result.9, result.10, result.11, result.12,     result.13,
 result.14, result.15, result.16,
 result.17, result.18,     result.19, result.20, result.21, result.22, result.23, result.24,     result.25, result.26, result.27, result.28, result.29, result.30,     result.31, result.32, result.33, result.34, result.35, result.36,     result.37, result.38, result.39, result.40, result.41, result.42,     result.43, result.44, result.45, result.46, result.47, result.48,     result.49,<br> result.50): attempt to select less than one element><br>><br>><br>><br>><br>>Have also tried variations on labels e.g. add.distribution component.label="slowD.stoch.ind.gte.80", as the signal is applied in the add.rule.<br>><br>><br>><br>>Here's the packages on linux with rev. <br>><br>><br>><br>>Please
 advise.<br>><br>><br>><br>><br>><br>>Amarjit<br>><br>><br>><br>><br>><br>><br>><br>><br>><br>>R version 3.1.0 (2014-04-10)<br>>Platform:<br> x86_64-pc-linux-gnu (64-bit)<br>><br>>locale:<br>> [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              <br> LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8   <br>> [6] LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_GB.UTF-8       LC_NAME=C                 <br> LC_ADDRESS=C              
 LC_TELEPHONE=C            <br>>[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C      <br>><br>>attached base packages:<br>>[1] stats     graphics  grDevices utils     datasets  methods   base     <br>><br>>other attached packages:<br>> [1] quantstrat_0.8.2 (1598)          foreach_1.4.2 (25)             blotter_0.8.18 (1599)            PerformanceAnalytics_1.1.4 (3362)     FinancialInstrument_1.1.9 (1529)<br>> [6] quantmod_0.4-1 (610)<br>           
 Defaults_1.1-1                  TTR_0.22-0.1 (177)              xts_0.9-7 (803)                                  zoo_1.7-11 (973)               <br>><br>>loaded via a namespace (and not attached):<br>>[1] codetools_0.2-8 grid_3.1.0      iterators_1.0.7 lattice_0.20-29 tools_3.1.0    <br>><br>><br>><br>><br>><br>><br>>From: Ilya Kipnis <<a href="mailto:ilya.kipnis@gmail.com" target="_blank" rel="nofollow" ymailto="mailto:ilya.kipnis@gmail.com">ilya.kipnis@gmail.com</a>><br>>To: amarjit chandhial <<a
 href="mailto:a.chandhial@btinternet.com" target="_blank" rel="nofollow" ymailto="mailto:a.chandhial@btinternet.com">a.chandhial@btinternet.com</a>>; "<a href="mailto:r-sig-finance@r-project.org" target="_blank" rel="nofollow" ymailto="mailto:r-sig-finance@r-project.org">r-sig-finance@r-project.org</a>" <<a href="mailto:r-sig-finance@r-project.org" target="_blank" rel="nofollow" ymailto="mailto:r-sig-finance@r-project.org">r-sig-finance@r-project.org</a>> <br>>Sent: Sunday, 20 April 2014, 3:19<br>>Subject: Re: [R-SIG-Finance] Fw: stochastic oscillator OBOS - intraday data & optimization<br>> <br>><br>><br>>Amarjit,<br>><br>>I got it. While I didn't fix up the GBPUSD demo, I did this using the google demo.<br>><br>>The critical issue is that in order to optimize a component, the component needs a label. The reason you were getting your error (as far as I can deduce) is that you didn't label the indicator, and
 therefore, had no label to which to hook the indicator optimization distribution.<br>><br>>In any case, I've attached the salient
 aspects of the demo to demonstrate.<br>><br>><br>>###INITIAL STRATEGY<br>><br>><br>>library(quantstrat)<br>><br>><br>>osMaxDollar <- function(data, timestamp, orderqty, ordertype, orderside,<br>>                                portfolio, symbol, prefer="Open", tradeSize,<br>>                                maxSize, integerShares=FALSE,<br>>                                ...) {<br>>  pos <- getPosQty(portfolio, symbol, timestamp)<br>>  if(prefer=="Close") {<br>>    price <- as.numeric(Cl(mktdata[timestamp,]))<br>>  } else {<br>>    price <- as.numeric(Op(mktdata[timestamp,]))<br>>  }<br>>  posVal <-
 pos*price<br>>  if (orderside=="short") {<br>>    dollarsToTransact <- max(tradeSize, posVal-maxSize)<br>>  } else {<br>>    dollarsToTransact <- min(tradeSize, maxSize-posVal)<br>>  }<br>>  qty <- dollarsToTransact/price<br>>  if(integerShares) {<br>>    if(qty > 0) {<br>>      qty <- floor(qty)<br>>    } <br>>    if(qty < 0) {<br>>      qty <- ceiling(qty)<br>>    }<br>>  }<br>>  return(qty)<br>>}<br>><br>><br>>rm(list=ls(.blotter), envir=.blotter)<br>>initDate='2000-12-31'<br>>initEq=10000<br>><br>><br>>currency('USD')<br>>Sys.setenv(TZ="UTC")<br>><br>><br>>symbols <- c("USO")<br>><br>><br>>stock(symbols, currency="USD", multiplier=1)<br>>getSymbols(symbols, src='yahoo', <br>>     
      index.class=c("POSIXt","POSIXct"),<br>>           from = "2009-01-01", to="2013-12-31", adjust=TRUE)<br>><br>><br>>strategy.st="GOOGstoch"<br>>portfolio.st="GOOGstoch"<br>>account.st="GOOGstoch"<br>><br>><br>>rm.strat(portfolio.st)<br>>rm.strat(strategy.st)<br>>initPortf(portfolio.st, symbols=symbols, initDate=initDate, currency='USD')<br>>initAcct(account.st, portfolios=portfolio.st, initDate=initDate, currency='USD', initEq=initEq)<br>>initOrders(portfolio.st, initDate=initDate)<br>>strategy(strategy.st, store=TRUE)<br>><br>><br>>################## indicators and parameters ##############<br>><br>><br>>nFastK = 20<br>>nFastD = 3<br>>nSlowD = 5<br>>maType="SMA"<br>>.orderqty=1000<br>>.txn=0<br>><br>><br>>add.indicator(strategy.st, name = "stoch",<br>>              arguments =
 list(HLC = quote(HLC(mktdata)), nFastK=nFastK, <br>>                               nFastD=nFastD,nSlowD=nSlowD, maType=maType),<br>>              label="stoch")  #NOTICE THE LABEL HERE.<br>><br>><br>><br>><br>>################### signals ###################3#######<br>>add.signal(strategy.st, name="sigThreshold",<br>>           arguments = list(threshold=0.20,<br>>                            column="slowD.stoch",<br>>                            relationship="gt",<br>>                            cross=TRUE),<br>>         
  label="slowD.stoch.ind.gt.20")<br>><br>><br>>add.signal(strategy.st,<br>>           name="sigThreshold",<br>>           arguments = list(threshold=0.80,<br>>                            column="slowD.stoch",<br>>                            relationship="lt",<br>>                            cross=TRUE),<br>>           label="slowD.stoch.ind.lt.80")<br>><br>><br>>add.signal(strategy.st,<br>>           name="sigThreshold",<br>>           arguments = list(threshold=0.80,<br>>                     
       column="slowD.stoch",<br>>                            relationship="gte",<br>>                            cross=TRUE),<br>>           label="slowD.stoch.ind.gte.80")<br>><br>><br>>add.signal(strategy.st,<br>>           name="sigThreshold",<br>>           arguments = list(threshold=0.20,<br>>                            column="slowD.stoch",<br>>                            relationship="lte",<br>>                            cross=TRUE),<br>>       
    label="slowD.stoch.ind.lte.20")<br>><br>><br>>################# long rules ########################<br>><br>><br>>add.rule(strategy.st,<br>>         name='ruleSignal',<br>>         arguments = list(sigcol="slowD.stoch.ind.gte.80",<br>>                          sigval=TRUE,<br>>                          orderqty='all',<br>>                          ordertype='market',<br>>                          TxnFees=.txn,<br>>                          orderside='long',<br>>                   
       #pricemethod='market',<br>>                          replace=FALSE),<br>>         label='Exit2SHORT', type='exit', path.dep=TRUE)<br>><br>><br>>stratstoch <- add.rule(strategy.st,<br>>                       name='ruleSignal',<br>>                       arguments = list(sigcol="slowD.stoch.ind.gt.20",<br>>                                        sigval=TRUE,<br>>                                        orderqty=100,<br>>                     
                   ordertype='market',<br>>                                        TxnFees=0, <br>>                                        orderside='long',<br>>                                        #pricemethod='market',<br>>                                        tradeSize=.orderqty,<br>>                                        maxSize=initEq,<br>>           
                             replace=FALSE,<br>>                                        osFUN=osMaxDollar), <br>>                       label='EnterLONG', type='enter', path.dep=TRUE)<br>><br>><br>>############# short rules ##################<br>><br>><br>>#stratstoch <- add.rule(strategy.st,<br>>#                       name='ruleSignal',<br>>#                       arguments = list(sigcol="slowD.stoch.ind.lte.20",<br>>#                                        sigval=TRUE,<br>>#
                                        orderqty='all',<br>>#                                        ordertype='market',<br>>#                                        TxnFees=.txn,<br>>#                                        orderside='short',<br>>#                                        #pricemethod='market',<br>>#                                      
  replace=FALSE),<br>>#                       label='Exit2LONG', type='exit', path.dep=TRUE)<br>><br>><br>>#stratstoch <- add.rule(strategy.st,<br>>#                       name='ruleSignal',<br>>#                       arguments = list(sigcol="slowD.stoch.ind.lt.80",<br>>#                                        sigval=TRUE,<br>>#                                        orderqty=100,<br>>#                                        ordertype='market',<br>>#  
                                      TxnFees=0,  <br>>#                                        orderside='short',<br>>#                                        #pricemethod='market',<br>>#                                        replace=FALSE,<br>>#                                        tradeSize=-.orderqty,<br>>#                                      
  maxSize=initEq,<br>>#                                        osFUN=osMaxDollar),<br>>#                       label='EnterSHORT', type='enter', path.dep=TRUE)<br>><br>><br>>Optimization:<br>><br>><br>>.nSlowD <- seq(from=3, to=10, by=1)<br>>.nLower <- seq(from=.10, to=.30, by=.05)<br>>.nUpper <- seq(from=.70, to=.90, by=.05)<br>>.nsamples = 50<br>><br>><br>>add.distribution(strategy.st,<br>>                 paramset.label="stochDist",<br>>                 component.type='indicator',<br>>                 component.label="stoch", #THE COMPONENT LABEL IS THE LABEL ARGUMENT FROM THE ADD.INDICATOR
 FUNCTION.<br>>                 variable=list(nSlowD=.nSlowD),<br>>                 label="nSlowDdist")<br>><br>><br>>add.distribution(strategy.st,<br>>                 paramset.label="stochDist",<br>>                 component.type="signal",<br>>                 component.label="slowD.stoch.ind.gt.20",<br>>                 variable=list(threshold=.nLower),<br>>                 label="lowThreshDist"<br>>                 )<br>><br>><br>>add.distribution(strategy.st,<br>>               
  paramset.label="stochDist",<br>>                 component.type="signal",<br>>                 component.label="slowD.stoch.ind.lt.80",<br>>                 variable=list(threshold=.nUpper),<br>>                 label="highThreshDist"<br>>)<br>><br>><br>>save.strategy(strategy.st)<br>><br>><br>>require(doMC)<br>>registerDoMC(cores=8)<br>><br>><br>>results <- apply.paramset(strategy.st,<br>>                          paramset.label='stochDist',<br>>                          portfolio.st=portfolio.st,<br>>                       
   account.st=account.st,<br>>                          nsamples = .nsamples,<br>>                          audit = NULL,<br>>                          verbose=TRUE)<br>><br>><br>>print(results$tradeStats)<br>><br>><br>><br>><br>><br>>On Wed, Apr 16, 2014 at 11:41 PM, amarjit chandhial <<a href="mailto:a.chandhial@btinternet.com" target="_blank" rel="nofollow" ymailto="mailto:a.chandhial@btinternet.com">a.chandhial@btinternet.com</a>> wrote:<br>><br>><br>>><br>>><br>>><br>>><br>>><br>>>Can someone provide guidance on getting the optimization
 working.<br>>><br>>><br>>><br>>><br>>>Amarjit<br>>><br>>><br>>><br>>><br>>><br>>><br>>><br>>><br>>>----- Forwarded Message -----<br>>>From: amarjit chandhial <<a href="mailto:a.chandhial@btinternet.com" target="_blank" rel="nofollow" ymailto="mailto:a.chandhial@btinternet.com">a.chandhial@btinternet.com</a>><br>>>To: "<a href="mailto:r-sig-finance@r-project.org" target="_blank" rel="nofollow" ymailto="mailto:r-sig-finance@r-project.org">r-sig-finance@r-project.org</a>" <<a href="mailto:r-sig-finance@r-project.org" target="_blank" rel="nofollow" ymailto="mailto:r-sig-finance@r-project.org">r-sig-finance@r-project.org</a>> <br>>>Sent: Thursday, 10 April 2014, 22:26<br>>>Subject: [R-SIG-Finance] stochastic oscillator OBOS - intraday data & optimization<br>>>
 <br>>><br>>><br>>><br>>><br>>>All,<br>>><br>>><br>>><br>>><br>>>Iiya and I have implemented a
 stochastic oscillator OBOS strategy within quantstrat.<br>>><br>>><br>>>I have then applied quantstrat's intraday GBPUSD data, 30min frequency with the strategy, including transaction costs (as in the other demos).<br>>><br>>><br>>>Thereafter I have attempted to optimize various values e.g.<br>>><br>>><br>>>(i) nSlowD, vary from 1-to-10<br>>>(ii) the lower level (over-sold) vary from .10-to-.30<br>>>(ii) the upper level (over-bought) vary from .70-to-.90<br>>><br>>><br>>><br>>><br>>>I get the error <br>>><br>>><br>>>error calling combine function:<br>>><simpleError in fun(result.1, result.2, result.3, result.4, result.5, result.6, result.7, result.8, result.9,..., result.100):<br> attempt to select less than one element><br>>><br>>><br>>>Attached are both programs: initial strategy and
 optimization.<br>>><br>>><br>>><br>>><br>>><br>>><br>>>An error corresponding to this from last month <a href="http://r-forge.r-project.org/forum/forum.php?set=custom&forum_id=1032&style=nested&max_rows=100&submit=Change+View" target="_blank" rel="nofollow">http://r-forge.r-project.org/forum/forum.php?set=custom&forum_id=1032&style=nested&max_rows=100&submit=Change+View</a><br>>><br>>><br>>><br>>><br>>>Please help!<br>>><br>>><br>>>Amarjit<br>>><br>>><br>>><br>>><br>>><br>>><br>>><br>>><br>>><br>>><br>>>_______________________________________________<br>>><a href="mailto:R-SIG-Finance@r-project.org" target="_blank" rel="nofollow" ymailto="mailto:R-SIG-Finance@r-project.org">R-SIG-Finance@r-project.org</a> mailing list<br>>><a
 href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance" target="_blank" rel="nofollow">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a><br>>>-- Subscriber-posting only. If you want to post, subscribe first.<br>>>-- Also note that this is not the r-help list where general R questions should go.<br>>><br>>><br>>>_______________________________________________<br>>><a href="mailto:R-SIG-Finance@r-project.org" target="_blank" rel="nofollow" ymailto="mailto:R-SIG-Finance@r-project.org">R-SIG-Finance@r-project.org</a> mailing list<br>>><a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance" target="_blank" rel="nofollow">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a><br>>>-- Subscriber-posting only. If you want to post, subscribe first.<br>>>-- Also note that this is not the r-help list where general R questions should go.<br>>><br>><br>><br>><br>   
 [[alternative HTML version deleted]]<br><br><br>_______________________________________________<br><a href="mailto:R-SIG-Finance@r-project.org" target="_blank" rel="nofollow" ymailto="mailto:R-SIG-Finance@r-project.org">R-SIG-Finance@r-project.org</a> mailing list<br><a href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance" target="_blank" rel="nofollow">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a><br>-- Subscriber-posting only. If you want to post, subscribe first.<br>-- Also note that this is not the r-help list where general R questions should go.<br><br></div> </div> </div> 
 </div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></body></html>