This probably helps (via CBT): http://www.amibroker.com/kb/2006/03/06/re-balancing-open-positions/
PS --- In [email protected], "KBGlenn" <[EMAIL PROTECTED]> wrote: > > Could someone please give me some suggestions on how I might > accomplish the following: > > - Establish a basket of stocks (I can do this) > - Review the basket periodically and determine which meet certain > criteria (I can do this) > - Buy all stocks in the basket that meet the criteria in equal weights > using all available cash (This I can do) > - Somtimes there may be 20 and sometimes there may be 0. However, > with every periodic review I need to rebalance as required. So, for > example, if stocks meeting the criteria went down from 5 to 4 I would > need to purchase additional shares of the 4 remaining on the list. > Alternatively I could go from 4 to 5 and need to trim the prior 4 to > add the fifth stock. (This I can't figure out how to code.) > > Also, would you even use rotational trading for this because you could > own anywhere from zero stocks to every stock on the list depending on > which met/didn't meet the criterion? I suppose I could force sell > everything and simply repurchase each period, but I'd prefer to > backtest the way it would actually be implemented. >
