RepositoryMQL5
MT5-Automation-Labs

MT5-Automation-Labs/mt5-gold-scalper-ea

MT5 gold (XAUUSD) M1 scalper EAs: Z-score mean reversion plus trend breakout, with dynamic equity risk tiers, session window, spread filter and cost-aware broker-side take-profit.

135sao
1fork
0issue
2lượt xem

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: breakout

#1 Repository của ngày

1
TINIX TRENDING·Chủ đề: expert-advisor

#1 Repository của ngày

1
TINIX TRENDING·Chủ đề: gold-scalper

#1 Repository của ngày

mt5-gold-scalper-ea

License: MIT Platform Language Symbol

MetaTrader 5 Expert Advisors that scalp gold (GOLD / XAUUSD) on M1 by trading statistical extremes back toward the mean.

The recommended build is TickRobust. It decides once per closed bar, refuses trades whose expected snap-back does not clear round-trip cost, and places the take-profit as a broker-side limit at the moving average. The other files are earlier mean-reversion builds and a dual-strategy variant kept for comparison.

Which file to run

BuildSourceMagicUse it when
TickRobust (recommended)Experts/XAU_Quant_Reversion_TickRobust.mq5777555Live trading and Every Tick testing
M1 OHLCExperts/XAU_Quant_Reversion_M1_OHLC.mq5777333Research on the bar-close Z-score model with spread, velocity, and trade-log filters
M1 Every TickExperts/XAU_Quant_Reversion_M1_EveryTick.mq5777333Comparing the original tick-by-tick Z-score scalper
Dual strategyExperts/XAU_Quant_Reversion_Breakout.mq5777333 / 777444Running mean reversion and a Donchian breakout on one chart

M1 OHLC, M1 Every Tick, and the mean-reversion leg of the dual strategy share magic 777333. Attach only one of those to an account, or change InpMagic, or they will manage each other's positions.

All four expect an M1 chart. The symbol input defaults to GOLD and falls back to XAUUSD when GOLD is not in the terminal.

Requirements

  • MetaTrader 5 with MetaEditor
  • A gold symbol quoted in points (SYMBOL_POINT). Stops in this project are points, not pips
  • The terminal economic calendar, if the news filter stays enabled
  • AutoTrading enabled on the account and on the chart

Installation

  1. Copy the .mq5 files from Experts/ into the terminal data folder: MQL5/Experts/.
  2. Open each file in MetaEditor and compile (F7). A successful compile writes a matching .ex5 beside the source.
  3. In MetaTrader 5, attach the Expert Advisor to a GOLD or XAUUSD chart set to M1.
  4. Confirm the inputs, then enable AutoTrading.

Compiled binaries are not stored in this repository.

Repository layout

Experts/                                   Deployable Expert Advisors
  XAU_Quant_Reversion_TickRobust.mq5       Closed-bar mean reversion (recommended)
  XAU_Quant_Reversion_M1_OHLC.mq5          Bar-close Z-score build
  XAU_Quant_Reversion_M1_EveryTick.mq5     Tick-level Z-score build
  XAU_Quant_Reversion_Breakout.mq5         Mean reversion plus Donchian breakout
reference/
  IdealEA_1mOHLC.txt                       Earlier source snapshot, not for deployment

Renames from the previous flat layout:

Previous pathCurrent path
XAU_Quant_Reversion_TickRobust.mq5Experts/XAU_Quant_Reversion_TickRobust.mq5
XAU_Quant_Reversion_m1_OLHC.mq5Experts/XAU_Quant_Reversion_M1_OHLC.mq5
XAU_Quant_Reversion_m1_EveryTick.mq5Experts/XAU_Quant_Reversion_M1_EveryTick.mq5
XAU_Quant_Reversion_Breakout.mq5Experts/XAU_Quant_Reversion_Breakout.mq5
IdealEA_1mOHLC.txtreference/IdealEA_1mOHLC.txt

The OHLC filename spelling is corrected from OLHC to OHLC. Recompile after updating an existing terminal copy.

Strategy

Price is scored against a simple moving average:

Z = (price - SMA) / StdDev

A large negative Z is a downside stretch (buy candidate). A large positive Z is an upside stretch (sell candidate). Entries are allowed only while the market looks like a range: ADX is capped, ATR must sit inside a band around its recent average, spread is capped, and the session is limited to broker hours 10:00–20:00.

Shared protective behaviour on every build:

  • High-importance USD calendar events only. New entries pause before and after the event. Open trades can be flattened before the release.
  • A daily loss limit, expressed as a percent of the day's starting balance. After it trips, positions managed by that magic are closed and new entries stop until the next day.
  • Friday flatten at InpFridayCloseHour (default 20:00) and a weekend block on the three single-strategy files.
  • Position size from the stop distance and a risk percent of balance, checked against free margin before OrderSend.

TickRobust

TickRobust is the build written so Every Tick results and closed-bar results describe the same decisions.

Decisions that can wait — entry, Z-score exit, time exit, breakeven, and take-profit retargeting — run once, at the open of a new bar, from shift-1 values. Intra-bar, only the server-side stop and take-profit can change the position. Daily-loss, weekend, and pre-news closes still run on the tick, because those are account-safety actions.

Entry, all required

RuleDefault
Closed-bar Z at or beyond the thresholdInpEntryZ = 2.2
Turn confirmation: the last close stopped extending the stretchInpRequireTurn = true
Closed-bar ADX at or below the capInpADXMax = 22
ATR between 0.4× and 2.0× its 50-bar averageInpMinATRRatio / InpMaxATRRatio
Spread at or below 50 pointsInpMaxSpreadPts = 50
StdDev at least 3× full round-trip costInpMinSDCostMult = 3
Distance from fill to the mean at least 4× that costInpMinTPCostMult = 4
Optional alignment with the closed H1 SMAperiod 50; set InpFilterPeriodH1 = 0 to disable
Outside the news window, inside the session, and past any loss cooldowncooldown 15 minutes

Round-trip cost is the current spread plus InpExtraCostPts. Set InpExtraCostPts to the broker's round-trip commission converted into gold points. Leave it at 0 when the account is spread-only.

Exit, in order

  1. Server-side limit take-profit at the SMA. A limit fill does not pay the spread on the way out. Each new bar retargets that price to the latest closed-bar SMA, and will not pull it inside a floor that still covers cost.
  2. Closed-bar Z back inside ±0.2 (InpExitZ), if the limit has not filled.
  3. Time exit after 40 bars (InpMaxHoldBars).
  4. Breakeven after 1.0 × ATR of open profit (InpBreakevenATR).
  5. Server-side stop at max(800 points, 2.5 × ATR).

M1 OHLC

Bar-close Z-score mean reversion with the filters that were added while tuning the OHLC model: a 20-tick spread average, an ATR-relative spread cap (12% of M1 ATR), a short price-velocity block, a loss cooldown, ADX, a volatility-adjusted entry Z, an H1 SMA filter, and a CSV trade log.

Default entry Z is 2.0, raised by 0.5 when ATR exceeds 1.5× its 100-bar average. The hard stop is 800 points and the hard take-profit is 1500 points. The working exit is a return of Z to ±0.5, with an ATR trail updated on a new bar. Maximum hold is 30 minutes.

Judge this file on 1 minute OHLC modelling. TickRobust is the file intended for real-tick tests.

M1 Every Tick

The earlier scalper. It evaluates Z from the live bid on every tick, enters beyond ±2.0, and exits on a Z return to ±0.5, an ATR trail, the hard stop (800), or the hard take-profit (1500). It has the session window, spread cap, H1 filter, news filter, and daily loss limit. It does not have the ADX gate, cost gate, turn confirmation, velocity filter, or loss cooldown added in the later files.

Dual strategy

Two strategies on one chart, each with its own magic and position limit.

LegMagicEntryStop / hard target / trail
Mean reversion777333Z beyond ±2.4 while ADX is below 20800 / 1500 / 1.5 × ATR
Trend breakout777444Close beyond a 30-bar Donchian band while ADX is at least 30, EMA 50 agrees, and the DI spread is at least 51000 / 2000 / 2.0 × ATR

The breakout leg enters on a new bar and waits 10 bars after a position closes. Mean reversion can scale out half the position when Z is inside ±0.2, then trail the remainder. Either leg can be switched off with InpUseReversion or InpUseBreakout.

With dynamic risk enabled, the breakout leg uses 30% of the mean-reversion tier. With it disabled, the inputs are InpRiskPct (default 10) and InpTBRiskPct (default 3).

Risk tiers

When InpUseDynamicRisk is true, risk per trade and the daily loss limit follow account equity:

EquityRisk per tradeDaily loss limit
Under $50010%25%
$500 to under $2,0007%20%
$2,000 to under $5,0005%15%
$5,000 to under $20,0003%10%
$20,000 and above1.5%7%

Set InpUseDynamicRisk to false to use the fixed inputs instead. Those defaults are 2% risk and 15% daily loss on TickRobust, and 10% risk and 20% daily loss on the other single-strategy files.

Ten percent of equity per trade can wipe a small account in a short losing sequence. Use a demo account and a risk setting you can afford to lose before attaching any of these files to live capital.

Backtesting

  • Test TickRobust with Every tick based on real ticks. Because entries and discretionary exits are taken from closed bars, OHLC and real-tick results should stay close. A large gap usually means the spread, commission, or symbol specification does not match the inputs.
  • Set InpExtraCostPts before reading a TickRobust report.
  • Expect fewer TickRobust trades than the earlier files. The cost gate drops stretches that do not clear the spread.
  • Test M1 OHLC on 1 minute OHLC. Its tick-path behaviour is not the acceptance test for that file.
  • Model spread explicitly. A zero-spread test will overstate every market-order variant in this repository.

Disclaimer

These Expert Advisors are published for education and research. Leveraged gold trading can lose the entire deposit. Nothing in this repository is a promise of profit, and historical tests do not predict live results. You are responsible for the symbol settings, the risk inputs, and the decision to run a strategy on a live account.

License

Released under the MIT License.

Author

Neo Malesa — n30dyn4m1c

Contact

Telegram: t.me/teraus111

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryPython
MT5-Automation-Labs/mt5-xauusd-bot

Python multi-strategy XAUUSD trading bot for MetaTrader 5: reads terminal data, runs technical strategies such as an HFT EMA scalper, and routes orders through a shared risk layer. Windows live trading, simulated macOS mode.

141
Oct 15, 2026
RepositoryHTML
Dream-XR/MT5-Post-Trade-Insight-Reporter

AutoTrade Forex Signals: Telegram to MT5 EA 2026 Strategy

121
Nov 27, 2026
RepositoryMQL5
francomascareloai/EA_SCALPER_XAUUSD

WIP — XAUUSD (Gold) automated-trading research, in the open. MQL5 (public) + Python/NautilusTrader (private). Studied thousands of bots first. No signals, no profit claims — just the engineering.

316
Nov 19, 2026
RepositoryMQL5
EarnForex/Account-Protector

Automate emergency position closing and autotrading termination using a multi-setting expert advisor.

126
Feb 19, 2026
RepositoryMQL5
xxvw/ICT_Library_MQ5

ICT Concept OSS Library for MQ5/MT5

111
Oct 13, 2026
RepositoryMQL5
6alaile/MetaTrader5-to-Telegram

An expert advisor to help traders connect their MT5 account, via the terminal with a Telegram Bot to broadcast messages to a user, group or channel.

110
Sep 29, 2021
RepositoryMQL5
9nix6/Median-and-Turbo-Renko-indicator-bundle

Open-source MetaTrader 5 SDK for Expert Advisors and indicators that run directly on Median & Turbo Renko charts. Works with both the MQL5 Market edition and Ultimate Renko from az-invest.eu — client library, 64 ported indicators, six working EAs.

102
Nov 23, 2026
RepositoryMQL5
codedpro/mt5-trade-split-manager

🤖 AI-Agent Friendly MT5 Expert Advisor with intelligent order splitting, automatic trailing stops, and REST API. Perfect for Gold/Silver trading with Claude AI integration. Split orders 60/10/10/10/10 for maximum profit optimization.

93
Jul 6, 2026
RepositoryMQL5
yanstd888/institutional-smc-scalper-mt5

Institutional-grade Smart Money Concepts (SMC) & ICT Gold (XAUUSD) Scalping Expert Advisor for MetaTrader 5 (MT5). Non-martingale, verified 6.5-year backtest.

92
Oct 25, 2026