Hello:

I have been trying to figure out how to write an AFL to backtest a method that 
(1) selects the strongest sector based on RS or a similar metric and then (2) 
select the strongest stock within the strongest sector.

I think sector proxies may be created using addtocomposite().  However, I'm not 
sure how to then rank just the sectors.  Worse, once this is done I have no 
idea how to accomplish step (2), picking the strongest stock within that 
sector, using AFL.

pseudo code might look something like:

//select the strongest sector
for i = 1 to N_Sector
 if sector is strongest over past week then
 strongest_sector = sector(i)
next i

//select the strongest stock within strongest sector
for j = 1 to N_Stocks_in_Sector(i)
   if stock is strongest over past week then
   strongest_stock = stock(j)
next j

buy strongest stock in strongest sector (stock(j))

Is it possible to write these types of loops in AFL (for backtesting)?  If so, 
is it possible to have logic based on a sector attribute?

Any help or example code to point me in the right direction would be greatly 
appreciated.

Many thanks!
Greg



Reply via email to