BGPL --
The 'elegant' and perhaps 'preferred' way to solve your problem is
probably to use the CBT to do all the work.
However, two possible ideas for "quick and dirty" or for "proof of
concept" might be:
1. Use two different .afl programs.
The first does a Backtest with Buy/Sell based on 'n' only. That
produces a list of all potential trades, which you export to a .csv
file. Import .csv file into a spread sheet, convert to a list that
looks something like this:
Date Symbol Close
06/01/10 AAPL_A 1
06/03/10 AAPL_A -1
etc.
where AAPL_A differentiates it from AAPL and Close of 1 means buy and
Close of -1 means sell. Save result as a new .csv file.
Next ASCII import new .csv file into your data base.
Use second .afl program containing code something like this:
PositionScore = m;
sym = Name() + "_A";
Buy = IIf(Nz(Foreign(sym, "C")) == 1, True, False);
Sell = IIf(Nz(Foreign(sym, "C")) == -1, True, False);
2. Similar to 1. above, except that, using only one .afl, you add a
metric 'm' to be add to backtest results (using CBT, high-level).
Export results as .csv file and import into spread sheet, and sort and
select trades based on the metric 'm'.
I would very much like to know how you make out. I am facing the same
problem, but have put it on my own "back burner". I would probably opt
for 2. above, in that my present strategy trades all common stocks,
ADRs, and ETFs, and I would rather not double my data base size.
-- Keith
On 7/6/2010 18:55, bgplmirror wrote:
Greetings,
I use AB quite a bit, but now am trying to use this for some
additional systems currently running in wealth-lab.
Is there a simple way to handle two factor models where for example, i
want to first rank n stocks using a first factor (same as the
positionscore in AB), pick the top n, and use a second factor to rank
the top m (out of the top n).
I can see that I could potentially do it using
(a) positionscore to do the first sort and rank
(b) the custom backtester and writing a sort among the top-n positions
with the second factor to get the new top-m. To do this, I have to
probably use static variables to keep track of the new sorted rank
(second sort).
However, before embarking on this exercise, I wanted to throw it out
to the users on this forums to see if you have this problem, or seen
solutions etc., I spent some time going over the past posts, but could
not find something like this.
regards
bgpl