Mean Reversion Gold
- Uzmanlar
- Sürüm: 1.0
An Expert Advisor for gold (XAU/USD) built on the classic, time-tested concept of price reverting to its mean.
No martingale, no grid, no averaging — one trade, one stop.Thanks to adaptive ATR-based logic, separate parameter sets for bull and bear markets, and a multi-layered system of filters (volatility, trend, volume, news, trading hours), Mean Reversion takes only "its own" moves and performs confidently in any market conditions.
Key advantages:
-
Honest risk management with no averaging:
- Auto lot — trade volume is calculated automatically from the account balance and a specified risk percentage (Risk per Trade).
- An individual Stop Loss for every trade, measured in ATR units — the stop size automatically adapts to current market volatility.
- An individual Take Profit in ATR units. -
Separate logic for bull and bear markets.
The EA determines the global market regime (bullish/bearish) using a trend moving average on a higher timeframe (D1 by default) and applies fully independent parameter sets for each regime: its own Bollinger Bands, RSI and trend SMA periods, its own entry levels, take profits and stops. Either regime can be disabled with a single checkbox. -
Dynamic targets (Take Profit Decay).
If the price fails to reach the target for too long, the EA gradually pulls the Take Profit toward the current price to close the lingering trade at a reasonable profit or breakeven, without waiting for a reversal against the position. -
Powerful built-in market filters:
- Bollinger Bands channel width filter (in ATR units) — cuts off trading in an overly narrow flat market or in overly wide chaos.
- ADX trend strength filter — prevents standing against a strong runaway move and filters out a "dead" market.
- ATR Spike Filter — completely blocks entries during abnormal volatility spikes (crisis moves, "black swans").
- Tick Volume Filter — blocks entries in an abnormally empty or overheated market.
- News Filter — a fully automatic news filter. It avoids major macroeconomic events by blocking trading before and after their release (in the tester, a built-in calendar covering 01.01.2017–01.08.2026 is used). -
Time management and gap protection.
Trading takes place only during liquid hours (the list of excluded hours is configurable). On Friday, the EA moves profitable positions to breakeven in advance and then force-closes all trades before the end of the session — you never carry open risk into the weekend. -
Fast and accurate testing.
Deep optimization of the algorithm to operate on the close of the one-minute candle (Sync to M1 bar) enables fast and reliable testing in "OHLC on M1" mode.
EA parameters:
General Settings
- Risk per Trade (%) — the percentage of the balance risked per trade (the lot size is calculated automatically from the stop size).
- Trend Alignment Timeframe — the timeframe for determining the global market regime (D1 recommended).
- Trend MA Period — the period of the moving average used to classify the market as bullish or bearish.
- Enable Bullish trend — allow opening new trades in the bullish regime.
- Enable Bearish trend — allow opening new trades in the bearish regime.
- Max Spread (in pips) — the maximum allowed spread for opening positions.
- Max Slippage (in pips) — the maximum slippage in pips.
- Sync to M1 bar — synchronizes calculations with the close of the M1 candle (significantly speeds up testing in OHLC M1 mode and makes it accurate).
- Magic Number — a unique identifier for the EA's trades.
- Trade Comment — the comment attached to orders.
- Info Panel — enable/disable the info panel on the chart.
Bullish trend (Bull market parameters)
- Bollinger Bands Period / Deviation — the Bollinger Bands period and deviation for finding the channel boundaries.
- RSI Period — the RSI indicator period.
- RSI Buy Level / RSI Sell Level — RSI levels for detecting buy and sell entry patterns.
- Trend SMA Period — the period of the trend moving average used to determine the local trend.
- Take Profit (in ATR) — the take profit size in ATR units.
- Stop Loss (in ATR) — the hard stop loss size in ATR units.
Bearish trend (Bear market parameters)
- A fully independent set of the same parameters (Bollinger Bands, RSI, Trend SMA, Take Profit, Stop Loss) — optimized separately for gold's behavior during a decline phase.
Trading Session
- Broker GMT Offset (Winter / Summer) — your broker's winter and summer time offset relative to GMT. Required for correct backtesting of the news filter and trading hours!
- Excluded Hours — a comma-separated list of hours during which trading is prohibited.
News Filter
- Enable News Filter — enable automatic news filtering (uses the built-in MT5 calendar on live accounts and its own database in the tester, loaded for the period 01.01.2017–01.08.2026).
- Block Before / After News (hours) — how long trading is blocked before and after a news release (in hours).
Recommendations:
- !!! When backtesting, make sure to correctly set your broker's winter and summer time offset relative to GMT. This is required for the trading hours and news filters to work correctly.
- Any timeframe — the EA works on the required timeframe by itself.
- Symbol — gold (XAUUSD).
- Recommended broker/account — one with a low spread on gold.
- Recommended deposit — from $500.
- The default settings (2% risk) are reliable. For more aggressive trading, increase Risk per Trade.
- You can test and optimize in OHLC on M1 mode, since all position openings/closings are based on the close of the M1 bar (this can be disabled in the settings).
- Before using the EA on a live account, be sure to test it in the Strategy Tester — on the same account you will be trading from.
