Pairs Trading: Trading the Spread Between Two Related Markets
Pairs trading buys one market and sells a related one when their relationship stretches. Correlation vs cointegration, hedge ratios, z-score entries, risks and what it takes to automate it.
Instead of predicting where one market will go, pairs trading bets on the relationship between two related markets. When the gap between them stretches beyond normal, the strategy buys the relatively cheap one and sells the relatively expensive one, expecting the gap - the spread - to return toward its usual level. It is a form of market-neutral mean reversion.
Classic pair candidates
- Gold and silver (XAUUSD / XAGUSD).
- Two oil benchmarks (WTI / Brent).
- Related currency pairs (for example AUDUSD / NZDUSD).
- Two stock indices from similar economies.
The relationship should have an economic reason, not only a statistical one.
Correlation vs cointegration
Correlation says the two markets’ returns tend to move together. Two markets can be highly correlated and still drift apart for years.
Cointegration says a combination of the two prices - the spread - tends to return to a stable mean. That is what pairs trading needs. Tests such as Engle-Granger or Johansen check it statistically on historical data.
Building the spread
- Hedge ratio (β) - how much of B offsets one unit of A, often from a regression of A’s price on B’s price over a lookback.
- Spread = price A − β × price B.
- Z-score = (spread − mean of spread) / standard deviation of spread, over a rolling window.
Rules for a pairs bot
- Entry: z-score > +2 → sell A, buy β × B; z-score < −2 → buy A, sell β × B.
- Exit: z-score returns to about 0.
- Stop: z-score beyond ±3.5-4, or a maximum holding time.
- Re-estimate: hedge ratio and statistics on a schedule (for example monthly), tested in a walk-forward setting.
- Size: both legs together sized so that a stop on the spread costs a fixed share of equity.
Practical issues
- Execution of two legs. Both legs must fill; if one fails, the position is no longer hedged. The bot needs logic to retry or close the filled leg.
- Costs are paid twice - two spreads, two commissions, two swaps.
- Different trading hours between the two instruments create gaps.
- Contract sizes differ; convert hedge ratios into tradable volumes carefully.
- Regime change. A pair that reverted for years can stop reverting after a supply shock, policy change or index reconstitution.
Typical profile
| Metric | Typical |
|---|---|
| Win rate | Often high (60-75%) |
| Average win | Smaller than average loss |
| Market exposure | Low directional, high relationship risk |
| Main risk | Structural breaks that widen the spread |
Key takeaways
- Pairs trading bets on the spread between two related markets returning to normal.
- Cointegration, not just correlation, is what the strategy needs.
- Hedge ratio, z-score entries and exits, and a hard spread stop form the core.
- Two-leg execution, doubled costs and structural breaks are the practical risks.
Related: mean reversion strategy and hedging in trading.
FAQ
Is high correlation enough for pairs trading?
No. Correlation measures whether returns move together day to day; it does not guarantee that the price gap between two markets returns to a stable level. Cointegration tests that second property more directly.
What is the biggest risk in pairs trading?
A structural break: the relationship that held in the past stops holding, and the spread keeps widening. A stop on the spread and regular re-testing of the relationship are essential.
Can a single cTrader cBot trade a pair?
Yes, a cBot can request data for and trade more than one symbol. The bot must manage both legs together: size them by the hedge ratio, open and close them as one position, and handle a failed fill on one leg.
Sources and further reading
- StockCharts ChartSchool: Price Relative / Relative Strength - chartschool.stockcharts.com
- Bailey et al.: The Probability of Backtest Overfitting - papers.ssrn.com