Markets are unpredictable. Indices rise and fall, sectors rotate, and macro events can turn a well-researched position into a losing trade overnight. Yet experienced traders have long relied on a strategy that sidesteps much of this directional noise pairs trading.
At its core, pairs trading is a market-neutral strategy that profits not from the overall direction of the market, but from the relative performance of two correlated assets. When one asset moves out of sync with another, a trader simultaneously goes long on the underperformer and short on the overperformer betting that the two will eventually converge back to their historical relationship.
This guide breaks down how pairs trading works, how to identify viable pairs, and how to execute the strategy with discipline and precision.
Pairs trading was first developed in the mid-1980s by a quantitative research team at Morgan Stanley. The strategy is rooted in the concept of statistical arbitrage exploiting temporary mispricings between two assets that historically move together.
The underlying logic is straightforward: if two stocks have a strong historical correlation say, two banks, two airlines, or two oil majors their prices tend to move in tandem over time. When a divergence occurs, the expectation is that the spread will revert to its historical mean. That reversion is where the profit lies.
The appeal of tradingview pairs trading strategies is its relative insulation from broader market moves. Because you hold a long and a short position simultaneously, the strategy carries significantly reduced exposure to systemic risk. A market-wide selloff affects both legs of the trade, often leaving the spread and your P&L largely intact.
Not every two stocks with a superficial resemblance make a good pair. Identifying viable pairs requires both fundamental reasoning and statistical validation.
Fundamental Criteria
Start by looking within the same sector or industry. Two competing pharmaceutical companies, two regional banks, or two consumer staples giants are natural candidates. They face similar macroeconomic pressures, respond to the same regulatory environment, and are often driven by comparable demand cycles.
Beyond sector similarity, consider companies with comparable market capitalisations, revenue structures, and geographic exposure. The closer the fundamental profile, the more reliable the historical correlation tends to be.
Statistical Validation
Once you have a candidate pair, the numbers need to support it. The key metrics to examine are:
Correlation coefficient: A Pearson correlation above 0.80 over a meaningful historical window (typically 6–24 months) is a reasonable starting point.
Cointegration: Correlation alone is not sufficient. Two assets can be highly correlated without being cointegrated meaning their spread may drift rather than revert. The Engle-Granger or Johansen cointegration tests help confirm whether a long-run equilibrium relationship exists.
Spread behaviour: Plot the spread (the price ratio or difference) over time. A mean-reverting spread one that oscillates around a stable average is the hallmark of a tradeable pair.
Once a pair is validated, the mechanics of execution are relatively straightforward, though precision matters.
Calculating Position Size
Pairs trade are typically sized using a dollar-neutral or beta-neutral approach. Dollar-neutral means you invest an equal dollar amount in each leg. Beta-neutral goes further, adjusting for each asset's sensitivity to the broader market so that the combined position carries near-zero market beta.
For example, if Stock A has a beta of 1.2 and Stock B has a beta of 0.8, a beta-neutral position would require a larger notional size in Stock B to offset the higher market sensitivity of Stock A.
Entry and Exit Signals
The most widely used entry signal is the z-score of the spread. The z-score measures how many standard deviations the current spread is from its historical mean.
A z-score above +2 signals that the spread is unusually wide — go short the outperformer, long the underperformer.
A z-score below –2 signals the opposite.
Most traders set a target exit when the z-score reverts to 0 (the mean), with a stop-loss if the z-score moves beyond ±3 or ±4.
This rules-based approach keeps emotion out of the equation and ensures consistent trade management.
TradingView is one of the most versatile platforms for implementing pairs trading strategies. Its Pine Script language allows traders to build custom indicators and automated alerts tailored to spread analysis.
Plotting the Spread
TradingView's "Spread Chart" feature (accessed by entering a ratio like AAPL/MSFT directly in the symbol search bar) allows you to visualise the price ratio of any two assets on a single chart. From there, you can apply Bollinger Bands or custom z-score scripts to identify entry and exit zones visually.
Pine Script for Pairs Trading
With Pine Script, you can write a custom indicator that:
Calculates the rolling spread between two tickers using request.security()
Computes the mean and standard deviation of the spread over a defined lookback period
Plots z-score bands and generates alerts when thresholds are breached
This removes the need for manual monitoring and allows you to set TradingView alerts that notify you via email or SMS the moment a pair enters a tradeable zone.
Backtesting
TradingView's Strategy Tester enables you to backtest pairs trading logic directly on historical data. While it has limitations for multi-leg strategies compared to dedicated quant platforms, it offers a practical starting point for validating entry/exit rules before committing capital.
Pairs trading is not risk-free. Several specific risks deserve careful attention.
Divergence Risk
The most significant danger is that a spread continues to widen rather than revert sometimes permanently. This can happen when a fundamental change affects one company but not the other: a merger, a regulatory penalty, a product failure, or a change in management. Always monitor the news backdrop for both legs of the trade.
Liquidity Risk
Low-volume stocks can have wide bid-ask spreads, making entries and exits costly. Stick to liquid names where slippage is manageable, particularly if you are trading frequently.
Leverage Risk
Pairs trading is often executed with leverage, particularly in futures or CFD markets. While the market-neutral structure reduces directional risk, leverage amplifies losses if the spread moves sharply against you. Position sizing and stop-losses are non-negotiable.
Correlation Breakdown
Historical correlations are not permanent. Periodically re-validate your pairs what worked as a pair twelve months ago may no longer qualify today. A rolling correlation check every quarter is prudent.
Start with highly liquid large-cap pairs — indices like S&P 500 constituents offer deep liquidity and well-documented correlations.
Keep the lookback period consistent — whether you use 60 days or 252 days, apply the same window across all pairs for comparable z-score signals.
Trade smaller during high-volatility regimes — spreads behave differently during crises. Reduce position size when VIX is elevated.
Keep a trade journal — document your entry rationale, spread levels, and exit results. Pattern recognition improves over time.
Pairs trading rewards patience, analytical rigour, and disciplined execution. It is not a strategy for traders chasing fast, directional momentum it is for those who understand that markets occasionally misprice relationships and are willing to wait for those mispricings to correct.
By combining sound fundamental pair selection with statistical validation, precise position sizing, and tools like TradingView for monitoring and alerting, traders can build a systematic, market-neutral edge that performs across a range of market conditions.
The market will always create noise. Pairs trading is about finding the signal within it.