EA-11777 · Statistical Arbitrage

Double trading

This EA implements a pairs trading / statistical arbitrage strategy by simultaneously opening opposite-direction positions on two correlated currency pairs when their correlation reaches a threshold. It monitors combined profit of both positions and closes them when the total profit target is hit, while also relying on StopLoss/TakeProfit as fallback exits. Auto mode determines trade direction based on session-specific currency strength assumptions.

Open the interactive view (equity curve, symbol switch)

Key facts

RiskHigh risk
Blow-up riskLow
Rating★★☆☆☆
TypeTrading EA
TimeframesH1, H4, D1
IndicatorsCorrelation (Custom)
AuthorMetaQuotes Software Corp.

Backtest results (H1, about 1 year)

SymbolP&LAnnualMax DDTradesWin rateSharpeRecoveryLosing streakPer tradeStatus
EURUSD0.00%0.00%0.00%0—————Not convertible yet
GBPUSD0.00%0.00%0.00%0—————Not convertible yet
USDJPY0.00%0.00%0.00%0—————Not convertible yet
XAUUSD0.00%0.00%0.00%0—————Not convertible yet

Why this EA never traded: no entry rule survived the conversion.

Converted from MQL5 to Python and run with the same rules for every EA. Positions use MT5 lot sizes (100,000 units per FX lot, 100 oz per gold lot) with 1:100 leverage, one order at a time, and a stop-out below 10% of the starting balance. Sharpe is computed from the equity curve. Results marked as unreliable are shown for completeness only.

Blow-up risk: No blow-up pattern found

  • Can hold up to 2 positions at once

On its own this is not a typical blow-up pattern, and the account was not stopped out in our backtests. That is not a guarantee: any EA can lose money.

High: stopped out in our backtest, or martingale/grid sizing without a stop loss. Elevated: martingale or grid sizing with a stop loss, or several positions at once without a stop loss. What the label means and what we found →

Strategy analysis

Strategy concept: This EA performs statistical arbitrage based on the correlation between two currency pairs, opening positions when the correlation coefficient approaches a threshold (-0.98 ± 0.003). Entry conditions: triggered when CorrelationBuffer[0] falls within Open_Value ± Demis_Value range, the current day is an allowed trading day, and no positions are open. In auto mode, trade direction is determined by session-based currency strength assumptions (e.g., EUR/CHF/GBP are dominant during European session); in default mode (AutoD) the two pairs open opposite directions, while mirror mode (AutoM) opens same-direction positions. Exit conditions: both positions are closed simultaneously when combined profit reaches the Profit parameter (default 20), or when one position hits SL/TP, the EA waits for the other to also be stopped out or take profited. Position sizing: two independent lot sizes Lot1 and Lot2 (default 1 and 1.3), with no dynamic scaling logic. Money management: no dynamic money management; fixed lot trading with wide SL/TP of 5000 points each.

Strengths

  • Clear pairs trading logic based on correlation with theoretical foundation for statistical arbitrage
  • Auto mode adds flexibility by determining trade direction based on session-specific currency strength
  • Combined profit target exit mechanism helps lock in arbitrage gains from paired positions
  • Trading day filter allows avoiding inactive or high-risk trading sessions

Weaknesses

  • Sleep() calls block the OnTick thread, preventing the EA from responding to other events and severely degrading platform stability
  • After SL/TP hit, polling history deals in an infinite loop to detect the other position's exit is fragile and risks infinite hangs
  • When one position hits SL/TP, the other may run with unlimited floating loss — a significant risk exposure gap
  • Correlation signal depends on an external custom indicator with no existence check or error handling if missing
  • Garbled encoding of Russian comments severely hurts readability and maintainability
  • Using StringLen()==3 to detect Buy vs Sell is extremely fragile, relying on hardcoded string length instead of content comparison

Possible improvements

  • Remove Sleep() blocking calls and replace with a state-machine approach in OnTick to handle order lifecycle without blocking the main thread
  • Add emergency close logic for the remaining position when one side hits SL/TP, preventing unlimited unilateral risk exposure
  • Replace history deal polling with PositionSelect/PositionGetTicket for proper position state management
  • Replace StringLen()==3 direction check with content-based comparison (e.g., StringCompare) for robustness
  • Add existence check for the Correlation custom indicator and disable trading with error message if missing

Risk assessment

Overall risk: High risk

  • Sleep() blocks OnTick thread, potentially freezing the platform and preventing timely event processing
  • No protection for the remaining position after one side hits SL/TP — unlimited floating loss possible
  • SL/TP detection uses while(1) infinite loop with Sleep polling, creating deadlock risk
  • Default 5000-point SL is extremely wide, allowing very large per-trade losses
  • No validation for external Correlation indicator — failed load may produce incorrect signals

Evaluation scores

Code quality2.0
Strategy logic3.0
Risk management1.0
Robustness1.0
Innovation3.0
Documentation1.0
Overall1.8

Parameters

ParameterDefaultDescription
Lot11Trading lot size for 1st currency pair
Lot21.3Trading lot size for 2nd currency pair
StopLoss5000Stop loss in points
TakeProfit5000Take profit in points
Profit20Target combined profit for both positions (in currency)
Money2USDCHFSymbol for 2nd currency pair
Money1_SELL_or_BUYAuto1st pair direction: SELL/BUY/Auto
Money2_SELL_or_BUYAuto2nd pair direction: SELL/BUY/Auto
AutoAutoMAuto trade mode: AutoD=Hedge(opposite), AutoM=Mirror(same)
Try10Max order retry attempts
MondaytrueAllow trading on Monday
TuesdaytrueAllow trading on Tuesday
WednesdaytrueAllow trading on Wednesday
ThursdaytrueAllow trading on Thursday
FridayfalseAllow trading on Friday
Open_Value-0.98Correlation coefficient threshold for opening
Demis_Value0.003Correlation coefficient tolerance range (+/-)
Depth50Correlation calculation depth (bar count)
AppliedPricePRICE_WEIGHTEDPrice type for correlation calculation

Similar Statistical Arbitrage EAs

Backtests are historical simulations and do not guarantee future results. Not financial advice.

Get the weekly Arena report

One email a week: ranking changes, new signals and new research. No spam; unsubscribe any time.