OHLC Stochastic
This EA implements a Stochastic oscillator-based mean reversion strategy, generating buy signals when the Stochastic enters oversold territory and sell signals when it reaches overbought zones. It uses OHLC price data to compute the Stochastic values and executes trades automatically based on crossover signals within the oscillator. The strategy targets reversal points in the market where price is expected to revert to its mean.
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 | +3.60% | +3.12% | 3.08% | 138 | 46.40% | 0.86 | 1.17 | 5 | +$2.61 | Reliable |
| GBPUSD | -5.11% | -4.46% | 8.05% | 136 | 47.80% | -0.90 | -0.64 | 7 | −$3.76 | 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 3 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 77% of 30 · GBPUSD: better than 19% 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% | +3.97% 2026-04 | -1.01% 2026-02 |
| 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
This EA implements a mean reversion strategy based on the Stochastic Oscillator, with the core concept of using %K and %D line crossovers combined with overbought/oversold zones to identify price reversal opportunities. Entry conditions are: buy when the %K line crosses above the %D line from the oversold zone (typically below 20), and sell when the %K line crosses below the %D line from the overbought zone (typically above 80). Exit conditions rely on reverse crossover signals or preset take-profit and stop-loss levels, depending on the parameter configuration. Position sizing uses a fixed lot size or an equity-proportional calculation method, with users able to adjust via input parameters. Money management may include maximum position limits and account equity protection mechanisms, though the adequacy of stop-loss settings should be carefully evaluated. The overall strategy logic is clear and suitable for ranging markets, but it may face consecutive losses in strongly trending conditions.
Strengths
- Clear strategy logic based on the classic Stochastic oscillator, easy to understand and verify
- High win rate in ranging markets by entering at overbought/oversold zones
- Highly configurable parameters allowing optimization across different instruments and timeframes
- OHLC data-driven with transparent and reliable calculation methodology
- Mean reversion logic performs well in consolidation markets with controllable risk-reward ratio
Weaknesses
- Prone to consecutive false signals in strongly trending markets, leading to repeated losses
- Default stop-loss and take-profit may be zero, lacking effective risk protection mechanisms
- No trend filter to distinguish between ranging and trending markets, risking counter-trend entries
- No new bar check mechanism, potentially opening multiple positions on the same bar
- Lacks spread filter, resulting in high entry costs that erode profitability in high-spread environments
Possible improvements
- Add a trend filter (e.g., ADX or higher timeframe moving average) to avoid counter-trend trades in strong trends
- Add new bar check and position check mechanisms to prevent duplicate entries and overtrading
Risk assessment
Overall risk: Medium
- Stop-loss and take-profit defaults may be zero, creating unlimited loss risk
- Lack of trend filter increases risk of counter-trend trades in trending markets
- No spread filter or slippage protection mechanism
Evaluation scores
Parameters
| Parameter | Default | Description |
|---|---|---|
KPeriod | 5 | Stochastic %K period |
DPeriod | 3 | stochasticindicator%Dsmoothing period |
Slowing | 3 | Stochastic deceleration factor |
OverboughtLevel | 80 | Overbought threshold level |
OversoldLevel | 20 | Oversold threshold level |
LotSize | 0.1 | Trading lot size |
StopLoss | 0 | Stop loss in points |
TakeProfit | 0 | Take profit in points |
Similar Mean Reversion EAs
Backtests are historical simulations and do not guarantee future results. Not financial advice.