Lesson 5.1: Trend following and momentum
Learn trend following and momentum: moving-average and breakout rules, volatility targeting, why trend strategies win rarely but big, and why many markets help.
By the end of this lesson you will be able to describe time-series and cross-sectional momentum, build a moving-average crossover and a breakout signal, size positions by volatility so that each market carries the same risk, explain why trend strategies win a minority of their trades and still make money, and work out how much trading many markets raises the Sharpe ratio. You will show that a 20-day against 100-day moving-average rule has a Sharpe ratio of 0.80 in simulated markets that have a slowly changing trend and 0.00 in markets that have none, that it wins 42 per cent of its trades with winners about four times as large as losers, that holding an asset with 18 per cent volatility at a 10 per cent risk target means a position of 0.56 times capital, and that a single-market Sharpe ratio of 0.4 rises to 0.82 across 20 markets with an average correlation of 0.2. You should have read Module 4, especially Lessons 4.2 and 4.4. The mathematics is averages, ratios and a square root. This course is education about how markets and research work, not investment advice.
Modules 1 to 4 built the foundations: markets, mathematics, research method and testing. Module 5 turns to the strategies themselves. Almost every systematic strategy belongs to a small number of families, and each family has a distinct personality: where its profits come from, what its returns look like, when it fails and what it costs to run. We start with the oldest and most widely used, trend following: buy what has been rising and sell what has been falling, and hold until the direction changes.
The idea and why it might work
The claim of trend following is that price changes have a small tendency to continue in the same direction, over horizons from a few weeks to a year. It sounds as if it should not work: if prices follow a random walk, the past tells you nothing. Yet evidence from many markets and many decades shows a persistent effect. The explanations come from behaviour and from the structure of markets.
Slow information. News is absorbed gradually: analysts revise forecasts in steps, investors underreact at first and then chase.
Herding and feedback. Rising prices attract buyers, which pushes prices higher, until a limit is reached. Stop-losses and trend-following funds themselves add to the moves.
Constrained investors. Large investors cannot trade in an instant without moving prices, so they build and unwind positions over weeks, which spreads a price change over time.
Risk transfer. Hedgers, such as producers who sell their output forward, accept a worse price in return for certainty, and speculators who take the other side of this are paid for it.
None of these is a law. They are reasons the effect could exist, and each can weaken, which is why trend strategies have had long stretches of poor results.
Two forms
Time-series momentum looks at each asset on its own. If an asset's return over the past 12 months is positive, go long, and if it is negative, go short. Each market is judged against zero, or against its own history. Tobias Moskowitz, Yao Hua Ooi and Lasse Pedersen documented it across futures in many markets in 2012.
Cross-sectional momentum ranks assets against each other. Buy the top group of winners and sell the bottom group of losers, so that the portfolio is market-neutral. Narasimhan Jegadeesh and Sheridan Titman's 1993 study of stocks is the classic reference. It is the form most often used for shares, where the question is "which stocks are doing better than the others", and it is built like the signals of Lesson 3.3.
Building the signals
Several simple rules capture a trend. They are cousins, and in practice they are highly correlated.
Rule · How it works · CharacterPast return · Go long if the return over the last L days is positive, short if negative · Simplest; L is often 1, 3 or 12 months
Moving-average crossover · Go long when a fast average of price is above a slow one, short when below · Smooths noise; reacts with a lag
Breakout · Go long when the price makes a new high over the last L days, short at a new low · Enters late but catches big moves
Trend slope · Fit a line to the last L prices and use its slope divided by its error · Takes noise into account
Worked example 1. The moving-average crossover compares the average price of the last 20 days with the average of the last 100. When the 20-day average is above the 100-day average, the recent price is higher than the longer-term level, which marks an uptrend, and the rule is long. When it is below, the rule is short. The decision is made at the close, and, by the one-bar lag of Lessons 3.2 and 4.1, traded the next day.
To see what the rule does, we ran it on simulated markets. In one kind, returns are random noise with a standard deviation of 1 per cent a day plus a slowly changing drift, which is a trend that comes and goes. In the other, returns are noise alone, with no trend at all. We ran 100 ten-year histories of each, charged 2 basis points for every change in position, and averaged.
Simulated market · Sharpe ratio after costs · Share of trades that win · Average winner ÷ average loser · Trades a yearWith a slowly changing trend · 0.80 · 42% · 4.06 · 2.5
No trend · 0.00 · 33% · 2.11 · 3.3
Two things stand out. In the market with no trend, the rule earns nothing, as it must, since there is nothing to follow. And the rule loses money on most of its trades even where it works: in the trending market 58 per cent of trades lose, yet the strategy has a Sharpe ratio of 0.80.
The shape of trend returns: win rarely, win big
The reason is arithmetic that Lesson 2.1 introduced. The expected profit of a trade, in units of the average loss, is
expectancy = win rate × payoff ratio − (1 − win rate)
where the payoff ratio is the average win divided by the average loss. In the market with a trend, 0.42 × 4.06 − 0.58 = 1.71 − 0.58 = 1.12 average losses of profit per trade. In the market with no trend, 0.33 × 2.11 − 0.67 = 0.70 − 0.67, about 0.03 to 0.04, essentially zero, which costs push to zero. Trend following earns its profit from a few large winners, trades that ride a long move, and pays for it with many small losses when the market whipsaws, that is, reverses soon after a signal.
This is the mirror image of the insurance-selling strategies of Lesson 4.2. Those win often and lose big rarely. A trend follower loses often and small, and wins rarely and big, so its return distribution has positive skew: a long right tail. It is also why trend following is sometimes called long convexity, since its payoff resembles that of buying an option: a limited cost when nothing happens and a large gain when a big move develops. It earns most in sustained trends and, because it can go short, it can profit in a long market decline. This has made it of interest to investors seeking protection in crises, although it does not always deliver: a fast reversal after a crash can catch a trend follower on the wrong side.
The psychological cost should not be underestimated. A strategy that loses on 58 per cent of trades, and that can spend years under water, needs a disciplined investor. Many abandon it just before a good year.
Sizing by volatility
Different markets have very different volatilities. If you hold the same amount of capital in a stock index and in crude oil, oil dominates your risk. The standard remedy is volatility targeting: choose each position so that it contributes the same risk, for example a target of 10 per cent annual volatility per market.
position = (target volatility ÷ the asset's volatility) × capital
Worked example 2. Take four illustrative markets with annualised volatilities as in the table, and a 10 per cent risk target for each.
Market · Annual volatility · Position as a multiple of capitalEquity index · 18% · 10 ÷ 18 = 0.56
Government bond · 6% · 10 ÷ 6 = 1.67
Gold · 15% · 10 ÷ 15 = 0.67
Crude oil · 35% · 10 ÷ 35 = 0.29
The bond position is 1.67 times capital, which requires leverage, and the oil position is only 0.29. Each now contributes about the same risk. As volatility changes, the positions change too: when a market becomes twice as volatile, its position halves, which keeps risk steady and also cuts exposure just as danger rises, a built-in risk control. Estimate the volatility with the EWMA of Lesson 2.2 so that it reacts quickly.
Why many markets matter
A single market gives a handful of independent trends over a decade. A trend follower therefore trades many markets: equity indices, bonds, currencies, commodities and more. The benefit follows from the fundamental law of Lesson 3.3. If each of N markets has the same Sharpe ratio, and the average correlation between the strategies' returns is ρ, the Sharpe ratio of the combined portfolio is
SR portfolio = SR single × √(N ÷ (1 + (N − 1)ρ))
Worked example 3. Take a single-market Sharpe ratio of 0.4, which is modest, and an average correlation of 0.2 between markets. The effective number of independent markets for N = 20 is 20 ÷ (1 + 19 × 0.2) = 20 ÷ 4.8 = 4.2, so the portfolio Sharpe ratio is 0.4 × √4.2 = 0.82, double the single-market figure. Notice the diminishing returns: the benefit comes from adding markets that are different from each other, and a hundred markets that all move together would add little.
Number of markets · Portfolio Sharpe ratio (single market 0.4, correlation 0.2)1 · 0.40
5 · 0.67
10 · 0.76
20 · 0.82
50 · 0.86
Check the effect with your own numbers.
The risks of trend following
Whipsaws. In a range-bound market, signals flip back and forth and each flip costs money. A strategy can lose for a long time.
Sharp reversals. After a sudden shock, markets can reverse before a slow signal catches up. A fast signal reacts sooner but whipsaws more.
Momentum crashes. For cross-sectional stock momentum, Kent Daniel and Tobias Moskowitz found in 2016 that the worst losses come in sharp market rebounds after a panic, when the losers that the strategy is short rally hardest.
Long drawdowns. A trend strategy can spend years below a previous peak, so the time under water of Lesson 4.2 matters as much as the maximum drawdown.
Costs and capacity. Trend signals are slow, which keeps costs low, but the strategy is widely followed, and a crowded trade has more impact on the way out (Lesson 4.4).
Regime change. If markets become less trending, because central banks suppress volatility or because more money chases the same signals, the edge can shrink.
Practical design
1. Trade many markets that differ from each other, and weight them by risk, not by capital.
2. Blend lookbacks. Combine signals from, say, 1, 3 and 12 months, which smooths the result and reduces dependence on one parameter, as the plateau test of Lesson 3.4 recommends.
3. Scale positions to volatility and cap leverage.
4. Keep turnover low. Use a band so that small changes in the signal do not trigger trades.
5. Test out of sample. Use walk-forward testing (Lesson 4.3) and judge the strategy over decades, not years.
6. Include costs and financing in the backtest, and double them as a check (Lesson 4.4).
7. Set expectations for the investor: frequent small losses, long drawdowns, and a few large wins.
The code below simulates the markets, runs the crossover rule, and reproduces the trade statistics, the expectancy, the volatility targets and the diversification numbers.
python
import numpy as np
from math import sqrt
def sharpe(x):
return x.mean() / x.std(ddof=1) sqrt(252)
def world(seed, trend, n=2520):
rng = np.random.defaultrng(seed)
r = rng.normal(0, 0.01, n)
if trend: # a slowly changing drift, which comes and goes
d = np.zeros(n)
for t in range(1, n):
d[t] = 0.98 d[t - 1] + rng.normal(0, 0.0003)
r = r + d
return r
def sma(x, w):
c = np.cumsum(np.insert(x, 0, 0))
out = np.full(len(x), np.nan)
out[w - 1:] = (c[w:] - c[:-w]) / w
return out
def run(r, fast=20, slow=100, costbp=2.0):
price = np.exp(np.cumsum(r))
f, s = sma(price, fast), sma(price, slow)
signal = np.where(np.isnan(s), 0, np.sign(f - s))
pos = np.concatenate([[0], signal[:-1]]) # decided at t-1, earns day t
pnl = pos r - np.abs(np.diff(np.concatenate([[0], pos]))) costbp / 1e4
return pnl, pos
def tradepnls(gross, pos):
out, start = [], 0
for t in range(1, len(pos)):
if pos[t] != pos[t - 1]:
if pos[start] != 0:
out.append(gross[start:t].sum())
start = t
return np.array(out)
for label, trend in (("with a trend", True), ("no trend", False)):
sr, wins, ratio, peryear = [], [], [], []
for seed in range(100):
r = world(seed, trend)
pnl, pos = run(r)
sr.append(sharpe(pnl))
tr = tradepnls(pos r, pos)
if len(tr) > 3:
wins.append((tr > 0).mean())
ratio.append(tr[tr > 0].mean() / abs(tr[tr < 0].mean()))
peryear.append(len(tr) / 10)
w, pr = np.mean(wins), np.mean(ratio)
print(f"{label}: Sharpe {np.mean(sr):.2f} | win rate {w:.2f} | payoff ratio {pr:.2f} | trades a year {np.mean(peryear):.1f}"
f" | expectancy per trade {w pr - (1 - w):.2f} average losses")
volatility targeting
for name, vol in (("Equity index", 18), ("Government bond", 6), ("Gold", 15), ("Crude oil", 35)):
print(name, "position multiple", round(10 / vol, 2))
diversification across markets
for n in (1, 5, 10, 20, 50):
print(n, "markets: Sharpe", round(0.4 sqrt(n / (1 + (n - 1) 0.2)), 2))
Common mistakes
Expecting a high win rate. Trend followers lose most trades. Judge the expectancy, not the win rate.
Using one market. A single market gives too few independent trends. Breadth is the main source of the Sharpe ratio.
Equal capital in every market. The most volatile market then dominates the risk. Size by volatility.
Over-fitting the lookback. Choose a broad plateau or blend several, not the single best window.
Ignoring the whipsaw years. A strategy that is good over twenty years may lose for three in a row.
Forgetting costs in fast versions. A shorter lookback trades more often and pays more.
Believing the crisis hedge story without testing. Trend following has helped in some crashes and failed in others.
Running the same trade as everyone else. Crowded momentum is exposed to sharp reversals.
Using unadjusted futures prices. Contracts roll, and the roll must be handled correctly or the price series jumps.
Key takeaways
Trend following buys what has been rising and sells what has been falling. Time-series momentum judges each asset against its own past, and cross-sectional momentum ranks assets against each other.
A 20-day against 100-day crossover earned a Sharpe ratio of 0.80 in simulated markets with a slowly changing trend and 0.00 in markets with none. It follows a trend, it cannot create one.
Trend following wins rarely and wins big: 42 per cent winners with a payoff ratio of 4.06 gives an expectancy of 1.12 average losses per trade. Its returns have positive skew, the opposite of selling insurance.
Volatility targeting sizes each position as the target volatility divided by the asset's volatility: 0.56 times capital for an index with 18 per cent volatility at a 10 per cent target, and 1.67 for a bond with 6 per cent.
A portfolio of N markets has a Sharpe ratio of the single-market ratio times √(N ÷ (1 + (N − 1)ρ)). A single-market 0.4 becomes 0.82 across 20 markets with a correlation of 0.2, and the ceiling is set by ρ.
The main risks are whipsaws, sharp reversals, momentum crashes in cross-sectional stock momentum, long drawdowns, crowding and regime change.
Blend lookbacks, trade many different markets, scale by volatility, keep turnover low and test out of sample.
Check yourself
1. A trend strategy wins 35 per cent of its trades, and its average win is 3 times its average loss. What is the expectancy in units of the average loss?
0.35 × 3 − 0.65 = 1.05 − 0.65 = 0.40 average losses per trade. It is profitable despite losing 65 per cent of trades.
2. A currency pair has an annual volatility of 8 per cent. With a 10 per cent risk target on ₹50 lakh of capital, how large is the position?
Multiple = 10 ÷ 8 = 1.25, so a position of ₹62.5 lakh, which needs leverage.
3. A single-market trend Sharpe ratio is 0.3 and the average correlation is 0.3. What is the Sharpe ratio of a portfolio of 10 markets, and what is the ceiling?
Neff = 10 ÷ (1 + 9 × 0.3) = 10 ÷ 3.7 = 2.70, so the Sharpe ratio is 0.3 × √2.70 = 0.49. The ceiling is 0.3 ÷ √0.3 = 0.55.
4. Why does trend following often have a drawdown lasting several years, even when it works over decades?
Trends are not constant. In range-bound or fast-reversing markets the strategy gives back profits through repeated small losses, and a long run of such markets can last for years.
5. A friend says a 5-day lookback is better than a 100-day one because it made more money in the backtest. What would you ask?
How many trades and what turnover, and what the result is after costs. A shorter lookback trades more, so costs matter more, and it should be compared by walk-forward testing and by looking at neighbouring parameters.
Try this
Set aside forty-five minutes. You need daily prices for at least five liquid markets over at least ten years.
1. Compute 20-day and 100-day moving averages for each market, and the crossover signal. Apply the one-bar lag.
2. Compute the profit and loss of each market, with a cost of 2 basis points per change of position. Report the Sharpe ratio of each.
3. Compute the number of trades, the win rate, the payoff ratio and the expectancy for one market. Check that the arithmetic matches the Sharpe ratio.
4. Scale each market to a 10 per cent volatility target using a trailing 60-day volatility, and combine them with equal risk. Compare the portfolio Sharpe ratio with the average single-market one.
5. Compute the correlation between the markets' strategy returns, and use the diversification simulator to see whether the gain matches.
6. Repeat with lookbacks of 10/50 and 50/200. Is there a plateau?
7. Write a short note: the portfolio Sharpe ratio after costs, the maximum drawdown and its length, the win rate and payoff ratio, and what an investor should expect.
A good result is a portfolio Sharpe ratio above the single-market average, a win rate below 50 per cent with a payoff ratio above 2 and an honest statement of the longest drawdown. The next lesson turns to the opposite bet: mean reversion, which wins often and loses rarely and big.
Read more
Tobias Moskowitz, Yao Hua Ooi and Lasse Pedersen's 2012 paper "Time Series Momentum" in the Journal of Financial Economics and Narasimhan Jegadeesh and Sheridan Titman's 1993 paper "Returns to Buying Winners and Selling Losers" in the Journal of Finance are the key sources. Kent Daniel and Tobias Moskowitz's 2016 paper "Momentum Crashes" in the Journal of Financial Economics studies the tail risk. Brian Hurst, Yao Hua Ooi and Lasse Pedersen's "A Century of Evidence on Trend-Following Investing" is a long-history study. For practice, Andreas Clenow's Following the Trend is a readable account of how trend funds are run, and Ernest Chan's Algorithmic Trading covers momentum strategies with code.
Tags: Quant Trader Trend following Momentum Volatility targeting Diversification