Market Breadth
An index price is a single number standing in for several hundred separate stories. It can rise because almost everything in it rose a little, or because five very large constituents rose a lot while the rest drifted sideways. The printed level is identical in both cases. Breadth measures are the statistics that tell the two cases apart.
This part does two things. It defines the common participation measures precisely enough
that you could compute them by hand — advances and declines, the advance/decline line,
the percentage of members trading above a moving average, new highs and new lows. And it
teaches the AmiBroker machinery that produces them: AddToComposite(), the artificial
~-prefixed symbols it writes into, the Analysis modes it will and will not run in, and
the database settings that decide whether the numbers it produces mean anything.
Why this part sits where it does
Section titled “Why this part sits where it does”Everything here is a multi-symbol calculation. A breadth reading is not a property of any
one instrument; it is a count taken across a universe, one bar at a time. That makes this
part a direct continuation of Part 15: Foreign() reads one other symbol, and
AddToComposite() is what you use when the “other symbol” you need does not exist yet
and has to be manufactured from five hundred of them.
It is also the first part where you write data into the database rather than only reading from it. A composite is stored data, not a live calculation. It is as old as the last time you ran the scan that built it, it survives restarts, and it can be silently wrong in ways a chart formula cannot. Most of the second lesson is about that.
What you will be able to do
Section titled “What you will be able to do”By the end of this part you should be able to:
- state what advances, declines, percentage-above-a-moving-average and new-high counts each measure, and what each of them fails to measure;
- write an
AddToComposite()formula with the correct flags for the mode you intend to run it in, and explain what every flag in that expression does; - run the scan that builds a composite, read the result back with
Foreign(), and re-run it correctly after adding quotes; - clear stale composite values instead of accumulating a second copy on top of the first;
- prove a composite is arithmetically consistent rather than assuming it;
- define a market regime from a breadth series in a way that could be applied at the time rather than only in hindsight, and say honestly how many independent observations of that regime your history actually contains.
The honest part
Section titled “The honest part”Breadth carries more folklore than almost any other corner of technical analysis, and two problems undermine most of it.
The first is survivorship. A breadth series is a count over the symbols in your database, and an ordinary database contains the companies that still exist. Every company that fell until it was delisted contributes declines, new lows and readings below its moving average that your data simply does not contain. Breadth measured from a present-day universe is therefore biased towards looking healthier in the past than the market actually was, and the advance/decline line — a running total — accumulates that bias permanently. Part 2 introduced survivorship bias; this part shows exactly where it enters a calculation you build yourself.
The second is that divergence, the most repeated breadth claim of all, is unusually easy to see after the fact and unusually hard to define before it. Lesson 3 takes that claim apart, not to dismiss it, but to show what a version of it that could be tested would have to look like — and why the answer is likely to rest on a handful of independent episodes rather than thousands of bars.
What you need first
Section titled “What you need first”Part 12 for the Analysis window and its modes, Part 15 for Foreign() and cross-symbol
alignment, and a database with enough members to make a count meaningful. A few dozen
symbols will run every formula here; a few hundred will make the pictures look like the
ones people publish. No real-time feed and no paid subscription are required — every
formula in this part works on end-of-day data.
0 / 4 lessons in this part completed
Progress tracking needs browser storage, which is unavailable here. The course works exactly the same without it.
- LessonBreadth Concepts: Participation and Its Measures26 min
- LessonBuilding Composites with AddToComposite()32 min
- LessonBreadth Divergence and Market Regime26 min
- ProjectProject: Market Breadth Dashboard60 min