Contrarian trade MA
This EA implements a contrarian mean-reversion strategy using moving averages. It enters trades against the prevailing trend when price deviates significantly from a moving average, anticipating a reversion to the mean. The strategy opens positions on pullbacks and manages exits via take-profit and stop-loss levels.
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
- Has no stop loss or trailing stop
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
The core strategy concept is contrarian trading, entering positions against the prevailing move when price deviates significantly from a moving average, anticipating a mean reversion. Entry conditions are triggered when price deviation from the MA exceeds a predefined threshold — going short when price is overextended above the MA and going long when price is oversold below the MA. Exit conditions rely on fixed take-profit and stop-loss levels in points, with TP set near the mean reversion target and SL placed where the deviation would continue to widen. Position sizing uses a fixed lot approach with no dynamic lot calculation or ATR-based adaptive sizing. Money management lacks percentage-based risk control and does not adjust position size based on account balance or volatility, making the overall risk management relatively simplistic.
Strengths
- Clear contrarian logic that performs well in ranging markets
- Uses MA deviation as entry signal, concept is intuitive and easy to understand
- Has defined TP/SL providing a basic risk control framework
Weaknesses
- Fixed lot sizing without dynamic position management cannot adjust exposure to account risk
- Contrarian strategy suffers continuous losses in strong trending markets, lacks trend filter
- Missing new bar check may cause repeated entries on the same candle
- No spread filter makes it vulnerable in high-spread conditions
Possible improvements
- Add a trend filter (e.g., ADX or higher timeframe MA direction) to avoid counter-trend entries during strong trends
- Introduce dynamic position sizing based on account equity percentage or ATR
- Add new bar check and spread filter to improve execution quality
Risk assessment
Overall risk: Medium
- Fixed lot sizing without dynamic risk control leads to disproportionate exposure with larger accounts
- Contrarian approach can result in consecutive stop-losses during strong directional moves
- Missing new bar check may cause duplicate entries on the same candle
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
Lots | 0.1 | Fixed trading lot size |
MAPeriod | 200 | Moving average period |
MAMethod | MODE_SMA | Moving average calculation method |
MAPrice | PRICE_CLOSE | Moving average applied price type |
Deviation | 500 | Price deviation from MA in points threshold |
StopLoss | 300 | Stop loss in points |
TakeProfit | 500 | Overall take profit target in points |
MagicNumber | 123456 | EA magic number for trade identification |
Similar Mean Reversion EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.