[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Please help with sector then stock afl



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "bean_pi314" <gkjw@xxx> 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
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/