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
Backtest results (H1, about 1 year)
| Symbol | P&L | Annual | Max DD | Trades | Win rate | Sharpe | Recovery | Losing streak | Per trade | Status |
|---|---|---|---|---|---|---|---|---|---|---|
| EURUSD | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | Not convertible yet |
| GBPUSD | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | Not convertible yet |
| USDJPY | 0.00% | 0.00% | 0.00% | 0 | — | — | — | — | — | Not convertible yet |
| XAUUSD | 0.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
Parameters
| Parameter | Default | Description |
|---|---|---|
Lot1 | 1 | Trading lot size for 1st currency pair |
Lot2 | 1.3 | Trading lot size for 2nd currency pair |
StopLoss | 5000 | Stop loss in points |
TakeProfit | 5000 | Take profit in points |
Profit | 20 | Target combined profit for both positions (in currency) |
Money2 | USDCHF | Symbol for 2nd currency pair |
Money1_SELL_or_BUY | Auto | 1st pair direction: SELL/BUY/Auto |
Money2_SELL_or_BUY | Auto | 2nd pair direction: SELL/BUY/Auto |
Auto | AutoM | Auto trade mode: AutoD=Hedge(opposite), AutoM=Mirror(same) |
Try | 10 | Max order retry attempts |
Monday | true | Allow trading on Monday |
Tuesday | true | Allow trading on Tuesday |
Wednesday | true | Allow trading on Wednesday |
Thursday | true | Allow trading on Thursday |
Friday | false | Allow trading on Friday |
Open_Value | -0.98 | Correlation coefficient threshold for opening |
Demis_Value | 0.003 | Correlation coefficient tolerance range (+/-) |
Depth | 50 | Correlation calculation depth (bar count) |
AppliedPrice | PRICE_WEIGHTED | Price type for correlation calculation |
Similar Statistical Arbitrage EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.