[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Erroneous Position Size and Entry Price



PureBytes Links

Trading Reference Links

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





Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/