Hello, I started using quanstrat recently, and must say the design is impressive.<div><br></div><div>My first goal is to back test a strategy on daily data, but it quickly became apparent that I will need to do some work prior to that. First and foremost, I will need to modify quanstrat to execute the orders on the end of day, i.e. the same bar. To achieve that I decided to familiarize myself with the code and I am having problems figuring out the intended design even for monthly data.<div>
<br></div><div>According to ruleOrderProc.R, it seems that for monthly time series, the trading should occur at the same bar that the signal was triggered (both on Close at the end of month), right? If so, my 10-month SMA test which is attached is contradictory - looking at the market data and the trades, it seems that the orders are executed at the end of the next month instead. More specifically (from ruleOrderProc.R):</div>
<div><br></div><div><div>                                yearly = , </div><div>                                quarterly = , </div><div>                                monthly = { </div><div>                                    txntime=as.character(index(ordersubset[ii,])) # transacts on this bar, e.g. in the intraday cross, or leading into the end of month, quarter, etc.</div>
<div>                                    # txntime=as.character(timestamp) # use this if you wanted to transact on the close of the next bar</div><div>                                    txnprice=as.numeric(getPrice(mktdataTimestamp, prefer=prefer)[,1])</div>
<div>                                }, #end</div></div><div><br></div><div>When this code is entered, mktdataTimestamp is on the next bar and it delivers the price. Is this an issue, or I am missing something?</div><div>
<br></div><div>While on the topic, would you object adding the functionality (under a flag) to execute trades on the same bar (of course, if it's feasible - i will try to do the implementation)? I managed to achieve similar functionality by lagging the indicator backwards, but that seems like a hack, and I am suspicious that it may have issues with stoplimit and trailing stops.</div>
<div><br></div><div>Thanks in advance,</div><div>Ivan</div></div>