// MQL5 · MetaTrader 5 · XAUUSD M1

GoldBreak EA
& MQL5

Architecture, strategy logic, version governance, and MQL5 patterns behind GoldBreak — running live on XAUUSD. Built with the same rigour as production software.

// 01

Strategy & Performance

GoldBreak is a session-aware Donchian channel breakout Expert Advisor targeting XAUUSD on M1. Entry signals trigger when price breaks the Donchian high or low within defined session windows — session timing is the primary filter, not a secondary one.

On a valid breakout, the EA opens an initial position sized by risk percentage. Subsequent positions scale in at fixed ATR multiples — a pyramid scaling architecture that compounds winning moves while keeping total position risk bounded. Each pyramid level carries an independent take-profit; a shared trailing stop manages the composite position.

Development is strictly version-controlled. Every parameter change requires a full backtest comparison against the benchmark version before deployment. The benchmark — v11.7 — achieved 87% win rate with 7.61% max drawdown across 2022–2025. Version 12.0 regressed severely when three features simultaneously suppressed the pyramid; the lesson is now a governance rule.

GoldBreak v11.7 — Equity Curve
Simulated backtest 2022–2025 · XAUUSD M1 · $169 initial deposit
Equity
Drawdown
Sessions
ILLUSTRATIVE · BASED ON v11.7 BACKTEST PARAMETERS · NOT FINANCIAL ADVICE
GoldBreak v11.7 · Backtest Snapshot
InstrumentXAUUSD · M1
Period2022 – 2025
Initial Deposit$169
Net Profit$1,260,000+
Win Rate87%
Max Drawdown7.61%
StrategyDonchian + Pyramid
SessionsLondon · NY · Asia
BrokerIC Markets SC · Raw
Status
Live
// 02

Session Architecture

Primary
London
03:00 – 12:00 UTC · Peak liquidity
Highest-volume session for XAUUSD. Donchian breakouts carry the most follow-through. The EA fires on the first valid breakout within the window, with hourly re-entry logic on the variant build. Friday expiry cutoff at 12:00.
Secondary
New York
13:00 – 20:00 UTC · Session overlap
Captures the London–NY overlap and afternoon continuation moves. EMA trend gate (NY_TrendEMA=200) filters entries. Self-cancellation bug fixed in v11.8 — g_ordersActive flag now correctly clears on London expiry.
Tertiary
Asia
23:00 – 07:00 UTC · Range-bound
Single-fire entry pattern. Uses a separate AsiaExpiryHour=7 input to prevent the self-cancel bug where ExpiryHour=21 fired at 23:05. Fixed in v11.8.
// 03

Version Governance

VersionNet ProfitWin RateMax DDKey ChangeStatus
v11.7$1,260,000+87%7.61%Benchmark — strongest live performerLive
v11.85 bug fixes: Asia expiry, NY cancel, Friday cutoff, VPS migrationIn Dev
v12.0RegressedH4 EMA gate + Adaptive ADT + VAS floored — all three suppressed pyramidReverted
v13 (best)$2,016,226BATRP=8, Risk=25, MaxLot=150 · AccelLo/Hi hardcoded constantsResearch
Governance rule: every parameter change requires full backtest vs v11.7 before deployment. No exceptions.
// 04

MQL5 Patterns

001
Session-Gated Donchian Breakout
Entry fires only within the configured session window. Donchian high/low calculated over the lookback period on M1 close.
// Donchian breakout entry check
double hi = iHigh(Symbol(), PERIOD_M1,
  iHighest(Symbol(), PERIOD_M1,
    MODE_HIGH, DonchianPeriod, 1));
double lo = iLow(Symbol(), PERIOD_M1,
  iLowest(Symbol(), PERIOD_M1,
    MODE_LOW, DonchianPeriod, 1));

if (InSession(LONDON) && !g_londonFired) {
  if (Ask > hi) {
    OpenBuy(LotSize);
    g_londonFired = true;
  } else if (Bid < lo) {
    OpenSell(LotSize);
    g_londonFired = true;
  }
}
002
ATR-Based Pyramid Scaling
Each pyramid level opens at a fixed ATR offset. Independent TP per level, shared trailing stop.
// Pyramid entry at ATR multiples
double atr = GetATR(ATRPeriod);
for (int i=1; i<=MaxPyramidLevels; i++) {
  double target =
    g_initialEntry + (i * atr * PyramidStep);
  if (Ask >= target && !g_levelOpen[i]) {
    double lot = PyramidLot(i, LotSize);
    OpenBuy(lot);
    SetTP(target + atr * TPMultiplier);
    g_levelOpen[i] = true;
  }
}
003
Self-Cancel Fix (v11.8)
The g_ordersActive flag resets on London expiry so NY can place fresh orders without immediately cancelling.
// OnTimer — session expiry handler
void OnTimer() {
  if (IsLondonExpiry()) {
    CancelPendingOrders(LONDON);
    // v11.8 fix: reset flag so NY fires
    g_ordersActive = false;
    g_londonFired  = false;
  }
  if (InSession(NEW_YORK) &&
      !g_ordersActive &&
      !g_nyFired) {
    PlaceBreakoutOrders(NEW_YORK);
    g_ordersActive = true;
    g_nyFired = true;
  }
}
004
Friday Early Expiry Fix
London orders were expiring 9 hours early on Fridays. Fixed by checking DayOfWeek and applying a separate Friday cutoff.
// Friday-aware expiry calculation
datetime GetExpiryTime() {
  MqlDateTime dt;
  TimeToStruct(TimeCurrent(), dt);

  // Friday = day_of_week 5
  if (dt.day_of_week == 5) {
    // Use early close to avoid weekend gap
    return BuildTime(dt,
      FridayExpiryHour, 0);
  }

  // Standard expiry for other days
  return BuildTime(dt, ExpiryHour, 0);
}
// 05

Articles

MQL5 / EA Design
Building GoldBreak: Architecture of a Session-Aware Donchian Breakout EA
From concept to live trading — full architecture, session window design, pyramid scaling, and what a real 3-year backtest looks like when you stop fooling yourself.
~20 min
COMING SOON
Backtesting
Why v12.0 Regressed: Three Features That Killed the Pyramid
A post-mortem on v12.0 — H4 EMA gating blocked sells in a persistent uptrend, adaptive ADT set its threshold too high, VAS permanently floor-clamped sizing. All three at once.
~14 min
COMING SOON
MQL5 Development
Version Governance for Expert Advisors
Treating EA development like production software: version registry, parameter change governance rules, mandatory backtest regression, and why "it felt right" is never a valid justification.
~12 min
COMING SOON