Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: Compare Sectors against Tickers
Author/Uploader: goldfreaz - goldfreaz [at] thelion.com
Date/Time added: 2002-05-09 13:44:50
Origin:
Keywords:
Level: advanced
Flags: exploration

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas.
Description:

Compares relative strength, StochRSI, relative volume, and RSI. Good stocks must be assigned to the right sectors...garbage in / garbage out. Scan the enclosed AFL then set up the indicators that follow.

Formula:

/* SectorRSI swing system
** goldfreaz - 5 May 2002
*/
/* StochRSI  */
Nrsi=14;
Nstoch=17;
Nslow=7;
rrsi=RSI( Nrsi );
Stochrsi=EMA((rrsi-LLV(rrsi,Nstoch))/(HHV(rrsi,Nstoch)-LLV(rrsi,Nstoch)),Nslow);


/* Relative Volume  */
RelVol=EMA(V,3)/ Ref(MA(V,40),-4);

/* Rate of Change  */
xp=0.1*(4.0*(O+C)+H+L);
Chan=EMA(ROC(xp,1),2);


/* RSI  */
Rt=RSI( 14 );
Rmean=IIf(Rt>0.1 AND Rt<99.9,Rt,0);


/*MACD BULL-BEAR*/
Mid=IIf(MarketID(1)=="NYSE" OR MarketID(1)=="Nasdaq",1,0);
ob=Signal(11,23,7)<MACD(11,23);
AddToComposite(IIf(Mid,Ob,0.0),"~macdbullbear","H",7);
AddToComposite(IIf(Mid,NOT(ob),0.0),"~macdbullbear","L",7);

/*  Market Total  */
AddToComposite(IIf(Mid,StochRsi,0.0),"~market","O",7);
AddToComposite(IIf(Mid,Rmean,0.0),"~market","H",7);
AddToComposite(IIf(Mid,Relvol,0.0),"~market","L",7);
AddToComposite(IIf(Mid,Chan,0.0),"~market","C",7);
AddToComposite(IIf(Mid,1,0),"~market","V",7);

sectorname="Healthcare";
AddToComposite(IIf(SectorID(1)==sectorname,StochRsi,0),"~Drug","O",7);
AddToComposite(IIf(SectorID(1)==sectorname,Rmean,0),"~Drug","H",7);
AddToComposite(IIf(SectorID(1)==sectorname,RelVol,0),"~Drug","L",7);
AddToComposite(IIf(SectorID(1)==sectorname,Chan,0),"~Drug","C",7);
AddToComposite(IIf(SectorID(1)==sectorname,1,0),"~Drug","V",7);

sectorname="Financial";
AddToComposite(IIf(SectorID(1)==sectorname,StochRsi,0),"~Bank","O",7);
AddToComposite(IIf(SectorID(1)==sectorname,Rmean,0),"~Bank","H",7);
AddToComposite(IIf(SectorID(1)==sectorname,RelVol,0),"~Bank","L",7);
AddToComposite(IIf(SectorID(1)==sectorname,Chan,0),"~Bank","C",7);
AddToComposite(IIf(SectorID(1)==sectorname,1,0),"~Bank","V",7);

sectorname="Technology";
AddToComposite(IIf(SectorID(1)==sectorname,StochRsi,0),"~techy","O",7);
AddToComposite(IIf(SectorID(1)==sectorname,Rmean,0),"~techy","H",7);
AddToComposite(IIf(SectorID(1)==sectorname,RelVol,0),"~techy","L",7);
AddToComposite(IIf(SectorID(1)==sectorname,Chan,0),"~techy","C",7);
AddToComposite(IIf(SectorID(1)==sectorname,1,0),"~techy","V",7);

sectorname="Basic Materials";
AddToComposite(IIf(SectorID(1)==sectorname,StochRsi,0),"~raw","O",7);
AddToComposite(IIf(SectorID(1)==sectorname,Rmean,0),"~raw","H",7);
AddToComposite(IIf(SectorID(1)==sectorname,RelVol,0),"~raw","L",7);
AddToComposite(IIf(SectorID(1)==sectorname,Chan,0),"~raw","C",7);
AddToComposite(IIf(SectorID(1)==sectorname,1,0),"~raw","V",7);

Buy=0;

Comments:

goldfreaz
goldfreaz [at] thelion.com
2002-05-09 13:48:20
/* Relaive Strength Indicator */
EnableScript("vbscript");
sid=SectorID(1);
<%
Select Case AFL.var("sid")
Case "Healthcare"
Afl.var("sector")="~drug"
Case "Financial"
Afl.var("sector")="~bank"
Case "Technology"
Afl.var("sector")="~techy"
Case "Basic Materials"
Afl.var("sector")="~raw"
Case else
Afl.var("sector")="~market"
end select
%>

/* Rate of Change */
xp=0.1*(4.0*(O+C)+H+L);
Chan=EMA(ROC(xp,1),2);
Schan=Foreign(sector,"C",1)/Foreign(sector,"V",1);
RS=EMA((Chan-Schan),19);

Mchan=Foreign("~market","C",1)/Foreign("~market","V",1);
RM=EMA((Chan-Mchan),19);


Graph0=RS;Graph0Style=1;Graph0Color=7;
Graph1=RM; Graph1Style=1; Graph1Color=17;
goldfreaz
goldfreaz [at] thelion.com
2002-05-09 13:51:54
/* Sector RSI Indicator */
EnableScript("vbscript");
sid=SectorID(1);
<%
Select Case AFL.var("sid")
Case "Healthcare"
Afl.var("sector")="~drug"
Case "Financial"
Afl.var("sector")="~bank"
Case "Technology"
Afl.var("sector")="~techy"
Case "Basic Materials"
Afl.var("sector")="~raw"
Case else
Afl.var("sector")="~market"
end select
%>


rrsi=RSI( 14 );

Srsi=(Foreign(sector,"H",1)/Foreign(sector,"V",1));


Graph0=Rrsi;Graph0Style=1;Graph0Color=11;
Graph1=Srsi; Graph1Style=1; Graph1Color=0;
Title="RSI - "+sid;
goldfreaz
goldfreaz [at] thelion.com
2002-05-09 13:58:15
/* Sector Relative Volume Indicator */
EnableScript("vbscript");
sid=SectorID(1);
<%
Select Case AFL.var("sid")
Case "Healthcare"
Afl.var("sector")="~drug"
Case "Financial"
Afl.var("sector")="~bank"
Case "Technology"
Afl.var("sector")="~techy"
Case "Basic Materials"
Afl.var("sector")="~raw"
Case else
Afl.var("sector")="~market"
end select
%>

Relvol=20*log10( EMA(V,3) / Ref(MA(V,40),-4) );

Srelvol=20*log10(Foreign(sector,"L",1)/Foreign(sector,"V",1));


Graph0=Relvol;Graph0Style=1;Graph0Color=7;
Graph1=Srelvol; Graph1Style=1; Graph1Color=0;
Title="Relative Volume dB - "+sid;
goldfreaz
goldfreaz [at] thelion.com
2002-05-09 14:01:30
/* Sector StochRSI Indicator */
EnableScript("vbscript");
sid=SectorID(1);
<%
Select Case AFL.var("sid")
Case "Healthcare"
Afl.var("sector")="~drug"
Case "Financial"
Afl.var("sector")="~bank"
Case "Technology"
Afl.var("sector")="~techy"
Case "Basic Materials"
Afl.var("sector")="~raw"
Case else
Afl.var("sector")="~market"
end select
%>

/* StochRSI */
Nrsi=14;
Nstoch=17;
Nslow=7;
rrsi=RSI( Nrsi );
Stochrsi=EMA((rrsi-LLV(rrsi,Nstoch))/(HHV(rrsi,Nstoch)-LLV(rrsi,Nstoch)),Nslow);

/* StochRSI for sector */

Sstochrsi=Foreign(sector,"O",1)/Foreign(sector,"V",1);


Graph0=Stochrsi;Graph0Style=1;Graph0Color=3;
Graph1=Sstochrsi; Graph1Style=1; Graph1Color=0;

Title="StochRSI - "+sid;


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM