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);