PureBytes Links
Trading Reference Links
|
You need to actually check how many open positions you have after the
exits and thus how many new trades you need to enter. You can do this
with openpos loop
Then use bo.Cash to determine the position size for the new entries
--
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com
On 01/02/2008, vlanschot <vlanschot@xxxxxxxxx> wrote:
> Thanks Graham,
>
> A follow-up question if I may.
>
> Indeed, in my CBT-loops, I first execute the exits, and keep track of
> the number of exits. Based on this, and after bo.UpdateStats, I've
> added the following:
>
> (FYI: Cash = bo.Cash Eq = bo.Equity)
>
> if (bar>1) NewPosSize = Nz((Kas[bar]/numExits)/Eq[bar],
> MaxOpenPos/100);
> else NewPosSize = MaxOpenPos/100 ;
>
> LongPS = ShortPS = -NewPosSize*100;
>
> I then run through my entry signals.
>
> In other words, I assume the CBT re-calculates the cash amount after
> exits, which I subsequently divide evenly over the potential new
> positions.
>
> However, for some reason I end up with less than 50 positions (my
> MaxOpenPos) at the end of the backtest. Whereas if I "delete" the
> above code, I do end up with 50 positions, but then with too much
> cash occassionally. Iow, the system generates enough valid signals to
> fill any exits.
>
> Any clarification appreciated, although I realize I'm not giving you
> much detail.
>
> PS
>
> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxx> wrote:
> >
> > In advanced backtest code you exit the trades, update the values,
> then
> > enter signals with amended posSize
> >
> > --
> > Cheers
> > Graham Kav
> > AFL Writing Service
> > http://www.aflwriting.com
> >
> >
> > On 01/02/2008, vlanschot <vlanschot@xxx> wrote:
> > > Perhaps somebody has a straightforward way to solve the
> following, or
> > > point out the error in my interpretation of AFL/CBT:
> > >
> > > My system keeps a constant number of 50 positions, based on a
> ranking
> > > (although I do not use rotational trading.) At the start the
> > > positions are equally weighted, i.e. PositionSize is defined as
> 2%.
> > > As time moves on, some do very well, and reach, say, a weight of
> 3%
> > > of equity. When the exit signal arrives, these positions are
> replaced
> > > by new ones, but now back to the 2% of equity as defined in
> > > PositionSize.
> > >
> > > The resulting problem is that at times I find I have too much cash
> > > left. Now, I know that I can rebalance open positions (by scaling
> > > in/out, for example via TJ's code
> > > http://www.amibroker.com/kb/2006/03/06/re-balancing-open-
> positions/).
> > > However, apart from the extra costs involved, I have found that
> there
> > > is no way to determine/access the amount of cash BEFORE
> > > entering/rebalancing the new positions. In other words, bo.Cash
> gives
> > > you the amount of cash "at the end of the bar". You can, of
> course,
> > > use the amount of cash of the previous bar, but you keep lagging
> the
> > > actual trades.
> > >
> > > In short, I would like to force the backtester to always make the
> > > system fully invested (except for round lots, etc.) It would be
> > > great, for example, if there would be an option to automatically
> > > assign the amount of cash which becomes available from the first
> > > exited trade to the first new trade, etc. In my system this is
> very
> > > applicable, as I always have other trades to replace the exited
> one.
> > >
> > > Any thoughts/suggestions welcome. If none, I'll forward this to
> > > support.
> > >
> > > Thx.
> > >
> > > PS
> > >
> > >
> > >
> > > 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
> > >
> > >
> > >
> > >
> >
>
>
>
>
> 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
>
>
>
>
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/
|