Trading Dev AcademyFree quant education

Free lesson · Quant strategy development

04 / Momentum and trend: information that persists

Open interactive lessonPractice calculationsExplore labs

Start with the idea

Momentum measures persistence in past price changes. The lookback defines what “trend” means; the holding and execution horizons determine whether that information can be used economically.

Symbols, units & horizon
  • mᵢ,ₜ: sum of historical log returns for instrument i
  • rᵢ,ₜ₋ⱼ: log return j periods before t
  • k: most recent included lag, skipping newer returns if k>0
  • L: oldest included lag
  • L−k+1: number of included returns
  • σ̂: per-period volatility estimated from history
  • sᵢ,ₜ: bounded score between −1 and 1
  • tanh: hyperbolic tangent, (e²ˣ−1)/(e²ˣ+1)

When and why to use this

Use simple momentum as a transparent baseline against which to test complex pattern recognition. Volatility scaling and a bounded score can help compare signals across instruments.

mi,t=∑j=kLri,t−j,si,t=tanh⁡(mi,tσ^i,tL−k+1)
Algebra and arithmetic

Build and bound a momentum score

  1. Add the lagged log returns from k through L, giving n=L−k+1 observations. Under an IID equal-variance approximation, their sum has SD σn.
  2. Divide cumulative momentum by that scale to get x. The bounded transformation is tanh⁡x=(e2x−1)(e2x+1), which approaches ±1. Its inverse is x=12ln⁡[(1+s)(1−s)] for |s|<1.
Work it by hand

Cumulative log return=.04, per-period vol=.02, n=4: x=1 and score=tanh1≈.761594. This bounded value is not a 76% win probability.

A lagged cumulative log return measures trend from k periods ago through L periods ago. Skipping the most recent observations can test whether very short-horizon reversal contaminates a slower trend. The bounded score is an example normalisation, not an optimal universal rule. Both lookbacks and volatility estimates must be fixed through a documented training process.

Time-series momentum asks whether an instrument’s own direction persists. Cross-sectional momentum ranks instruments against peers and typically combines long winners with short losers. The latter can acquire sector, market, size or liquidity exposures unless the portfolio construction controls them.

VariablePotential roleTrade-off
Lookback L and skip kChoose the information horizonShorter windows react faster but often trade more
Volatility estimateCompare signal strength and set exposureSlow estimates miss shocks; fast estimates can cause churn
Rebalance intervalTranslate signal updates into tradesLess trading can reduce costs and delay response
Trend breadth / market regimeTest whether broad participation mattersA regime filter adds another model-selection problem
Liquidity and carryDetermine executable size and holding costA strong price signal can still have negative net carry

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

from math import tanh, sqrt

def momentum_score(returns_oldest_first, oldest_lag, newest_lag, per_period_sd):
    """Last supplied return is lag 0, already observable at decision time."""
    if not 0 <= newest_lag <= oldest_lag < len(returns_oldest_first) or per_period_sd <= 0:
        raise ValueError("Invalid lag window or volatility")
    recent = list(reversed(returns_oldest_first))
    momentum = sum(recent[newest_lag:oldest_lag+1])
    scale = per_period_sd*sqrt(oldest_lag-newest_lag+1)
    return momentum, tanh(momentum/scale)

print(momentum_score([.01,.02,-.01], 2, 0, .02))

Continue learning

Quant Strategy Development — all lessons
  1. 01 / Start with a source of return
  2. 02 / The variables that actually enter the decision
  3. 03 / Test predictive information before a complex model
  4. 04 / Momentum and trend: information that persists
  5. 05 / Mean reversion and relative value
  6. 06 / Carry, events, and liquidity provision
  7. 07 / Convert a forecast into a trade decision
  8. 08 / Build a bot that preserves the experiment
  9. 09 / Decide whether the edge is real enough to continue

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations