Pipsgrowth EX10016 Momentum-Scalper
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX10016 MomentumScalp_XAUUSD_5M — momentum oscillator + EMA trend filter scalper, full 12-layer stack.
Overview
Pipsgrowth EX10016 Momentum-Scalper is the most pared-down variant in the EX10 family: a single Momentum oscillator crossing a fixed level, gated by a single trend filter, with no management layer in flight. The EA watches the 14-period Momentum(close) on the same M5 chart it trades. On every new bar, it copies the last two completed-bar values of the Momentum buffer and the last value of a 200-period EMA, then asks one question: did the oscillator cross 100 on the just-closed bar, and is price on the right side of the 200 EMA?
A buy fires when Momentum was at or below 100 on the prior bar and closed above 100 on the bar just finished, provided the M5 close is also above the 200 EMA. A sell is the exact mirror: a downward cross of 100 combined with a close below the 200 EMA. Both signals use bar 1 (the most recent completed bar) as the trigger, so the EA never enters mid-bar on noise. The bar gate is enforced by caching iTime(_Symbol, _Period, 0) — only when the value changes does CheckSignal() even run, which keeps the indicator handles idle most of the time.
There is no entry filter beyond spread and the safety stack, and no other oscillator, no ATR floor, no regime classifier, no higher-timeframe confirmation. The architecture is intentionally narrow: one oscillator cross plus one trend line equals the entire signal. The trade-off is that the EA relies on the safety layer — not the signal layer — to keep drawdown under control. That safety layer is the part of the code that has real weight.
Position management is the opposite of the EX10 family's busier variants. There is no trailing stop, no break-even, no partial close, no time-stop, no regime-change exit. The trade either hits the 300-point stop, the 500-point target, or stays open until the session ends. The trade.SetExpertMagicNumber call writes 22210016 to every order, and PositionsTotal() > 0 short-circuits CheckSignal() before any signal logic runs, so the EA only ever holds a single position on the symbol at a time. Re-entries have to wait for the existing position to close first.
Lot sizing is risk-based with a fixed-lot fallback. CalculateLotSize() takes the InpStopLoss of 300 points, multiplies the account balance by InpRiskPercent (default 1.0%), divides by the per-lot loss for that stop distance in tick terms, and floors the result to the symbol's LotStep. The result is then clamped to the broker's min/max and to InpMaxLot (default 5.0). If InpRiskPercent is set to 0, the EA falls back to InpFixedLot = 0.01, which is the safe default for a small account or for users who want to test the signal without scaling risk.
The retry wrapper around each entry is the most consequential piece of plumbing. OpenBuy() and OpenSell() each loop three times. On each attempt, OrderCalcMargin is checked first — if the lot does not clear the free-margin test, the attempt is skipped. Otherwise TryBuy_EX10016 / TrySell_EX10016 is called, which sets the price to the live Ask/Bid inside the loop, sends the order, and only treats TRADE_RETCODE_DONE or TRADE_RETCODE_DONE_PARTIAL as success. On REQUOTE, TIMEOUT, PRICE_OFF, or PRICE_CHANGED the loop sleeps 200ms and tries again with a +5 point slippage ramp; any other return code breaks out of the loop. The whole entry attempt is also wrapped in a hard 3-attempt outer loop, so the EA can survive a brief liquidity glitch but will not spam the trade server if something structural is wrong.
The safety stack — the IsSafeToTrade_EX10016() function and the OnTradeTransaction handler that feeds it — is the architecture's real depth. OnTradeTransaction listens for TRADE_TRANSACTION_DEAL_ADD, runs HistorySelect over the past 90 days, picks out DEAL_ENTRY_OUT rows whose DEAL_MAGIC matches 22210016, and accumulates realized PnL (profit + swap + commission) into g_realizedToday, g_realizedWeek, and g_tradesToday. A losing deal increments g_consecLosses and pushes g_cooldownUntil out by InpCooldownMinutes (default 30 minutes); a winning deal resets the counter. UpdateDailyCounters_EX10016() resets all three counters at the start of a new server day.
IsSafeToTrade_EX10016() then composes nine gates from the data OnTradeTransaction collected. They fire in this order: capital cap ceiling (if InpCapAmount > 0, refuse new entries once equity reaches that amount), capital floor (refuse entries below InpCapFloor = 50), minimum equity (refuse entries if equity has fallen below 95% of the initial balance, the persistent-drawdown cut-off), daily loss cap (3% of effective capital), weekly loss cap (twice the daily cap, i.e. 6%), consecutive-loss cooldown (3 losses within the cooldown window disables the EA), daily trade cap (50), market open, and active session. Only when all nine return true does the signal logic get to run.
The session gate deserves its own paragraph. The EA refuses to fire during the Asia session by default: InpAvoidAsia is true, the Asia window is 0-7 GMT, and the gate returns false during those hours unless the current time also falls inside the London (7-16 GMT) or New York (12-21 GMT) windows. This overlaps London and New York from 12:00-16:00 GMT, which is also the period when XAUUSD has historically shown its tightest spreads and most reactive order flow. The news filter (InpNewsFilter, default off) blocks the 15 minutes around the London open (07:00 GMT) and New York open (12:30 GMT) when toggled on — this is an opt-in because the indicator cross logic is already slow enough to be partially immune to first-minute spike noise.
The DetectGMTOffset_EX10016() helper auto-detects the server-to-GMT offset on init by walking H1 bars and looking for the weekend gap. If the user knows the offset, InpServerGMTOffset overrides auto-detect. The function exists because the session gates all run in GMT, and an MT5 broker with server time set to GMT+2 or GMT+3 would otherwise put the Asia blackout in the middle of the London session. The first init log line is EX10016 init OK magic=22210016 GMT=<offset> — this is the value to verify in the Experts tab before going live.
Filling is hard-coded to ORDER_FILLING_FOK in OnInit, which matches the dominant execution model for XAUUSD on the brokers the EA is paired with. Slippage is set to InpSlippage = 3, and the spread ceiling is InpMaxSpread = 250 points. The 250-point cap is loose by scalping standards — it accepts entries during the volatile minutes around 12:30 GMT and 14:30 GMT, when XAUUSD spreads can briefly double — and the trade-off is that the EA will take signals the tighter-paired EAs in the family reject. If your broker widens the spread above 250 points for more than a few seconds, the entry is paused until the spread normalises.
OnTester returns (net × profit factor) / (1 + drawdown percent) when the backtest has at least 30 trades and a positive profit factor and drawdown. This favours EAs that combine profitability with smoothness — a 50% return with a 60% drawdown will score worse than a 25% return with a 10% drawdown. The 30-trade minimum is meaningful: it filters out one-shot backtests where the optimizer lands on a freak configuration. In practice, the EX10 family EAs with management layers typically outscore this one on the criterion, because the static SL/TP cannot extract profit from post-target continuation — but the simpler signal also survives regimes that confuse the busier variants.
The honest expectation for a backtest on XAUUSD M5 is a sawtooth equity curve, because each trade is a fixed 500-point target against a fixed 300-point stop. The strategy's edge depends on the asymmetry holding in the chosen sample — a 1.67:1 reward-to-risk that wins more than 38% of the time clears the 100-pip/cycle breakeven after spread. Expect clusters of consecutive losses during trendless sessions; the 3-loss/30-min cooldown is the only built-in mitigation, and it is short by design. Users who want a smoother experience should test the 1-hour or 15-minute timeframes, where the same signal fires less often but with a higher per-trade quality; the EA's input pin to M5 is the suggested time, not a hard constraint at the code level — only the EA being compiled to a chart period restricts this.
Risk profile is HIGH. The fixed 1% risk per trade is moderate, but XAUUSD moves 200-500 points in a single 5-minute candle on NFP days, and the EA will not pause for news unless InpNewsFilter is manually toggled to true. Pair this with an ECN or low-spread broker, a 100 USD minimum deposit for a single 0.01-lot position, and a realistic expectation of equity drawdowns in the 15-30% range during losing streaks. The EA is not a black box — every input, every gate, every entry condition is visible in the source — and that visibility is the reason it is published without obfuscation.
Strategy Deep Dive
On every tick OnTick() refreshes rates, checks the spread cap (250 points), runs the nine-gate IsSafeToTrade_EX10016() check, and on a fresh bar (iTime cache change) calls CheckSignal(). The signal logic copies two completed bars of Momentum(14) and the latest EMA(200), then tests the cross-100-and-trend-aligned condition — a single threshold plus a single filter. CalculateLotSize() converts the 1% risk and the 300-point stop into a lot size floored to LotStep. The order is wrapped in a 3-attempt loop with a 200ms sleep, slippage ramp of +5, and only TRADE_RETCODE_DONE/PARTIAL are accepted. OnTradeTransaction listens for DEAL_ADD events with magic 22210016, reads 90 days of deal history, and accumulates realized PnL, daily/weekly loss, and consecutive-loss counts that the safety gates consume. There is no in-trade management — the open position is the broker's problem until SL, TP, or the session end.
Buys fire when the 14-period Momentum closes the bar above 100 while the prior bar was at or below 100, and the M5 close sits above the 200 EMA. Sells are the mirror: Momentum crosses below 100 with a close under the 200 EMA. CheckSignal() runs only on a fresh bar (lastBar gate) and only when PositionsTotal() == 0, so the EA holds a single position at a time and never enters mid-bar.
Exits are mechanical: the 300-point stop, the 500-point target, or the broker closing the position. There is no trailing stop, no break-even shift, no partial close, and no time-based exit. Once a position is open, the EA does not touch it — it waits for the next CheckSignal() cycle, which is itself blocked by the PositionsTotal() > 0 gate until the trade resolves.
Stop loss is InpStopLoss = 300 points below entry for buys and above entry for sells, calculated as mysymbol.Ask() - 300*Point() in OpenBuy() and mirrored with Bid() + 300*Point() in OpenSell(). The SL is set as part of the order request and never modified after the trade is open.
Take profit is InpTakeProfit = 500 points, giving a fixed 1.67:1 reward-to-risk against the 300-point stop. TP is set on the order request at entry and held unchanged for the life of the position.
Best suited for traders running XAUUSD M5 with a $100 minimum balance who want the simplest possible signal: a single Momentum cross filtered by a single 200 EMA trend line. Run on an ECN or low-spread broker where the 250-point spread cap is rarely binding and where slippage stays inside the +5 ramp on most entries. Recommended session is London (7-16 GMT) plus the London-New York overlap (12-16 GMT); the Asia window is blocked by default. Toggle InpNewsFilter on if you want the EA to skip the 15 minutes around the London and New York opens. Pair with a $1,000+ balance for realistic position sizing at the default 1% risk, and accept that the EA carries HIGH risk during NFP weeks when XAUUSD M5 candles can move the full 300-point stop in a single bar.
Strategy Logic
Pipsgrowth EX10016 Momentum-Scalper — Strategy Logic Analysis (from .mq5 source)
Family: Momentum-Scalper
Magic: 22210016
Version: 2.00
BRIEF:
Momentum scalper using the Momentum oscillator crossing the 100 level combined with a 200 EMA trend filter to generate buy/sell signals on each new bar. Risk-based lot sizing with fixed-lot fallback, SL/TP in points, spread filter. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
OnTradeTransaction()CheckSignal()OpenBuy()OpenSell()CalculateLotSize()EffectiveCapital_EX10016()DetectGMTOffset_EX10016()ServerToGMT_EX10016()IsMarketOpen_EX10016()InActiveSession_EX10016()IsNewsTime_EX10016()IsSafeToTrade_EX10016()- ...and 3 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (26 total across 5 groups):
- [=== Strategy Parameters ===]
InpMomPeriod= 14 // Momentum Period - [=== Strategy Parameters ===]
InpTrendEMA= 200 // Trend FilterEMA - [=== Money Management ===]
InpRiskPercent=1.0// Risk Percent per Trade - [=== Money Management ===]
InpFixedLot=0.01// FixedLot(if Risk=0) - [=== Money Management ===]
InpStopLoss= 300 // StopLoss(points) - [=== Money Management ===]
InpTakeProfit= 500 // TakeProfit(points) - [=== Trade Management ===]
InpMagicNumber=22210016// Magic Number - [=== Trade Management ===]
InpTradeComment= "Psgrowth.com Expert_10016" // TradeComment - [=== Trade Management ===]
InpMaxSpread= 250 // MaxSpread(points) - [=== Trade Management ===]
InpSlippage= 3 // Slippage - [=== Hardening: Risk Management ===]
InpDailyLossLimitPct=3.0// Daily loss limit (% of effective capital) - [=== Hardening: Risk Management ===]
InpMaxLot=5.0// Hard lot cap per trade - [=== Hardening:
GMTSessions ===]InpServerGMTOffset= 0 // ServerGMToffset hours (0=auto-detect) - [=== Hardening:
GMTSessions ===]InpLondonStartHour= 7 // London session start (GMT) - [=== Hardening:
GMTSessions ===]InpLondonEndHour= 16 // London session end (GMT) - [=== Hardening:
GMTSessions ===]InpNYStartHour= 12 // New York session start (GMT) - [=== Hardening:
GMTSessions ===]InpNYEndHour= 21 // New York session end (GMT) - [=== Hardening:
GMTSessions ===]InpAvoidAsia=true// Avoid Asian session - [=== Hardening:
GMTSessions ===]InpAsiaStartHour= 0 // Asian session start (GMT) - [=== Hardening:
GMTSessions ===]InpAsiaEndHour= 7 // Asian session end (GMT) - [=== Hardening:
GMTSessions ===]InpNewsFilter=false// Avoid trading near news session opens - [=== Hardening:
GMTSessions ===]InpNewsFilterMinutes= 15 // Minutes to avoid around news - [=== Hardening:
GMTSessions ===]InpMaxTradesPerDay= 50 // Maximum trades per day - [=== Hardening:
GMTSessions ===]InpMinEquityPercent=95.0// Stop trading if equity < this % of initial balance - [=== Hardening:
GMTSessions ===]InpCooldownMinutes= 30 // Cooldown minutes after consec losses - [=== Hardening:
GMTSessions ===]InpMaxConsecLosses= 3 // Max consecutive losses before cooldown
// Pipsgrowth EX10016 Momentum-Scalper — Execution Flow (from source analysis)
// Family: Momentum-Scalper
// Momentum scalper using the Momentum oscillator crossing the 100 level combined with a 200 EMA trend filter to generate buy/sell signals on each new bar. Risk-based lot sizing with fixed-lot fallback, SL/TP in points, spread filter. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
ON_INIT:
Create indicator handles: standard set
Initialize state variables
Detect broker GMT offset
ON_TICK:
1. Refresh indicator buffers (closed-bar shift=1)
2. Manage existing positions:
- Break-even check
- ATR trailing stop
- Profit lock ratchet
- Time-based exit
- Opposite-signal exit
3. If new bar:
a. ClassifyRegime() — ADX/ATR/BB regime detection
b. NoTradeGate() checks:
- Market open + session filter
- Spread limit
- Cooldown after loss
- Consecutive loss limit
- Kill switch
- Max drawdown
- Max concurrent positions
- Daily/weekly loss limits
c. GenerateSignal() — strategy-specific entry logic
d. CheckConfirm() — HTF alignment + R:R + ADX minimum
e. Calculate position size from risk %
f. Execute with retry logic
g. Mark bar to prevent duplicates
ON_TESTER:
Custom fitness = weighted(RecoveryFactor, ROI, ProfitFactor, TradeCount, Sharpe, Drawdown)Optimization Profile
How to Install This EA on MT5
- 1Download the .mq5 file using the button above
- 2Open MetaTrader 5 on your computer
- 3Click File → Open Data Folder in the top menu
- 4Navigate to MQL5 → Experts and paste the .mq5 file there
- 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
- 6Drag the EA from the Navigator onto any chart (M1 or M5 recommended)
- 7In the EA dialog, enable Allow Algo Trading and set your lot size
- 8Click OK — the EA will begin trading automatically
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| InpMomPeriod | 14 | Momentum Period |
| InpTrendEMA | 200 | Trend Filter EMA |
| InpRiskPercent | 1.0 | Risk Percent per Trade |
| InpFixedLot | 0.01 | Fixed Lot (if Risk=0) |
| InpStopLoss | 300 | Stop Loss (points) |
| InpTakeProfit | 500 | Take Profit (points) |
| InpMagicNumber | 22210016 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_10016" | Trade Comment |
| InpMaxSpread | 250 | Max Spread (points) |
| InpSlippage | 3 | Slippage |
| InpDailyLossLimitPct | 3.0 | Daily loss limit (% of effective capital) |
| InpMaxLot | 5.0 | Hard lot cap per trade |
| InpServerGMTOffset | 0 | Server GMT offset hours (0=auto-detect) |
| InpLondonStartHour | 7 | London session start (GMT) |
| InpLondonEndHour | 16 | London session end (GMT) |
| InpNYStartHour | 12 | New York session start (GMT) |
| InpNYEndHour | 21 | New York session end (GMT) |
| InpAvoidAsia | true | Avoid Asian session |
| InpAsiaStartHour | 0 | Asian session start (GMT) |
| InpAsiaEndHour | 7 | Asian session end (GMT) |
| InpNewsFilter | false | Avoid trading near news session opens |
| InpNewsFilterMinutes | 15 | Minutes to avoid around news |
| InpMaxTradesPerDay | 50 | Maximum trades per day |
| InpMinEquityPercent | 95.0 | Stop trading if equity < this % of initial balance |
| InpCooldownMinutes | 30 | Cooldown minutes after consec losses |
| InpMaxConsecLosses | 3 | Max consecutive losses before cooldown |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX10016 MomentumScalp_XAUUSD_5M — momentum oscillator + EMA trend filter scalper, full 12-layer stack."
#include <Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
CTrade trade;
CPositionInfo position;
CSymbolInfo mysymbol;
CAccountInfo account;
//--- Input Groups
input group "=== Strategy Parameters ==="
input int InpMomPeriod = 14; // Momentum Period
input int InpTrendEMA = 200; // Trend Filter EMA
input group "=== Money Management ==="
input double InpRiskPercent = 1.0; // Risk Percent per Trade
input double InpFixedLot = 0.01; // Fixed Lot (if Risk=0)
input int InpStopLoss = 300; // Stop Loss (points)
input int InpTakeProfit = 500; // Take Profit (points)
input group "=== Trade Management ==="
input int InpMagicNumber = 22210016; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_10016"; // Trade Comment
input int InpMaxSpread = 250; // Max Spread (points)
input int InpSlippage = 3; // Slippage
input group "=== Hardening: Risk Management ==="
input double InpDailyLossLimitPct = 3.0; // Daily loss limit (% of effective capital)
input double InpMaxLot = 5.0; // Hard lot cap per trade
input group "=== Capital Allocation Cap ==="
// InpCapEnabled removed — use InpCapAmount=0 to disable
input double InpCapAmount = 0.0;
input double InpCapFloor = 50.0;
input group "=== Hardening: GMT Sessions ==="
input int InpServerGMTOffset = 0; // Server GMT offset hours (0=auto-detect)
input int InpLondonStartHour = 7; // London session start (GMT)
input int InpLondonEndHour = 16; // London session end (GMT)
input int InpNYStartHour = 12; // New York session start (GMT)
input int InpNYEndHour = 21; // New York session end (GMT)
input bool InpAvoidAsia = true; // Avoid Asian session
input int InpAsiaStartHour = 0; // Asian session start (GMT)
input int InpAsiaEndHour = 7; // Asian session end (GMT)
input bool InpNewsFilter = false; // Avoid trading near news session opens
input int InpNewsFilterMinutes = 15; // Minutes to avoid around news
input int InpMaxTradesPerDay = 50; // Maximum trades per day
input double InpMinEquityPercent = 95.0; // Stop trading if equity < this % of initial balance
input int InpCooldownMinutes = 30; // Cooldown minutes after consec losses
input int InpMaxConsecLosses = 3; // Max consecutive losses before cooldown
//--- Handles
int hMom;
Full source code available on download
Educational purposes only. Do NOT use with real money. Test on demo accounts only.
Clear Warning: Educational Purposes Only
Clear Warning: This Expert Advisor is for educational and testing purposes only. Do NOT use it with real money. Test only on demo accounts. Trading with real money involves substantial risk of capital loss. This does not constitute investment advice.
Recommended Brokers for This EA
These EAs run on MT5 — use a regulated broker with fast execution and tight spreads
Markets.com
Exness
IC Markets
Similar Expert Advisors
View All Expert AdvisorsMore Scalping strategy EAs from our library
Pipsgrowth EX14020 Scalper
Pipsgrowth.com EX14020 AIXAUUSDScalper — AI-assisted XAUUSD scalper, full 12-layer stack.
Pipsgrowth EX10006 Momentum-Scalper
Pipsgrowth.com EX10006 USDJPY Scalper — USDJPY pullback momentum scalper, full 12-layer stack.
Pipsgrowth EX14021 Scalper
Pipsgrowth.com EX14021 EURUSDScalper — BB + MACD divergence scalper, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.