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

RE: [AmiBroker] Help with AD Ratio



PureBytes Links

Trading Reference Links

I have taken the liberty to modify your code to speed it up a bit and also to show a count for Advancers, Decliners and Unchanged in the Title Bar. I am running this against a watch list that includes all the active stocks in the NYSE, AMEX and NASDAQ exchanges. My data source is Quotes Plus, so there may be a difference in the number of stocks compared to your Yahoo Data, but it should be very close. One thing I should warn you about. Before you run the Scan you should first go to Tools>Database Purify. Check only Report Missing Quotes. Now run Analyze.  When complete sort on the Problem/Description column so that all NO QUOTES are grouped together. Copy these no quotes to your Bad Ticker watch list (This is usually watch list 0).  Now go into Symbol>Organize>Watch Lists and DELETE all the symbols in your Bad Ticker Watch List. This purges your database of all stocks that have no data.

 

Now with your clean database you can insert the code below as an indicator, then do a SCAN in auto analysis against your stock universe and you should get correct results.  There is no reason to brek this code into two parts as someone else suggested. It works fine as a single AFL.  Let me know if there is anything you don’t understand or want further clarification on.

 

Enjoy,

 

------------------------------------------ Start Code --------------------------------------------

Filter=InWatchList(38); //This tells me what stock universe I am running against. Change to match your

// Stock Universe. Mine includes all stock in NYSE, AMEX, NASDAQ

sym1="~Advancers"; // Set Variable for Advancers

sym2="~Decliners"; // Set Variable for Decliners

sym3="~Unchanged"; // Set Variable for Unchanged

Advance=Close>Ref(Close,-1); // Defines what constitutes Advance

Decline=Close<Ref(Close,-1);// Defines what constitutes Decline

Unchanged=Close==Ref(Close,-1);// Defines what constitutes Unchanged

IIf(Advance>0,AddToComposite(Advance,sym1,"C"),0); // Adds Advancers to Composite

IIf(Decline>0,AddToComposite(Decline,sym2,"C"),0); // Adds Decliners to Composite

IIf(Unchanged>=0,AddToComposite(Unchanged,sym3,"C"),0); // Adds Unchanged to Composite

AD1=Foreign("~Advancers","C"); //Reads Value for plot of Advances used in Title

DC1=Foreign("~Decliners","C");//Reads Value for plot of Decliners used in Title

UC1=Foreign("~Unchanged","C");//Reads Value for plot of Unchanged used in Title

ADRatio= IIf(DC1>AD1,(DC1*-1)/AD1, AD1/DC1); // Calculates ADRatio

Buy=Sell=Short=Cover=0;

 

GraphXSpace = 2;

Plot(ADRatio,"AdvanceDeclineRatio",colorDarkBlue,styleHistogram|styleThick);

Plot(0,"",colorBlack);

Plot(3,"",colorGreen);

Plot(-3,"",colorRed);

 // This places all the composites into the watchlist were I save results. Change to match your enviorment

CategoryAddSymbol( "~Advancers", categoryWatchlist, 54);

CategoryAddSymbol( "~Decliners", categoryWatchlist, 54);

CategoryAddSymbol( "~Unchanged", categoryWatchlist, 54);

// Below is expanded title to give me values for all of the composites

Title="Advance/Decline Ratio = "+ADRatio+"  "+EncodeColor(colorGreen)

+ "Advancers = "+AD1+"  "+EncodeColor(colorRed)+"Decliners = "+DC1+"  "

+EncodeColor(colorBlue)+"Unchanged = "+UC1;

 

--------------------------------------- End Code ----------------------------------------------

 

Donald F Lindberg


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of smithkt9675
Sent: Saturday, October 06, 2007 8:04 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Help with AD Ratio

 

Hello, I'm trying to plot the Advance/Decline Ratio so that advancers
show up 3:1 for example, and decliners show up as -3:1, so that
declining days appears as a negative breadth thrust and advancers
positive...all along a zero line in histogram form. The formula
looks right, but when compared to a source I'm trying to replicate
the figures look off. Please advise if I should tweak the formula.
I'm using Yahoo data. Thank you very much.

symz="~Advancers";
symy="~Decliners";
Advance=Close>Ref(Close,-1);
Advance1=Advance>0;
Decline=Close<Ref(Close,-1);
Decline1=Decline>0;
IIf(Advance1>0,AddToComposite(Advance1,symz,"C"),0);
IIf(Decline1>0,AddToComposite(Decline1,symy,"C"),0);

AD1=Foreign("~Advancers","C");
DC1=Foreign("~Decliners","C");

ADRatio= IIf(DC1>AD1,(DC1*-1)/AD1, AD1/DC1);

Buy=0;
Filter = 1;

GraphXSpace = 2;
Plot(ADRatio,"AdvanceDeclineRatio",colorDarkBlue,styleHistogram);

Plot(0,"",colorBlack);
Plot(3,"",colorGreen);
Plot(-3,"",colorRed);

Title="Advance/Decline Ratio";

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

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

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___