Thanks Graham The values in vaLimitEntry had already been rounded.
For the first trade the values (as per _TRACE) are vaLimitEntry - $11.59, Open - $11.36. I cannot fathom the origin of 11.1357 that is in the backtest report for open price, and it is also odd that it is 4 decimal places. Additionally, the position size for this trade is virtually double what it should be - and then the 2nd & 3rd trades do not have any errors. Cheers Graham > > You have BuyPrice = Min(Open, Ref(vaLimitEntry, -1));, so can only > assume that in this case Open is higher than the vaLimitEntry value, > and thus vaLimitEntry is used. > To get this rounded to correct tick prices then you need to round the > vaLimitEntry, either up(ceil), down(floor) or closest(round) tick > eg something like this rounding up to higher round tick price level > ticksize = 0.01; > BuyPrice = Min(Open, Ceil( Ref(vaLimitEntry, -1) / ticksize ) * ticksize ); > > The actual trade size in backtest uses the roundlotsize, default is 1, > so the trade will buy whole shares as happens in normal equity > markets. If you trade funds then typically define roundlotsize=0; > which allows part shares and trade size to equal the dollars required. > > > -- > Cheers > Graham Kav > AFL Writing Service > http://www.aflwriting.com > > > On 02/01/2008, Graham Johnson <[EMAIL PROTECTED]> wrote: > > As part of the migration process from Wealth-Lab, I've been running > > some parallel backtesting. > > > > Symbol currently used is JBH(ASX) for period 01/07/2007 to 31/12/2007. > > > > Both AB & WLD open long trades on 26/07/2007, 13/11/2007 & > > 19/12/2007, and the exit dates match. > > > > The 2nd & 3rd trades have matching Entry & Exit Prices and the > > position sizes are within tolerance. > > > > Trade for 26/07/2007 is the problem, the AB report shows entry price > > $11.1357 and Position Size of $19988.60, whereas it should have been > > $11.36 and $10000.00. > > > > I've been using _TRACE to follow the calculations and the logic > > appears to be correct so, ther must be something that I haven't got > > quite right. Any ideas, please? > > > > The relevant code is > > //================== Position Size ================== > > vMaxPosn = 10000; > > vMaxRisk = 2000; > > vMaxTOPc = 3; > > vaPosnSize = vMaxRisk / Ref(vaIStopVal, -1) * Ref(vaLimitEntry, - 1); > > vaPosnSize = Min(vaPosnSize, vMaxPosn); > > vaPosnSize = Min(vaPosnSize, Ref(vaAvgTO, -1) * vMaxTOPc / 100); > > SetPositionSize(vaPosnSize, spsValue); > > //_TRACE("Position Size: " + vaPosnSize); > > > > //================== Trade ================== > > Buy = Ref(vaValidEntry,-1) AND Low <= Ref(vaLimitEntry, -1); > > Buy = IIf(Buy, sigScaleIn, 0); // allow pyramidding, recorded as one > > position > > BuyPrice = Min(Open, Ref(vaLimitEntry, -1)); > > //_TRACE("Open: " + Open + " | Limit Entry: " + Ref (vaLimitEntry, -1) > > + " | Buy Price: " + BuyPrice + " | T/O: " + Ref(vaAvgTO, -1) + " | > > PosnSize: " + VaPosnSize); >
