NeuroBacktest
Back to BlogStrategy

Pairs Trading: A Cointegration Strategy Guide

June 16, 2026 9 min read

By Daniel Chau

Founder, NeuroBacktest

Learn how to build a statistical arbitrage pairs trading strategy using cointegration, the z-score, and backtesting best practices.

Pairs trading is a market-neutral strategy that profits when the price relationship between two historically linked assets returns to its mean. It is one of the most popular forms of statistical arbitrage.

Correlation vs Cointegration

Two assets can move together (correlation) without necessarily returning to a stable ratio. Cointegration is stronger: it means the spread between the two prices is mean reverting over time. Pairs traders prefer cointegrated pairs.

The Z-Score Signal

Traders typically normalize the spread to a z-score. When the z-score exceeds +2, they short the outperforming asset and buy the underperforming one. When the spread returns to zero, they close the positions.

Backtest Pairs in NeuroBacktest

Try: "Backtest a pairs trading strategy on PEP and KO using a 2-standard-deviation z-score entry and a 0.5 z-score exit from 2015 to 2024."

Frequently Asked Questions

What is pairs trading?

Pairs trading is a market-neutral strategy that takes a long position in one asset and a short position in a related asset when their price ratio diverges from its historical mean.

What is cointegration?

Cointegration means two price series move together over time even if they drift apart temporarily. It is the statistical foundation of most pairs trading strategies.

How is the z-score used in pairs trading?

The z-score measures how far the price ratio has deviated from its mean. Traders often enter when the z-score exceeds ±2 and exit when it returns toward zero.