HomeKnowledge Base

How to display the indicators based on Advances/Declines

IMPORTANT: The article below applies ONLY TO LOCAL DATABASES. If you are using ANY plugin-driven database (eSignal, IQFeed, Premium Data, Norgate, Interactive Brokers or whatever other 3rd party plugin), then you SHOULD NOT use “calculate composites” tool. Instead use composite symbols that are provided by data vendor. Contact data vendor to learn what symbols given data vendor uses, because composite symbols are NOT standarized and vary from vendor to vendor

In order to display indicators based on Advances/Declines first of all it’s necessary to calculate composities in the database:

  1. Open Categories window using Symbol->Categories menu item.
  2. Select base index for given market in Markets tab and Base indexes for – Composites combo.
    For example if you are following NYSE this can by ^DIJ (Dow Jones Average)
    (certain symbol must be marked as index in Symbol -> Information and must belong to the same market)

  3. Choose Symbol ->Calculate composites  menu item to open the window shown below and mark:
    – Number of advancing/declining issues and
    – Apply to: all quotes, All markets

  4. Click Calculate . From now on ADLine, AdvVolume() and TRIN indicators will be visible.

Q: Why does AB need “base index”?
A: Just because it may happen that not all stocks are quoted every businness day and AB needs must calculate number of advancing/declining issues per market. So it checks the “base index” quotations dates and tries to find corresponding quotes of all stocks belonging to that market to find out how many issues advanced, declined and not changed at all.

Q: What are “Volume for base index” and “Copy volume to all indexes” checkboxes for?
A: “Volume for base index” and “Copy volume to all indexes” are provided in case you DON’T have real volume data for index quotes. In that case AmiBroker can calculate volume for index as a sum of volumes of all stocks belonging to given market. First option assigns calculated volume only to “base index”, the second copies the volume figure to all indexes belonging to given market.

How to detect the divergences

There are many different ways to check for divergences. One of the simplest is to use Rate of change indicator and EXPLORATION feature of Automatic Analysis window:

– Analysis -> Formula Editor
– enter:
// 5 day rate of change of close
PriceUp ROCC) > ;
// 5 day rate of change of MACD histogram
MacdUP ROCMACD() - Signal(), ) > 0;
BullishDiv NOT PriceUP AND MACDUp;
BearishDiv PriceUP AND NOT MACDUp;
Filter BullishDiv OR BearishDiv;
AddColumnBullishDiv"Bullish Divergence"1.0,
colorDefaultIIf(BullishDivcolorGreencolorDefault ) ); 
BearishDiv "Bearish Divergence"1.0,
colorDefaultIIf(BearishDiv colorRedcolorDefault) )

– Tools -> Send to Auto-analysis
– Apply to: All Symbols, N last quotations = 1
– press EXPLORE

Tools -> Send to Auto-analysis- Apply to: All Symbols, N last quotations = 1- press EXPLORE

A different approach can use linear regression instead:
// 10 day linear regression slope of close
PriceUp LinRegSlopeC10 ) > ;
// 10 day linear regression slope of MACD histogram
MacdUP LinRegSlopeMACD() - Signal(), 10 );