Momentum Trading Algorithm Development
Momentum is one of the most statistically proven phenomena in financial markets. Assets that grew over the last N periods are statistically likely to continue growing. Jegadeesh and Titman documented this in 1993 on stocks. On crypto markets momentum works, but with peculiarities: it can reverse sharply.
Types of Momentum Strategies
Cross-sectional momentum (relative): among N assets, buy top-K (best performers), sell (or don't hold) losers. Portfolio rotation every N days.
Time-series momentum (absolute): buy asset if 12-month return is positive. Sell/short if negative.
Short-term momentum: buy on strong short-term impulse (1–5 days). Requires active management.
Measuring Momentum
Rate of Change (ROC):
ROC(n) = (Close - Close[n]) / Close[n] × 100
Relative Strength: asset return vs market over period.
MACD histogram: difference between MACD line and signal line. Growing histogram = strengthening momentum.
ADX: trend strength. ADX > 25 with rise = strong upward momentum.
Crypto Momentum Mechanics
In crypto, momentum is amplified by several factors:
- Retail FOMO (Fear of Missing Out) during rises
- Shorts squeeze on strong upward move
- On-chain activity increases with price rise
Momentum scoring for multiple assets:
def calculate_momentum_scores(prices_df, lookback=30):
returns = prices_df.pct_change(lookback)
# Normalize by volatility
vol = prices_df.pct_change().rolling(lookback).std()
risk_adjusted_momentum = returns / vol
return risk_adjusted_momentum.iloc[-1].sort_values(ascending=False)
Portfolio rotation: weekly, buy top-5 by risk-adjusted momentum from defined universe. Sell those dropping from top.
Momentum Filters and Signals
Trend filter: enter only when momentum > 0 AND price > SMA(200). Protects from buying in bear market.
Volume confirmation: momentum signal confirmed by high volume. Momentum without volume — weak signal.
Breakout confirmation: momentum + key level breakout = high-priority signal.
Momentum Crashes
Momentum strategies suffer from "crash" events — sharp reversals after overheating. Protection:
- Fast trailing stop (2–3 ATR)
- Max holding period (auto-close after N days)
- Correlation filter: don't hold > 3 highly correlated positions simultaneously
- Volatility scaling: reduce position size at high volatility
Stack: Python + pandas, CCXT for data and execution, PostgreSQL for history. Algorithm runs on schedule (daily or weekly for rotation strategies), results displayed in Grafana dashboard.







