Technical analysis: moving averages, breadth and sentiment

Market efficiency and behavior
What are chartists looking at, how do I compute their tools, and does any of it work?

Learning goals

After this page, you can:

  • Describe what technical analysts do, and why it is the opposite of weak-form efficiency.
  • Compute an n-day moving average, mark the days the price crosses it, and apply the crossover rule.
  • Compute the breadth measures and the sentiment measures, and say which way each one is read.
  • Compare what a rule would have earned with buy-and-hold, and explain why one lucky result is not evidence.

The idea

A weather app looks only at the last ten days of temperatures and says “warming trend, pack shorts”. Sometimes it is right, because weather has seasons. A chartist’s moving average does the same with prices. The question on this page: do prices have seasons at all?

Technical analysis is the search for repeating patterns in past prices and in volume (the number of shares traded). The people who do it are called chartists. The weak form of the efficient markets hypothesis says that past prices are already in today’s price, so they predict nothing (see the random walk). The two ideas are opposites. You learn the tools to understand what chartists see, not to copy them.

The moving average. An n-day moving average is the average of the last n closing prices. Each day the window slides: drop the oldest close, add the newest. A longer window gives a smoother line and fewer signals.

The crossover rule. When the price crosses above its moving average, a chartist buys. When it crosses below, the chartist sells. The tool on this page uses closing prices only: buy at the close of the first day the close is above the average, sell at the close of the first day it is below. A close exactly equal to the average is no signal.

Key formulas

n-day moving average = (sum of the last n closes) ÷ n

advance–decline line today = line yesterday + (advances − declines), starting at 0

TRIN = (advances ÷ declines) ÷ (up volume ÷ down volume)

on-balance volume today = yesterday’s total + today’s volume if the close rose, − today’s volume if it fell, no change if equal

mutual fund cash ratio = cash ÷ total assets

short-interest ratio = shares sold short ÷ average daily volume

odd-lot ratio = odd-lot sales ÷ odd-lot purchases

Breadth measures count stocks across the whole market. An advance is a stock that rose today. A decline is a stock that fell.

Measure What it is How chartists read it
Advance–decline line a running total of advances minus declines rising: many stocks take part; falling: weakness
New highs minus new lows stocks at a 52-week high minus stocks at a 52-week low positive is strong, negative is weak
TRIN the advance–decline ratio divided by the ratio of up volume (shares traded in rising stocks) to down volume (in falling stocks) above 1 is a weak day: the volume went into the losers; below 1 is a strong day
On-balance volume a running total: add the volume on an up day, subtract it on a down day rising: buyers are in control

Sentiment measures try to read the mood of the crowd. Bullish means expecting prices to rise. A contrarian bets against the crowd, so some of these are read backwards.

Measure What it is How chartists read it
Mutual fund cash ratio fund cash as a share of fund assets high: cash is waiting to buy, read as bullish
Short-interest ratio the days of normal volume needed to buy back all shares sold short (borrowed and sold) high: many must buy later, bullish for contrarians
Odd-lot ratio sales ÷ purchases in odd lots, orders of fewer than 100 shares heavy selling by small investors: contrarians buy

Does it work? The evidence says that these tools do not beat the market after trading costs. Compute them, read them in the news, and do not pay for them.

In Excel. With closes in B2:B13, the 5-day average is =AVERAGE(B2:B6) in C6, copied down. Signal: =IF(B6>C6,"above",IF(B6<C6,"below","on the line")). With volume in column D, on-balance volume is a running total in column E. Leave E2 empty, type =E2+IF(B3>B2,D3,IF(B3<B2,-D3,0)) in E3 and copy it down: in E6 it reads =E5+IF(B6>B5,D6,IF(B6<B5,-D6,0)).

Try it

Press each of the three buttons once and read the results card.

What to notice:

  • 10-day rule: 11 trades and +13.50%. Simply holding earned +14.23% with no trades.
  • 50-day rule: one trade and +37.98%. The rule happened to buy right after a big drop.
  • Same stock, two rules, two verdicts. That is luck, not a law. Move a slider and look again.

Worked example

Juniper Apparel, twelve daily closes: 30.00, 30.60, 30.20, 31.00, 31.40, 31.10, 31.90, 32.30, 31.80, 32.60, 31.20, 30.70. Use a 5-day moving average and the crossover rule. On day 11 the whole exchange had 1,320 advances and 1,860 declines, with 640 million shares of up volume and 1,210 million shares of down volume.

Step 1. The first average (day 5). (30.00 + 30.60 + 30.20 + 31.00 + 31.40) ÷ 5 = 153.20 ÷ 5 = 30.64. The close, 31.40, is above the average: buy at 31.40.

Step 2. Slide the window. Day 6 uses days 2 to 6: (30.60 + 30.20 + 31.00 + 31.40 + 31.10) ÷ 5 = 30.86.

Day Close 5-day average The close is Action
5 31.40 30.64 above buy
6 31.10 30.86 above hold
7 31.90 31.12 above hold
8 32.30 31.54 above hold
9 31.80 31.70 above hold
10 32.60 31.94 above hold
11 31.20 31.96 below sell
12 30.70 31.72 below stay in cash

Step 3. The result. Bought at 31.40, sold at 31.20: 31.20 ÷ 31.40 − 1 = −0.64%. Buy-and-hold from day 5 to day 12: 30.70 ÷ 31.40 − 1 = −2.23%. The rule lost less, because it sold on day 11, before the fall on day 12. One case proves nothing either way.

Step 4. Breadth on day 11. Advances − declines = 1,320 − 1,860 = −540. The advance–decline line falls by 540: a weak day. TRIN = (1,320 ÷ 1,860) ÷ (640 ÷ 1,210) = 0.7097 ÷ 0.5289 = 1.34, above 1.

Answer. Buy on day 5 at 31.40 and sell on day 11 at 31.20: −0.64%, against −2.23% for holding. The advance–decline difference is −540. TRIN is 1.34, a weak day.

Check yourself

Check 1.

The last four closes of a stock are 18.00, 18.40, 18.10 and 18.90. Its 4-day moving average today is:

Moving average = sum of the last n closes ÷ n.

Check 2.

Yesterday a stock closed below its 50-day moving average; today it closed above it. Under the crossover rule a chartist would:

Price crosses above the moving average → buy; crosses below → sell.

Check 3.

On one day 1,250 stocks rose and 1,750 fell. The advance–decline line stood at +2,400 the day before. Where is it now, and what does the move say?

A–D line today = A–D line yesterday + (advances − declines).

Check 4.

TRIN for a day is 2.10. The best reading is:

TRIN = (advances ÷ declines) ÷ (up volume ÷ down volume); above 1 weak, below 1 strong.

Check 5.

Mutual funds’ cash ratio has risen from 3.5 % to 6.0 % of assets over six months. A technician who follows this measure would call that:

Mutual fund cash ratio = cash ÷ total assets; high = bullish (cash waiting to buy).

Video

Video coming soon.