Free strategy check — send your trading rules and we tell you within 24 hours if they can be automated. No obligation. Send your rules →
Arbitrage18 Sep 2026 · Eye Algo

Statistical arbitrage trades two related instruments whose price difference (the spread) tends to return to its average. This article explains the Z-score in plain terms, shows a simple rule set, and covers the points that decide whether such a model is workable in practice.

What the spread is

Take two instruments that usually move together, such as two similar stocks, a spot price and a futures price, or two related currency pairs. Subtract one from the other, after adjusting for a ratio if needed, and you get the spread. If the relationship is stable, the spread wanders around an average level instead of drifting away forever. Statistical arbitrage tries to trade those wanders back toward the average.

The Z-score

The Z-score tells how far today's spread is from its recent average, measured in standard deviations: Z = (spread − average) ÷ standard deviation. A Z-score of +2 means the spread is unusually wide.

The average and standard deviation are calculated over a lookback window, for example the last 100 or 200 bars. The window length is a key setting. A short window reacts quickly but gives noisy signals. A long window is steadier but slow to adapt.

A simple rule set

  • Enter when Z goes above +2 (sell the spread) or below −2 (buy the spread).
  • Exit when Z returns near 0.
  • Stop out if Z keeps moving, for example beyond ±3.5.

Selling the spread means selling the expensive leg and buying the cheap one at the same time, so the position depends on the gap closing, not on the market going up or down. The thresholds above are examples, not recommendations. The right values depend on the pair and must be tested.

Why the model can fail

The relationship between the two instruments can change. A company event, a policy change or a shift in market structure can break the link, and the spread may never come back. A model that keeps adding to a widening spread can lose a lot. That is why the model needs a stop and regular review.

  • Check that the pair is still related, for example with a rolling correlation or a spread stability test.
  • Use a hard stop based on Z or on money lost.
  • Limit the total exposure the model can hold.
  • Review the lookback window and thresholds on a schedule.

Costs and execution

Every entry and exit has spreads, commissions and possibly swaps on two legs. A signal that looks good on a chart can disappear after costs. Execution matters too: both legs should be sent close together, and the EA should check that both filled. If one leg fails, the position is no longer a hedge and the EA should repair it quickly. Our article on arbitrage between MT4 and MT5 terminals covers the technical side of this.

Note: Backtests of mean reversion often look smooth until the relationship breaks. Test on long data that includes volatile periods, and remember that past results do not predict future ones.

Building it as an EA or bot

A Z-score model is straightforward to code once the rules are written down: the instruments, the lookback, the thresholds, the position size, and the stops. We build these as MetaTrader EAs, or as Python bots when the instruments sit on different platforms. See our arbitrage systems page for the scope. Arbitrage projects start at Rs 25,000 and usually take 1 to 4 weeks, and the pricing page lists the other tiers. You get a working demo before final payment.

Choosing and checking a pair

The model is only as good as the pair. Two instruments that look related for a few months may not stay related. Before trading, look at a long history and ask whether there is a clear economic reason for the link. Futures and their underlying spot price are tied by cost of carry, so the spread has a natural anchor. Two unrelated stocks that happened to move together are a weaker choice, because nothing forces them back.

  • Use enough data to cover calm and volatile periods.
  • Check that the spread crosses its average many times, instead of trending for long stretches.
  • Recalculate the hedge ratio from time to time if the two prices do not move one for one.
  • Keep position size small until the model has run live for a while.

Another practical point is how the Z-score is recalculated. If it is recalculated on every tick, the signal can flicker around the threshold. Many systems use closed bars, or require the Z-score to stay beyond the threshold for a short time, to reduce false entries. These choices are part of the rule set and should be written down before coding so the EA does exactly what you intend.

Frequently asked questions

Is Z-score arbitrage risk free?

No. Despite the word arbitrage, statistical arbitrage is a bet that a relationship will hold. If it breaks, losses can be large. Use stops and position limits.

What lookback window should I use?

There is no universal value. It depends on the instruments and the timeframe, and should be chosen by testing on enough data and then reviewed from time to time.

Can you code my own Z-score rules?

Yes. Send your entry, exit and stop rules on the contact page and we will give a written quote after the rules are reviewed. A free strategy check is available first.

Have a strategy you want automated?Get a free strategy check
← All articles