PairTrading
- Experts
- Version: 1.0
- Activations: 5
PAIR TRADING: multi-currency pair trading (statistical arbitrage) Expert Advisor
The EA trades pairs of correlated instruments. When two related instruments drift apart further than usual, it opens a hedged pair: it sells the one that ran ahead and buys the one that lagged. The pair is closed on its total profit once the divergence returns to the mean.
How it works
- For every pair the EA measures the current correlation and its stability on history. A pair with weak or unstable correlation is not traded.
- Divergence is measured in points, adjusted for the volatility ratio of the two instruments. Entry is taken when the divergence reaches a set percentage of its historical maximum (75% by default).
- If the divergence keeps growing, the pair is averaged through a trailing virtual order: a new step opens only after the divergence turns back. The number of steps and the total volume are capped.
- Exits: pair profit target, divergence back at zero, total account profit percentage, equity growth per cycle.
- Protection: per-pair loss limit (percent of balance or money), close on correlation breakdown, margin level check before every entry, pause after a failed order.
Features
- Any number of pairs in a single EA. Pairs and per-pair settings are comma-separated lists; broker symbol suffixes are supported.
- Attach to one chart of any symbol and timeframe.
- Works on hedging and netting accounts (on netting, pairs must not share symbols).
- Built-in full-chart dashboard: correlation, divergence with the entry threshold, positions, profit and statistics per pair, and an event log. Buttons disable a pair or close it manually.
- No directional bets: the result depends on prices converging inside a pair, not on the trend.
Default pairs
EURGBP/GBPCHF, EURJPY/CHFJPY, AUDCAD/NZDUSD, EURUSD/USDCHF (calculation timeframe M5).
Recommendations
- Hedging account, low spreads and commissions (ECN), leverage 1:100 or higher.
- Deposit from 1000 USD with 0.01 lot per 1000 of balance (LotPer1000).
- Run 24/5 on a VPS.
- Backtest with "Every tick based on real ticks". In "1 minute OHLC" mode the tester generates each symbol's ticks separately. That creates false divergences between instruments and inflates the result.
Main inputs
- Symbols1 / Symbols2: first and second instruments of the pairs.
- FixedLot / LotPer1000: fixed lot or lot from balance.
- LotMultiplier, MaxOrders, MaxLot: averaging multiplier and caps.
- CorrOpenMin, CheckHistoryCorr, CorrHistoryMin: correlation filters.
- EntryPercent: entry threshold as a percent of the maximum divergence.
- ProfitDivider, MinPairProfit: pair profit target.
- PairLossPct / PairLossMoney, DisableAfterLoss: loss limit.
- EquityTargetPct, TotalProfitPct: close all pairs at an account-level target.
- MinMarginLevel: minimum margin level after an entry.
Risks
Correlation between instruments can weaken or break. The divergence then does not return and the pair is closed at its loss limit. Averaging increases the position size. Raise the lot only after testing on real ticks and on a demo account. Past results do not guarantee future results.
