Skip to main content

Breadth Indicator for Amibroker (AFL)

mmore over 8 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 1)
  • Tags:
    amibroker, composite, breadth

30% up/down last quarter in the Russell 3000 index. Modified to not use ‘IsIndexConstituent’ which is a norgate data specific function.

It’s a two step process. You must do a scan every day, or as frequently as you want accurate data, with the exploration formula on a watch list of the russell 3000 members. Once the exploration formula is run it will create a bunch of composites (Check the code). You can then use the diffusion indicator code.

Created By: money matt for more information visit his site here

Indicator / Formula

Copy & Paste Friendly
thresh1=Param("buy thresh",75,1,99,1); 
thresh2=Param("sell thresh",75,1,99,1); 
Ticker1 = ParamStr("Symbol1", "~POS30QTR" ); 
Ticker2 = ParamStr("Symbol2", "~NEG30QTR" ); 
flgrng=Param("threshold count",10,1,50,1); 
 
t1=Foreign(Ticker1,"C"); 
t2=Foreign(TIcker2,"C"); 
dif=t1/(t1+t2)*100; 
flgon=Sum(dif>thresh1,flgrng)==flgrng; 
flgoff=Sum(dif<thresh2,flgrng)==flgrng; 
 

Plot(dif,"Diffusion",colorTeal,styleLine|styleThick); 
Plot(thresh1,"",colorGreen); 
Plot(thresh2,"",colorRed); 
 
Plot(flgon*100,"Buy",colorGreen,styleHistogram|styleThick); 
Plot(flgoff*100,"Sell",colorRed,styleHistogram|styleThick); 
Copy & Paste Friendly

Run this exploration on a watchlist of the russel 3000 stocks before using the indicator.

AddToComposite(C/LLV(C,60)>=1.3,"~POS30QTR","X",19);
AddToComposite(C/HHV(C,60)<=.7,"~NEG30QTR","X",19);

// above is the breadth measurement that showed the most promise.
//You could comment out all the other indicators and
//possibly speed things up.

AddToComposite(C/Ref(C,-1)>=1.04,"~POS4DAILY","X",19);
AddToComposite(C/Ref(C,-1)<=.96,"~NEG4DAILY","X",19);
AddToComposite(C/LLV(C,20)>=1.2,"~POS20MO","X",19);
AddToComposite(C/HHV(C,20)<=.8,"~NEG20MO","X",19);
AddToComposite(L==LLV(L,60),"~NEWLOW60","X",19);
AddToComposite(H==HHV(H,60),"~NEWHI60","X",19);




myrsi=RSI(2);
AddToComposite(myrsi<10,"~LO_RSI_COMP","X",19);
AddToComposite(myrsi>90,"~HI_RSI_COMP","X",19);

rsi14=RSI(14);
AddToComposite(rsi14<30,"~LO_RSI14_COMP","X",19);
AddToComposite(rsi14>70,"~HI_RSI14_COMP","X",19);



AddToComposite(C>BBandTop(C),"~HI_BB_COMP","X",19);
AddToComposite(C<BBandBot(C),"~LO_BB_COMP","X",19);

pos4d=Foreign("~POS4DAILY","C");
neg4d=Foreign("~NEG4DAILY","C");
pos30q=Foreign("~POS30QTR","C");
neg30q=Foreign("~NEG30QTR","C");
pos20m=Foreign("~POS20MO","C");
neg20m=Foreign("~NEG20MO","C");
spyop=Foreign("SPY","O");
spycl=Foreign("SPY","C");
newlow=Foreign("~NEWLOW60","C");
newhi=Foreign("~NEWHI60","C");
posrsi14=Foreign("~HI_RSI14_COMP","C");
negris14=Foreign("~LO_RSI14_COMP","C");



Buy=Sell=Cover=Short=0;


Filter = 1;
AddColumn(pos4d,"+4% today",1);
AddColumn(neg4d,"-4% today",1);
AddColumn(pos30q,"+30% qtr",1);
AddColumn(neg30q,"-30% qtr",1);
AddColumn(pos20m,"+20% month",1);
AddColumn(neg20m,"-20% month",1);
AddColumn(spyop,"SPY Open",1.2);
AddColumn(spycl,"SPY Close",1.2);
AddColumn(newlow,"New 60d Low",1.0);
AddColumn(newhi,"New 60d Hi",1.0);
AddColumn(pos30q/(pos30q+neg30q)*100,"30q dif",1.2);
AddColumn(newhi/(newhi+newlow)*100,"hi-lo dif",1.2);

5 comments

over 8 years ago

Above code not working, Please advise how to run above code in Amibroker version 5.80

4. data
over 8 years ago

Code is working fine for me if you run it correctly. Did you run the composite exploration on your market of stocks before trying to plot the indicator?

5. WSTBULL
over 7 years ago

Thanks for the Great work. Just what I’m looking for n more…
To use this, please note there is 2 pg of formula to copy. Please use 2 different name. Use the Analysis > exploration on the composite formula and then u can use the indicator to plot.

Leave Comment

Please login here to leave a comment.