UnityMartingale
A multi-currency expert advisor that uses the Unity indicator to detect overbought/oversold currency conditions and trades with a martingale lot-sizing strategy. It supports both breakout and pullback signal modes, includes trailing stop functionality, scheduled trading hours, and a sophisticated optimization reporting system with R-squared criterion. The EA can simultaneously manage multiple currency pairs through a strategy pool architecture.
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: Elevated
- Increases the position size after losses (martingale)
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
The strategy is based on the Unity indicator's multi-currency relative strength analysis, generating trade signals when one currency is at the maximum (overbought) and another at the minimum (oversold) among the indicator buffers. Entry conditions come in two modes: BREAKOUT mode enters in the signal direction directly, while PULLBACK mode reverses the signal direction, trading against the extreme. Exit conditions include stop loss/take profit triggers, position closure on opposing signals, and forced closure when outside scheduled trading hours. Position sizing employs a martingale strategy: after a profit, lot size resets to the base lots; after a loss, the lot is multiplied by the Factor, continuing until the Limit of multiplications is reached, at which point it resets to base lots. Money management includes free margin checks that automatically fall back to base lots when margin is insufficient, and a pause mechanism after trade errors based on the SkipTimeOnError timeout. The system also supports TrailingStop functionality and calculates equity drawdown on-the-fly in the tester to evaluate strategy performance.
Strengths
- Excellent multi-currency architecture with a strategy pool that can manage multiple symbol instances simultaneously
- Comprehensive optimization reporting system with R-squared criterion and HTML report generation for strategy evaluation
- Clean code structure using OOP design (interfaces, inheritance, smart pointers) for high maintainability
Weaknesses
- Martingale position sizing creates exponential risk growth during consecutive losses, potentially leading to account blowup
- When multiple positions are detected, only an alert is issued without handling them, leaving a position management gap
- The WorkSymbols parser's use of '-' symbol may conflict with negative numbers, reducing parsing robustness
Possible improvements
- Add maximum drawdown limits or account equity protection that forces trading stop and position closure at dangerous levels
- Replace martingale with anti-martingale or fixed fractional position sizing to reduce risk exposure during losing streaks
Risk assessment
Overall risk: Dangerous
- Martingale lot doubling creates exponential growth - Factor=2 and Limit=5 means max lot can reach 32x the initial size
- Although Limit caps the number of multiplications, a single max-lot trade can still cause catastrophic loss
- Running martingale on multiple correlated symbols simultaneously may trigger doubling across all pairs at once
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
UseTime | true | Enable trading session restrictions |
HourStart | 2 | Trading start hour(0-23) |
HourEnd | 22 | Trading end hour(0-23) |
Lots | 0.01 | Initial lot size |
Factor | 2.0 | Martingale multiplier factor |
Limit | 5 | Maximum doubling count |
StopLoss | 500 | Stop loss in points |
TakeProfit | 500 | Take profit in points |
StartType | 0 | Signal type: 0=breakout, 1=pullback |
Magic | 1234567890 | Magic number to identify this EA's positions |
SkipTimeOnError | 1 | Pause duration after trade error |
Trailing | true | Enable trailing stop |
WorkSymbols | Custom trading symbols string | |
UnitySymbols | EURUSD,GBPUSD,USDCHF,USDJPY,AUDUSD,USDCAD,NZDUSD | Currency pair list for Unity indicator |
UnityBarLimit | 10 | Bar limit for Unity indicator |
UnityPriceType | PRICE_CLOSE | Unityindicatorprice type |
UnityPriceMethod | MODE_EMA | UnityindicatorMA method |
UnityPricePeriod | 1 | Unityindicator MA period |
Similar Martingale EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.