PairTrade
- Experts
- Version: 2.22
- Activations: 20
PairTrade EA – Intelligent Pair Trading System
📊 About the EA
PairTrade EA is an automated trading system built on the fundamental principle of Pairs Trading. The strategy is based on statistical arbitrage between two correlated instruments.
The core concept is simple yet effective: the bot simultaneously opens two trades on different but historically correlated instruments in opposite directions. The algorithm calculates the current divergence (spread) between currency pairs, sells the leading instrument, and buys the lagging one, anticipating their return to the mean value.
🔑 Key Features
✅ Intelligent Position Management – the system adds volume as divergence increases, allowing averaging without losing control over the deposit.
✅ Cascading Closure – losing positions are closed gradually, reducing the psychological and financial burden on the trading account.
✅ Martingale Module – optional lot increase system for aggressive loss recovery (can be disabled if needed).
✅ Flexible Correlation Setup – suitable for any pairs: currencies (EURUSD/GBPUSD), metals (XAUUSD/XAGUSD), indices, cryptocurrencies.
✅ Automatic Volume Calculation – smart mechanism for balancing volumes in USD for pure arbitrage.
Please review the settings:
-
// First instrument - Symbol1 = "EURUSD"; – Sets the first trading symbol.
-
// Second instrument - Symbol2 = "GBPUSD"; – Sets the second trading symbol.
-
// Base trade amount for Symbol1 (USD) = 1000.0; – Setting for matching metals (e.g., XAUUSD and XAGUSD).
-
// Manual coefficient for Symbol2 = 1.0; – Difference in lot sizes between Symbol1 and Symbol2. For Symbol1 = XAUUSD and Symbol2 = XAGUSD, set this to 5.0 (or according to your broker's conditions) so that the position volumes in USD are roughly equal.
-
// Automatically adjust volume by price – If false, the forced lot difference from the setting above is used. If true, automatic calculation is used (may not always calculate correctly; it is recommended to set the difference manually for metals).
-
// Invert trades (BUY↔SELL) – Inverts signals to the opposite direction.
-
// Base spread step (%) = 0.2; – Currency divergence. If the pairs are strongly correlated, set up to 0.5; if the correlation is weak, increase the value.
-
// Use progressive threshold (depends on cells count) = true; – Uses progressive calculation for subsequent divergence steps (each new step is larger than the previous one by the step value – recommended). If false, linear steps with equal divergence are used.
-
// Use daily spread for direction (if false – fixed until recovery) = false; – If false, the next step opens in the same direction as previous losing steps. If true, the next step opens according to the daily currency divergence.
-
// Lot multiplier = 1.5; – The lot increase factor for the next step.
-
// Sum lots from several cells = true; – Enables summing of losing positions for recovery.
-
// Number of cells for summing = 2; – How many losing positions to take for recovery.
-
// Take cells from the end of the array = true; – If true, recovery starts from the last losing positions. If false, recovery starts from the first losing positions.
-
// Enable maximum lot control = true; – Enables maximum lot limit.
-
// Maximum allowed lot size = 0.9; – The maximum lot size allowed.
-
// true - stop EA, false - reset (restart) – Choose whether to stop the EA or reset to the beginning when the maximum lot is reached.
-
// Enable debug prints (disable in tester) – Outputs debug information.
-
// Magic number – Unique identifier for the EA.
-
// Slippage (points) – Allowed slippage.
-
// Trade comment = "PairTrade"; – Comment for trades.
⚠️ Important Warning
Before using on a live account, always test the strategy on a demo account for 1–2 weeks. Carefully review the maximum drawdown and initial deposit figures in historical tests. Make sure the selected parameters match your risk profile and capital size.
