EA Stochastic
This EA trades based on the Stochastic oscillator, entering positions when the indicator signals overbought or oversold conditions. It opens buy trades when Stochastic crosses upward from oversold zones and sell trades when it crosses downward from overbought zones. The strategy targets mean reversion opportunities in ranging or moderating markets.
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.39% | -0.34% | 3.92% | 134 | 47.80% | -0.08 | -0.10 | 5 | −$0.29 | Reliable |
| GBPUSD | -5.19% | -4.52% | 8.05% | 136 | 47.80% | -0.92 | -0.65 | 7 | −$3.82 | Reliable |
| USDJPY | +3.84% | +3.33% | 4.60% | 138 | 52.20% | 0.72 | 0.83 | 5 | +$2.78 | Reliable |
| XAUUSD | +39.20% | +31.42% | 74.01% | 148 | 53.10% | 0.87 | 0.53 | 8 | +$24.99 | Reliable |
Profitable on 2 of 4 markets with reliable results.
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.
Against the other Mean Reversion EAs with a reliable result on the same market: EURUSD: better than 63% of 30 · GBPUSD: better than 16% of 32 · USDJPY: better than 72% of 32 · XAUUSD: better than 61% of 31
Month by month
| Market | Months with a gain | Best month | Worst month |
|---|---|---|---|
| EURUSD | 38% | +1.41% 2026-01 | -1.24% 2026-10 |
| GBPUSD | 54% | +2.79% 2026-04 | -5.66% 2026-01 |
| USDJPY | 54% | +5.13% 2026-01 | -2.09% 2026-08 |
| XAUUSD | 69% | +31.38% 2026-06 | -30.39% 2026-05 |
From the backtest equity curve, sampled about every two days; only reliable results.
Blow-up risk: No blow-up pattern found
None of the usual blow-up patterns were found in the code, 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 mean reversion trading based on the Stochastic oscillator, utilizing %K and %D line crossovers along with overbought and oversold zones to determine entry timing. Entry conditions are: open a long position when the %K line crosses above the %D line from the oversold zone (typically below 20), and open a short position when the %K line crosses below the %D line from the overbought zone (typically above 80). Exit conditions typically include fixed take-profit and stop-loss levels, or closing positions when the Stochastic returns to neutral territory. Position sizing allows the user to set fixed lot sizes or calculate position size based on a percentage of account equity. Money management relies on the Stochastic indicator's inherent mean reversion characteristic, but the strategy faces the risk of consecutive losses in strong trending markets since the Stochastic can remain in overbought or oversold zones for extended periods during trends.
Strengths
- Simple and clear strategy logic based on the classic Stochastic overbought/oversold principle, easy to understand and verify
- Uses Stochastic crossover signals for entry, reducing false signals compared to single threshold triggers
- Highly configurable parameters allowing users to adjust K/D periods and overbought/oversold thresholds for different instruments and timeframes
Weaknesses
- Mean reversion strategy performs poorly in strong trending markets as the Stochastic can remain in overbought/oversold zones for extended periods causing repeated losses
- Lacks a trend filter to distinguish between ranging and trending markets, prone to counter-trend trading during trends
- Default stop-loss and take-profit are zero, presenting extreme risk of running without protective stops which could lead to catastrophic losses
Possible improvements
- Add a trend filter (such as ADX or moving average direction) to only trade mean reversion signals in ranging markets and pause trading during trending markets
- Implement mandatory stop-loss mechanism to ensure every trade has reasonable stop-loss protection, avoiding the risk of unprotected positions
- Add new bar check to prevent repeated entries on the same bar, and add spread filter to prevent entries during high spread conditions
Risk assessment
Overall risk: High risk
- Default stop-loss and take-profit are zero, trades can incur unlimited losses without any protection
- Lacks trend filter mechanism, will repeatedly open counter-trend positions during strong trends leading to consecutive losses
- No explicit new bar check, may open multiple positions on the same bar leading to excessive exposure
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
LotSize | 0.1 | Initial lot size, martingale base quantity |
Stochastic_Kperiod | 14 | Stochastic K period |
Stochastic_Dperiod | 3 | Stochastic D period (smoothing period) |
Stochastic_Slowing | 3 | Stochastic slowing value |
OverboughtLevel | 80 | Overbought threshold level |
OversoldLevel | 20 | Oversold threshold level |
StopLoss | 0 | Stop loss in points, max loss per trade |
TakeProfit | 0 | Group TP in points, close all at this profit |
MagicNumber | 12345 | EA magic number to distinguish trade instances |
Similar Mean Reversion EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.