How to Calculate Advance Decline Line in Amibroker

#3
This is the first file that needs to be run as a scan to calculate advances and declines.

Code:
// Advancers / Decliners
AddToComposite(C>Ref(C,-1),"~Advances","X");
AddToComposite(C<Ref(C,-1),"~Declines","X");
AddToComposite(C==Ref(C,-1),"~NoChange","X");
Buy = 0;
Next save this as a plot indicator to get the the plot of the advances and declines

Code:
AA = Foreign("~Advances", "C");
AB = Foreign("~Declines", "C");
AD = AA / AB;

Plot(AD, "A/D Line", colorBlue, styleLine);
Plot(AA, "Advances", colorGreen, styleLine|styleThick);
Plot(AB, "Declines", colorRed, styleLine|styleThick);

You will have to do this manually. Works great on EOD data. If you need this intraday you have to run the scan using autorepeat / autoscan and set the time interval to the base bar of what you are charting. i.e. for 1 min bar run every 1 min and so on.