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

[amibroker] Re: Erroneous Position Size and Entry Price



PureBytes Links

Trading Reference Links

Hi Graham & Dave

I now know what the issue is - it is the amalgamation of two 
consecutive Buy signals.

Now, I can investigate the cause and if I am stuck I will come back 
to the forum.

Thanks

Graham
>
> 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 <grahamj@> 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);
> >
>




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/