MT5 Expert Advisor · XAUUSD · M5 · v5.0

SCALP GOLD SNIPER EA

Evidence-Based Gold Scalping  ·  LWMA + Stochastic + BB + RSI
ATR-Adaptive Exits  ·  Built on Peer-Reviewed Research

M5 Timeframe
XAUUSD Instrument
0.75% Risk/Trade
1:1.67 Risk/Reward
3% Daily DD Limit
$49 Intro Price
01 / LIVE SIGNAL CHART
LWMA (20)
Bollinger Bands
▲ Buy Signal
▼ Sell Signal
Trailing Stop
XAUUSD 5 082.45 +0.24%
02 / SIGNAL GENERATION PIPELINE
01
📡
LAYER 1 — TREND
M15 FILTER
LWMA(20) slope on M15 confirms the macro direction. Counter-trend signals are blocked entirely before reaching Layer 2.
M5 Close > LWMA · M15 slope rising
02
LAYER 2 — TRIGGER
STOCHASTIC
%K crosses above %D from below 30 (buy) or crosses below %D from above 70 (sell). Mid-range crossovers are discarded.
Stoch(14,3,3) · Extreme zones only
03
🎯
LAYER 3 — CONFIRM ★
BB + RSI
Price at Bollinger Band edge AND RSI in extreme zone. When both fire, signal upgrades to HIGH CONFIDENCE with +25% lot.
BB(20,2) band touch · RSI < 35 or > 65
04
EXECUTE
ORDER SENT
Margin verified. Spread checked (<35pts). Session confirmed (08–17 GMT). ATR-based SL/TP calculated. Position opened.
ATR SL=1.5× · TP=2.5× · Risk 0.75%
03 / UNDER THE HOOD
ScalpGold_EA.mq5 MQL5 · v5.0
Signal Layer 1
TREND GATE
LWMA(20) on M5 and M15. Both must agree with the intended trade direction before the signal pipeline continues.
if(close > iMA(_Symbol,PERIOD_M5,20,0,MODE_LWMA,PRICE_CLOSE,1)
  && m15slope() == TREND_UP) {
Signal Layer 2
STOCHASTIC TRIGGER
%K crosses above %D only from below 30. Mid-range crossovers are rejected entirely — this is the key insight from the academic literature.
bool crossUp = K_prev < D_prev
  && K_cur >= D_cur && K_cur < 30;
Signal Layer 3
BB + RSI UPGRADE
When price touches the lower Bollinger Band AND RSI is below 35, signal strength upgrades. Position size increases by 25%.
if(close <= bbLower * 1.002
  && iRSI(...) < 35) strength = 3;
Risk Engine
ATR-ADAPTIVE SIZING
Stop loss and take profit dynamically computed from ATR(14). No fixed pip distances — every trade adapts to gold's current volatility regime.
sl = atr * 1.5;  tp = atr * 2.5;
lot = (equity * 0.0075) / (sl / tickSize * tickVal);
Protection
DAILY DD HALT
If daily drawdown breaches 3%, the EA stops opening new positions until the next trading session begins. Non-negotiable.
if((g_dayStartEq - AccountEquity()) / g_dayStartEq
  > MaxDailyDD / 100.0) return;
04 / INDICATOR STACK
LWMA
Period 20 · M5 + M15
TREND
Linear-weighted MA. Heavier weight on recent price. Dual-TF trend confirmation. Core of the strategy.
STOCHASTIC
14 · 3 · 3 · STO_LOWHIGH
TRIGGER
Primary entry trigger. Crossover from extreme zone only. Eliminates mid-range noise entirely.
BOLL. BANDS
Period 20 · Deviation 2.0
CONFIRM
Volatility envelope. Edge touch = high-confidence entry. Midline = partial exit trigger.
RSI
Period 14 · Levels 35 / 65
CONFIRM
Secondary confirmation paired with BB. Both extremes must fire to qualify strength-3 signal.
ATR
Period 14 · All exits
EXITS
Volatility-adaptive exits. SL=1.5×ATR, TP=2.5×ATR. Trail at 1.0×ATR. No fixed pip values.
SPREAD GATE
Max 35 points · Hard gate
FILTER
Blocks trading during news spikes, liquidity gaps. ECN/STP accounts recommended.
05 / EXIT SYSTEM
1.5× ATR · Stop Loss Adapts to gold's volatility — no fixed pips
2.5× ATR · Take Profit 1:1.67 R/R · Breakeven at 37.5% win rate
50% Partial at BB Mid Early capture on mean reversion
4H Max Hold Time Force-close if TP/SL not triggered
06 / RISK MANAGEMENT
PROTECTION PARAMETERS
All parameters configurable · Defaults represent conservative live deployment
0.75% Risk / Trade Equity-based sizing
3.0% Daily DD Halt Stops entries until next day
2 Max Positions Simultaneous open cap
5 Loss Streak Halt Manual review required
5 bars Cooldown Min bars between trades
≤35 Max Spread (pts) Hard gate — no exceptions
TRADING SESSION
CLOSED
ACTIVE ★
CLOSED
00040812162024
08:00 GMT London Open
13:00 GMT NY Overlap begins
17:00 GMT Session closes
ACCOUNT TYPES
ECN/STP Hedging
Raw spread accounts
~ Standard accounts (wider spreads)
Netting accounts (partial exit off)
Fixed spread demo only
07 / ACADEMIC FOUNDATION
Zarith Sofia et al. · 2024
LWMA + Stochastic on XAU/USD M5
GA-optimized parameters. 5-year backtest 2019–2023. Only peer-reviewed study with direct XAUUSD M5 evidence. Foundation of core entry logic.
+232% Annual return · 5-year backtest
Hutabarat et al. · 2025
Bollinger Bands + RSI on MT5 XAUUSD
Direct MT5 gold study. BB + RSI confirmation architecture. Basis for the high-confidence signal upgrade layer in ScalpGold.
PF 3.92 Profit Factor · MT5 XAUUSD
Zhang & Khushi · 2020
Genetic Algorithm + Sharpe-Sterling Ratio
Custom SSR fitness function for GA optimization. Basis for the OnTester() criterion: penalizes drawdown, rewards consistency.
+320% AUD/USD · Custom SSR optimization