I think you are talking about "Industry Groups" rather than Sector, correct me 
if I'm wrong.  Here's the code to make a Composite of the Industries in the 
Industry Group.  Hope it helps.
//Industry Group Composite

sym = "~" + IndustryID(1);
AddToComposite( L, sym,"L",1+2+8+16);
AddToComposite( O, sym,"O",1+2+8+16 );
AddToComposite( H, sym,"H",1+2+8+16 );
AddToComposite( C, sym,"C",1+2+8+16 );
AddToComposite( V, sym, "V",1+2+8+16);
ROC1 = ROC(C,1);
ROC5 = ROC(C,5);
AddTextColumn( FullName(), "FullName" );
AddColumn (Close, "Close",2.2);
AddColumn (C,"RS",4.1);
AddColumn(ROC(C,1),"ROC1",2.2);
AddColumn(ROC(C,5),"ROC5",2.2);
AddColumn(ROC(C,30),"ROC30",2.2);
Buy=Sell=Short=Cover=0;
Filter= Close >0;

Once you do the Composite they will automatically go to Groups 253. You can 
then do exploration to find top Industries.  Then go to the industry group 
involved and find stocks within that industry. Next step would be to screen and 
find strongest stocks.

Dick H.


--- In [email protected], "bean_pi314" <g...@...> wrote:
>
> 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