Strategy Detail
ES/NQ Pair Spread
Trades the ES/NQ price ratio as a mean-reversion spread. Long the ratio when it stretches low, short when it stretches high, exit on z-score return to neutral.
Sample runs (3)
What It Does
ES/NQ Pair Spread runs on daily bars. On every session close where both legs printed, the strategy:
- Computes the closing price ratio
ratio = ES_close / NQ_close. - Pulls the prior
lookback_daysdaily ratios (default 60), computes their mean and standard deviation. - Computes today’s z-score:
z = (today_ratio - mean) / stdev. - If flat and
z >= entry_z(default 2.0): short the spread by selling ES and buying NQ (the ratio is high relative to history; ES is “expensive”). - If flat and
z <= -entry_z: long the spread by buying ES and selling NQ (the ratio is low; ES is “cheap”). - If in a position and
|z| <= exit_z(default 0.5): flatten both legs.
The strategy has no stops, no profit targets, no holding-period limit. The z-score crossing back through the exit band is the only exit. A spread that keeps stretching against the position is held until it eventually reverts or the backtest ends.
Why Pair Trades Get Used
ES and NQ are both US equity index futures and move together most of the time. The differences between them are driven by sector composition: NQ is concentrated in mega-cap tech, ES is more diversified. When tech outperforms the broader market for a stretch, the ratio drifts lower; when value rotates in, the ratio drifts higher. Either move tends to mean-revert over weeks to months because the underlying correlation between the two indices remains high.
A pair spread isolates this relative move. By design it has less directional exposure than a single-leg position: a 5% market crash that hits both indices equally leaves the spread unchanged. The trade pays off when the relationship between the two legs reverts, not when the market itself moves.
The flip side: when the relationship structurally changes (sector rotation that does not unwind, a regulatory event that affects one index more than the other), the spread can stretch beyond historical bands and stay there. The strategy does not detect or adapt to regime changes; it just keeps placing the same trade.
Notional Balance
ES and NQ are dollar-asymmetric futures. ES is $50 per point; at ~5000, one contract represents ~$250k notional. NQ is $20 per point; at ~20000, one contract is ~$400k notional. The default es_quantity:nq_quantity of 2:1 brings these closer to balance at typical 2020-2024 prices, but does not auto-rebalance as prices drift. Users running the strategy at very different price regimes may want to adjust the leg sizes.
Presets
Five presets cover the canonical variants:
- Classic Z=2 Both Sides: the default starting point. Trades both directions at 2-stdev entry, 0.5-stdev exit.
- Tight Z=1.5 / Wide Z=2.5: narrower or wider entry bands. Tighter fires more often with more whipsaw; wider fires rarely but with cleaner setups.
- Long Spread Only / Short Spread Only: directional variants for when you have a view on which side of the relationship is more reliable.
Best In
- Periods of moderate but persistent rotation between large-cap tech and the broader market.
- Research where you want a market-neutral baseline.
- Studies that want to test whether ES-NQ correlation breakdowns produce tradable signals.
Where It Struggles
- Sustained regime changes. A multi-year tech outperformance keeps the ratio low and the long-spread leg keeps re-entering as the spread stretches further.
- Periods of high overall market volatility. The z-score thresholds were tuned for the 2020-2024 window; in high-vol regimes the same z value represents a much larger dollar move.
- Funding cost is not modeled. Real pair trades have margin requirements on both legs and may have implicit financing costs not reflected in the backtest.
What It Does Not Do
- No stops, no targets, no time-based exit. A spread that never reverts to the exit band stays open.
- No dynamic leg sizing. The
es_quantity:nq_quantityratio is fixed per preset. - No regime detection. The strategy keeps applying the same z-score rule whether the relationship is range-bound or trending.
- No spread adjustment for index changes. NQ index reconstitutions occasionally change the basket weighting; the strategy treats prices as continuous.
Presets (5)
Named parameter bundles for this family. Pick one to see its parameters and pre-fill the New Backtest form. The form lets you adjust contract, date range, and capital before running.
Preset
Classic Z=2 Both Sides
Enter when the ES/NQ ratio crosses 2 stdev from a 60-day rolling mean; exit when it returns to 0.5 stdev. Two-sided.
Preset
Tight Z=1.5 Both Sides
Earlier entry at 1.5 stdev. Fires more often than the classic preset; expect lower win rate per trade and more whipsaw.
Preset
Wide Z=2.5 Both Sides
Only trade extreme dislocations beyond 2.5 stdev. Very rare; the few trades that fire tend to resolve cleanly.
Preset
Long Spread Only
Only takes long-the-spread setups (long ES, short NQ when ES has underperformed). Useful as a tilt against persistent NQ outperformance.
Preset
Short Spread Only
Only takes short-the-spread setups (short ES, long NQ when ES has outperformed).