Trading robot · MT5

XAUUSD Adaptive Mean Reversion EA

by BlamzKunG

This Expert Advisor for MetaTrader 5 focuses on gold trading through a combination of mean-reversion signals and a grid management system.

High risk

GitHub stars1
Forks0
Last update3 weeks ago29 Aug 2026
LicenceMIT

Overview

XAUUSD Adaptive Mean Reversion EA uses multi-timeframe filters, including exponential moving averages and ADX on the H1 timeframe, to identify trend direction while executing entries on M15 based on RSI and Bollinger Bands. The robot employs a grid with dynamic ATR-based spacing and uses martingale lot scaling to recover positions. Risk controls include an equity drawdown hard stop, emergency stop losses, and a margin level guard to prevent excessive account exposure.

Details

Author

BlamzKunG on GitHub

Type

Trading robot

Platform

MetaTrader 5 (MQL5)

Strategy

Mean reversion, Grid, Martingale, Trend following, Hedging

Markets

Gold

Timeframes

M15-H1

Risk profile

  • Uses martingale lot scaling: losses can grow fast
  • Opens a grid of orders: exposure builds up in a trend
  • Holds opposite positions at once

Input parameters

Read from XAUUSD_Adaptive_MeanReversion_EA.mq5. Defaults are the author's; change them in the EA's Inputs tab.

NameTypeDefaultDescription
InpMagicNumberulong20250301Magic Number
InpTradeCommentstringXAU_MeanRevOrder Comment Prefix
InpAllowNewEntriesbooltrueAllow Opening New Baskets
InpEntryTFENUM_TIMEFRAMESPERIOD_M15Entry Timeframe (M15 Recommended)
InpTrendTFENUM_TIMEFRAMESPERIOD_H1Trend Filter Timeframe (H1 Recommended)
InpEMA_Fastint50[H1] Fast EMA Period
InpEMA_Slowint200[H1] Slow EMA Period
InpMaxEMADiffPointsint2000[H1] Max Distance between EMA50 & EMA200 (Points)
InpADX_Periodint14[H1] ADX Period
InpMaxADXForEntrydouble28.0[H1] Max ADX for Entry (Above this = Strong Trend)
InpTrendEscapeADXdouble32.0[H1] Trend Escape ADX (Trigger Emergency Freeze)
InpRSI_Periodint14[M15] RSI Period
Show all 40 inputs
NameTypeDefaultDescription
InpBuyRSI_Leveldouble35.0[M15] Buy Oversold RSI Level (RSI < Level)
InpSellRSI_Leveldouble65.0[M15] Sell Overbought RSI Level (RSI > Level)
InpBB_Periodint20[M15] Bollinger Bands Period
InpBB_Deviationdouble2.0[M15] Bollinger Bands Deviation
InpATR_Periodint14[M15] ATR Period
InpGridATRMultiplierdouble1.4Grid Step ATR Multiplier
InpMinGridStepUSDdouble3.5Minimum Grid Step ($ USD price distance, e.g. $3.50)
InpMaxGridStepUSDdouble12.0Maximum Grid Step ($ USD price distance, e.g. $12.00)
InpMaxGridLevelsint5Maximum Grid Levels per Basket (Strict Cap)
InpLotStrategyENUM_LOT_STRATEGYLOT_STRAT_FIXEDLot Strategy (Fixed / Mild Mult / Dynamic)
InpInitialLotdouble0.01Initial Lot Size
InpLotMultiplierdouble1.15Mild Lot Multiplier (Keep <= 1.20)
InpMaxSingleLotdouble0.10Max Lot Size per Single Order
InpMaxExposureLotsdouble0.25Max Cumulative Lots in a Basket
InpRiskPerBasketPctdouble3.0Max Equity Risk % per Basket (for Dynamic Sizing)
InpTPModeENUM_TP_MODETP_MODE_HYBRIDTake Profit Mode
InpBasketTPPercentdouble0.50Basket TP (% of Balance, e.g. 0.5%)
InpBasketTPUSDdouble15.0Basket TP ($ USD Fixed, e.g. $15.00)
InpBasketTP_ATR_Factordouble0.30TP Distance from Weighted Average (ATR_M15 * Factor)
InpUseBasketTrailingbooltrueEnable Basket Trailing Stop
InpTrailStartUSDdouble10.0Trail Start Target ($ USD)
InpTrailStepUSDdouble3.0Trail Step / Lock-in Distance ($ USD)
InpEquityStopPercentdouble8.0Equity Drawdown Hard Stop % (Close All & Pause)
InpUseEmergencyATR_SLbooltrueEmergency SL based on ATR(H1) from First Entry
InpEmergencySL_ATR_Multdouble3.5Emergency SL ATR(H1) Multiplier (e.g. 3.5x H1 ATR)
InpUseTrendEscapebooltrueEnable Trend Escape Safety Cut
InpTrendEscapeMaxLossUSDdouble60.0Max Loss to Trigger Trend Escape Cut ($ USD)
InpMarginLevelFreezedouble200.0Margin Guard: Stop New Grid if Margin Level % < threshold

How to install it

  1. 1Download the sourceUse "Download source (.zip)" above, or clone BlamzKunG/XAUUSD-Grid-EA from GitHub, and unzip it.
  2. 2Open the data folderIn MetaTrader choose File, then Open Data Folder, and go to MQL5/Experts.
  3. 3Copy the filesCopy the .mq5 file into Experts.
  4. 4Compile in MetaEditorOpen the file in MetaEditor and press Compile. Fix any missing includes the compiler reports.
  5. 5Test before you tradeRun it in the Strategy Tester, then attach it to a demo chart and allow algorithmic trading.
Third-party code. ForexR did not write, test or endorse this EA, and the summary above was generated automatically from its README and code. ForexR lists only repositories with readable source code and never hosts files. Read the code, backtest it and use a demo account first; automated trading can lose money quickly.

Similar expert advisors

IchiDCA CCBSN PropFirm EA

by magicniuniu
3 stars

IchiDCA CCBSN PropFirm EA is an automated trend-following robot for MetaTrader 5, optimized for gold and forex markets. It triggers trades based on Ichimoku Cloud breaks, filtered by dual Exponential Moving Averages and MACD indicators. The strategy manages positions through a Dollar Cost Averaging system that layers u

MT5 Trading robot Trend followingGridMean reversion High risk

STO Martin

by crq644
2 stars

STO Martin is a grid-based trading robot for MetaTrader 5 that uses technical indicators to manage entries and recoveries. It employs a Stochastic Oscillator for execution signals and a Moving Average to filter trades according to the prevailing trend. The EA features a martingale lot-scaling system that adds positions

MT5 Trading robot MartingaleGridTrend following High risk
Updated 3 years ago None stated GitHub repository of STO Martin

AW Full Recovery EA

by wongthep
2 stars

This MetaTrader 5 expert advisor functions as a grid-based recovery system that can operate independently or manage trades from external EAs via magic number filtering. It initiates entries using Bollinger Bands and RSI indicators, then manages drawdown through a recovery grid matrix. The system employs dynamic ATR-bas

MT5 Trading robot GridMartingaleHedging High risk
Updated 3 months ago None stated GitHub repository of AW Full Recovery EA

Xauusd Auto Trader

by ibadnarpatih-create
2 stars

This MetaTrader 5 expert advisor is designed for trading XAUUSD using a trend-following approach. It identifies entries through a triple Exponential Moving Average crossover system, requiring ADX momentum confirmation before opening positions. To manage losing trades, the EA employs a martingale strategy that layers or

MT5 Trading robot Trend followingIndicator crossoverMartingale High risk
Updated 3 weeks ago GPL-3.0 GitHub repository of Xauusd Auto Trader

Advanced Grid Trading

by jepli-1225
2 stars

Advanced Grid Trading is a MetaTrader 5 expert advisor that manages a complex grid strategy across four configurable layers. It places stop and limit orders at fixed intervals, employing either fixed or geometric lot scaling for increased grid depth. Trade management includes a shared profit pool used to close losing p

MT5 Trading robot GridMartingaleMean reversion High risk
Updated 6 months ago None stated GitHub repository of Advanced Grid Trading
2 stars

This MetaTrader 5 expert advisor implements a multi-layered grid strategy that manages up to three independent grids simultaneously on a single instrument. It uses the Relative Strength Index (RSI) across different timeframes to determine the initial trade direction for each grid. The EA employs martingale lot scaling,

MT5 Trading robot GridMartingaleMean reversion High risk
Updated 2 years ago None stated GitHub repository of Springfield 3 Grids

More trading robots

Need a broker for MT5?

Compare regulated brokers that support MetaTrader, with spreads, minimum deposits and leverage side by side.

Compare brokers