P
PipsGrowth
ScalpingOpen Source – Free

Pipsgrowth EX10014 Momentum-Scalper

MT5 Expert Advisor (Open Source) · XAUUSD · M5

Pipsgrowth.com EX10014 MomEMA XAUUSD 5M — Momentum + EMA scalper with pyramiding, full 12-layer stack.

Overview

Pipsgrowth EX10014 is a momentum-breakout scalper built around a simple but demanding entry condition: a fresh 100-line cross on the fast Momentum indicator, backed by 10 consecutive bars of slow-Momentum-above-100 and fast-EMA-above-slow-EMA agreement. The idea is to buy a thrust, not a reversion — a momentum line crossing back above 100 means the latest rate of change is positive, and the lookback window forces the EA to wait until trend structure has been confirmed for at least 10 bars before it will engage.

The signal stack is built from four indicators. The fast Momentum (period 10) and slow Momentum (period 34) both default to PRICE_CLOSE. Two EMAs (period 10 and period 34, MODE_EMA) provide the trend backbone. The buy condition requires three things simultaneously: bar-1 fast Momentum above 100 with bar-2 fast Momentum at or below 100 (a fresh up-cross of the 100 midline), AND every one of the last 10 bars showing slow Momentum above 100, AND every one of the last 10 bars showing fast EMA above slow EMA. The sell condition is the mirror: a fresh 100-line down-cross on fast Momentum, with slow Momentum below 100 and fast EMA below slow EMA on each of the 10 lookback bars. CheckSignal() runs on the close of every new M5 bar, gated by a static lastBar check so it cannot fire more than once per bar.

Position sizing flows through CalculateLotSize(). If InpRiskPercent is positive, the EA computes riskMoney = balance * InpRiskPercent/100 and divides by the per-lot risk implied by the 400-point stop. The result is floored to the symbol's lot step, clamped to the broker's min and max lot, and capped at InpMaxLot (default 5.0). If InpRiskPercent is set to 0, the EA falls back to a flat InpFixedLot (0.01). On entry, OpenBuy and OpenSell attempt the order up to 3 times — each retry widens trade deviation by 5 points and sleeps 500 ms — and only fires the order after OrderCalcMargin confirms free margin covers the request.

The stop-and-target placement is fixed in points. The default stop is 400 points and the default take-profit is 1200 points, giving an asymmetric 1:3 reward-to-risk profile that depends on price moving three times the stop distance in the favourable direction before the trailing logic interferes. Both OpenBuy and OpenSell compute sl and tp directly from the live ask/bid and the symbol point, so the actual pip values shift with broker digit count.

Trailing is handled by ManageProfitLock(). When InpEnableTrail is true (default), once a long position is in profit by more than InpTrailStart points (300), the EA ratchets the stop to bid − InpTrailDistance (150 points behind the bid), but only if that new stop is above the current stop. Sells mirror: ask − entry has to exceed 300 points before a stop is set to ask + 150. The trail only ever moves in the favourable direction; it never loosens. TryModify_EX10014 handles the order modification with up to 3 retries on REQUOTE or TIMEOUT, sleeping 100 ms between attempts.

Pyramiding is allowed up to InpMaxPositions (3) entries per direction, but only after the existing position is in profit by InpMinProfitPoints (300 points). IsGridSafe() walks all open positions on the symbol with this magic and returns false if any same-direction position is below that profit threshold. The pyramid adds on the same signal — a fresh momentum cross on a new bar — not on a separate scaling rule. Every pyramid entry carries the same fixed 400/1200 stop/target and the same lot as a fresh signal.

Risk management is wrapped around the entry path in IsSafeToTrade_EX10014(). The gate runs nine checks: a capital cap that disables new entries once equity reaches InpCapAmount (0 = disabled); a capital floor that blocks entries below InpCapFloor ($50 default); an equity drawdown circuit breaker at 95% of g_initialBalance; a daily loss limit at 3% of effective capital; a weekly loss limit at 6% (2x daily); a 30-minute cooldown after 3 consecutive losses; a hard 50-trade-per-day ceiling; a market-hours check that closes the EA around Friday 21:00 GMT and all of Saturday; and a session filter that requires the current GMT time to overlap with London (7-16) or New York (12-21) unless Asia is allowed. The optional InpNewsFilter adds a 15-minute blackout around the London and New York session opens. Effective capital for the daily/weekly loss tests is min(equity, InpCapAmount) when the cap is enabled, otherwise raw equity.

The realized PnL that feeds the daily counters is pulled from the deal stream, not from on-account tracking. OnTradeTransaction watches for DEAL_TRANSACTION_DEAL_ADD events, filters by magic and DEAL_ENTRY_OUT, and sums DEAL_PROFIT + SWAP + COMMISSION into g_realizedToday, g_realizedWeek, and g_tradesToday. A loss bumps g_consecLosses and sets g_cooldownUntil to now + 30 minutes. UpdateDailyCounters_EX10014() resets those counters at the server-time date rollover.

The OnTester() function returns (net * profitFactor) / (1 + relative_dd_percent) when the backtest has at least 30 trades and a positive profit factor — a custom criterion that rewards both absolute profit and profit-per-unit-of-drawdown. GMT offset is auto-detected by DetectGMTOffset_EX10014() when InpServerGMTOffset is 0, by walking H1 bars for a 3+ hour weekend gap and subtracting 22 hours from the post-gap bar hour. FOK filling is hardcoded via trade.SetTypeFilling(ORDER_FILLING_FOK) in OnInit.

In a backtest, expect a moderate trade count on M5 XAUUSD with relatively few winners (the 1:3 R:R means the EA needs the trend to extend) and clustered losses during the Asian session (which the EA explicitly avoids). The momentum-line-100 entry means the EA is silent during sideways regimes where momentum hovers near 100 — that's a feature, not a bug: the EA is built to trade thrusts, not chop.

Strategy Deep Dive

Each tick, the EA refreshes the symbol, gates the spread against InpMaxSpread (250 points), runs ManageProfitLock() on every open position, and then bails out unless IsSafeToTrade_EX10014() returns true. Once a new M5 bar opens, CheckSignal() pulls the fast Momentum, slow Momentum, fast EMA, and slow EMA buffers for the last 10+ bars, computes a fresh 100-line cross on the fast Momentum, and walks the lookback window to confirm the slow Momentum and EMA stack have agreed for the full InpTrendLookback bars. If both gates pass, OpenBuy/OpenSell run a 3-attempt retry loop with widening slippage, only firing after OrderCalcMargin confirms free margin. OnTradeTransaction watches the deal stream and increments g_realizedToday/g_consecLosses/g_tradesToday for every closed deal with the EA's magic, which feeds back into the daily loss, weekly loss, and 3-consec-losses cooldown gates. Effective capital for the daily/weekly loss tests is capped at InpCapAmount when enabled, and the session filter uses an auto-detected or manually-set GMT offset so London (7-16) and New York (12-21) line up regardless of broker server timezone.

Entry Signal

Long entries fire on the close of an M5 bar when the bar-1 fast Momentum(10) crosses above 100 with bar-2 at or below 100, AND every one of the last 10 bars (the InpTrendLookback window) shows slow Momentum(34) above 100 AND fast EMA(10) above slow EMA(34). Short entries mirror the same conditions with a fast-Momentum 100-line down-cross and 10 bars of slow Momentum below 100 with fast EMA below slow EMA. The first pyramid add is allowed when the existing position is in profit by 300+ points (InpMinProfitPoints), up to 3 positions per direction.

Exit Signal

Exits run on a fixed take-profit of 1200 points (3x the stop) and a 400-point stop-loss, both computed from the entry ask/bid. ManageProfitLock() ratchets the stop forward once profit exceeds 300 points (InpTrailStart) — long stop moves to bid-150, short stop moves to ask+150 — and only ever in the favourable direction. Positions left un-touched by the trail close on either the fixed TP or the fixed SL. There is no time-based exit and no signal-reverse exit; the only exit is the SL/TP and the trailing logic.

Stop Loss

Fixed 400-point stop-loss per trade (InpStopLoss), placed below the entry ask for longs and above the entry bid for shorts. After the trade moves 300+ points in favour, ManageProfitLock() steps the stop to lock 150 points behind price (InpTrailDistance), with each subsequent 100-point move of price advancing the trail by 100 points (InpTrailStep). A daily loss limit at 3% of effective capital and a weekly loss limit at 6% will block new entries once breached.

Take Profit

Fixed 1200-point take-profit (InpTakeProfit) per trade — 3x the stop distance — placed above the entry ask for longs and below the entry bid for shorts. No partial close is implemented. Pyramid adds carry the same 1200-point TP target as the initial entry.

Best For

Minimum recommended balance is $100 with InpRiskPercent defaulting to 1.0%, but the 400-point fixed stop on M5 XAUUSD makes the 1% risk model meaningful only on accounts of $300+ — smaller accounts will repeatedly hit the InpFixedLot=0.01 floor. Run this on an ECN or RAW-spread broker: the 250-point spread cap is generous but a 50-100 point average spread leaves more usable headroom for the trailing logic. Best deployed in the London session (7-16 GMT) and the London-New York overlap (12-16 GMT) when XAUUSD is most reactive to macro flows; the EA explicitly blocks Asia, Friday 21:00 GMT close, and the full Saturday session. The pyramid adds 1-3 entries in the same direction, so account sizing should assume 3x the per-trade risk during sustained trends.

Strategy Logic

Pipsgrowth EX10014 Momentum-Scalper — Strategy Logic Analysis (from .mq5 source)

Family: Momentum-Scalper Magic: 22210014 Version: 2.00

BRIEF: Momentum + EMA scalping EA for XAUUSD M5 that enters on momentum crossover confirmed by EMA alignment and sustained trend lookback. Includes risk-based lot sizing, spread filter, trailing stop with profit lock, and pyramiding with profit gating. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • OnTradeTransaction()
  • CheckSignal()
  • OpenBuy()
  • OpenSell()
  • ManageProfitLock()
  • IsGridSafe()
  • CalculateLotSize()
  • CountPositions()
  • EffectiveCapital_EX10014()
  • DetectGMTOffset_EX10014()
  • ServerToGMT_EX10014()
  • IsMarketOpen_EX10014()
  • ...and 5 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (36 total across 7 groups):

  • [=== Indicator Settings ===] InpFastMom = 10 // Fast Momentum Period
  • [=== Indicator Settings ===] InpSlowMom = 34 // Slow Momentum Period
  • [=== Indicator Settings ===] InpFastMA = 10 // Fast EMA Period
  • [=== Indicator Settings ===] InpSlowMA = 34 // Slow EMA Period
  • [=== Indicator Settings ===] InpTrendLookback = 10 // Trend Lookback Bars (Check for sustained trend)
  • [=== Money Management ===] InpRiskPercent = 1.0 // Risk Percent per Trade
  • [=== Money Management ===] InpFixedLot = 0.01 // Fixed Lot (if Risk=0)
  • [=== Money Management ===] InpStopLoss = 400 // Stop Loss (points)
  • [=== Money Management ===] InpTakeProfit = 1200 // Take Profit (points)
  • [=== Trade Management ===] InpMagicNumber = 22210014 // Magic Number
  • [=== Trade Management ===] InpTradeComment = "Psgrowth.com Expert_10014" // Trade Comment
  • [=== Trade Management ===] InpMaxSpread = 250 // Max Spread (points)
  • [=== Trade Management ===] InpSlippage = 3 // Slippage
  • [=== Profit Lock / Trailing ===] InpEnableTrail = true // Enable Trailing Stop
  • [=== Profit Lock / Trailing ===] InpTrailStart = 300 // Trail Start Distance (points)
  • [=== Profit Lock / Trailing ===] InpTrailStep = 100 // Trail Step (points)
  • [=== Profit Lock / Trailing ===] InpTrailDistance = 150 // Distance behind price (points)
  • [=== Pyramiding / Scaling ===] InpEnablePyramid = true // Enable Pyramiding
  • [=== Pyramiding / Scaling ===] InpMaxPositions = 3 // Max Open Positions
  • [=== Pyramiding / Scaling ===] InpMinProfitPoints = 300 // Min Profit (points) to Add Next
  • [=== Hardening: Risk Management ===] InpDailyLossLimitPct = 3.0 // Daily loss limit (% of effective capital)
  • [=== Hardening: Risk Management ===] InpMaxLot = 5.0 // Hard lot cap per trade
  • [=== Hardening: GMT Sessions ===] InpServerGMTOffset = 0 // Server GMT offset hours (0=auto-detect)
  • [=== Hardening: GMT Sessions ===] InpLondonStartHour = 7 // London session start (GMT)
  • [=== Hardening: GMT Sessions ===] InpLondonEndHour = 16 // London session end (GMT)
  • [=== Hardening: GMT Sessions ===] InpNYStartHour = 12 // New York session start (GMT)
  • [=== Hardening: GMT Sessions ===] InpNYEndHour = 21 // New York session end (GMT)
  • [=== Hardening: GMT Sessions ===] InpAvoidAsia = true // Avoid Asian session
  • [=== Hardening: GMT Sessions ===] InpAsiaStartHour = 0 // Asian session start (GMT)
  • [=== Hardening: GMT Sessions ===] InpAsiaEndHour = 7 // Asian session end (GMT)
  • [=== Hardening: GMT Sessions ===] InpNewsFilter = false // Avoid trading near news session opens
  • [=== Hardening: GMT Sessions ===] InpNewsFilterMinutes = 15 // Minutes to avoid around news
  • [=== Hardening: GMT Sessions ===] InpMaxTradesPerDay = 50 // Maximum trades per day
  • [=== Hardening: GMT Sessions ===] InpMinEquityPercent = 95.0 // Stop trading if equity < this % of initial balance
  • [=== Hardening: GMT Sessions ===] InpCooldownMinutes = 30 // Cooldown minutes after consec losses
  • [=== Hardening: GMT Sessions ===] InpMaxConsecLosses = 3 // Max consecutive losses before cooldown
Pseudocode
// Pipsgrowth EX10014 Momentum-Scalper — Execution Flow (from source analysis)
// Family: Momentum-Scalper
// Momentum + EMA scalping EA for XAUUSD M5 that enters on momentum crossover confirmed by EMA alignment and sustained trend lookback. Includes risk-based lot sizing, spread filter, trailing stop with profit lock, and pyramiding with profit gating. 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

Optimized Brokers:
ExnessIC Markets
Optimized Symbols:
XAUUSD
Optimized Timeframes:
M5

How to Install This EA on MT5

  1. 1Download the .mq5 file using the button above
  2. 2Open MetaTrader 5 on your computer
  3. 3Click File → Open Data Folder in the top menu
  4. 4Navigate to MQL5 → Experts and paste the .mq5 file there
  5. 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
  6. 6Drag the EA from the Navigator onto any chart (M1 or M5 recommended)
  7. 7In the EA dialog, enable Allow Algo Trading and set your lot size
  8. 8Click OK — the EA will begin trading automatically

EA Parameters

ParameterDefaultDescription
InpFastMom10Fast Momentum Period
InpSlowMom34Slow Momentum Period
InpFastMA10Fast EMA Period
InpSlowMA34Slow EMA Period
InpTrendLookback10Trend Lookback Bars (Check for sustained trend)
InpRiskPercent1.0Risk Percent per Trade
InpFixedLot0.01Fixed Lot (if Risk=0)
InpStopLoss400Stop Loss (points)
InpTakeProfit1200Take Profit (points)
InpMagicNumber22210014Magic Number
InpTradeComment"Psgrowth.com Expert_10014"Trade Comment
InpMaxSpread250Max Spread (points)
InpSlippage3Slippage
InpEnableTrailtrueEnable Trailing Stop
InpTrailStart300Trail Start Distance (points)
InpTrailStep100Trail Step (points)
InpTrailDistance150Distance behind price (points)
InpEnablePyramidtrueEnable Pyramiding
InpMaxPositions3Max Open Positions
InpMinProfitPoints300Min Profit (points) to Add Next
InpDailyLossLimitPct3.0Daily loss limit (% of effective capital)
InpMaxLot5.0Hard lot cap per trade
InpServerGMTOffset0Server GMT offset hours (0=auto-detect)
InpLondonStartHour7London session start (GMT)
InpLondonEndHour16London session end (GMT)
InpNYStartHour12New York session start (GMT)
InpNYEndHour21New York session end (GMT)
InpAvoidAsiatrueAvoid Asian session
InpAsiaStartHour0Asian session start (GMT)
InpAsiaEndHour7Asian session end (GMT)
InpNewsFilterfalseAvoid trading near news session opens
InpNewsFilterMinutes15Minutes to avoid around news
InpMaxTradesPerDay50Maximum trades per day
InpMinEquityPercent95.0Stop trading if equity < this % of initial balance
InpCooldownMinutes30Cooldown minutes after consec losses
InpMaxConsecLosses3Max consecutive losses before cooldown
Source Code (.mq5)Open Source
Pipsgrowth_com_EX10014.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX10014 MomEMA XAUUSD 5M — Momentum + EMA scalper with pyramiding, 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 "=== Indicator Settings ==="
input int      InpFastMom        = 10;       // Fast Momentum Period
input int      InpSlowMom        = 34;       // Slow Momentum Period
input int      InpFastMA         = 10;       // Fast EMA Period
input int      InpSlowMA         = 34;       // Slow EMA Period
input int      InpTrendLookback  = 10;       // Trend Lookback Bars (Check for sustained trend)

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       = 400;      // Stop Loss (points)
input int      InpTakeProfit     = 1200;     // Take Profit (points)

input group "=== Trade Management ==="
input int      InpMagicNumber    = 22210014;                     // Magic Number
input string   InpTradeComment   = "Psgrowth.com Expert_10014"; // Trade Comment
input int      InpMaxSpread      = 250;      // Max Spread (points)
input int      InpSlippage       = 3;        // Slippage

input group "=== Profit Lock / Trailing ==="
input bool     InpEnableTrail    = true;     // Enable Trailing Stop
input int      InpTrailStart     = 300;      // Trail Start Distance (points)
input int      InpTrailStep      = 100;      // Trail Step (points)
input int      InpTrailDistance  = 150;      // Distance behind price (points)

input group "=== Pyramiding / Scaling ==="
input bool     InpEnablePyramid  = true;     // Enable Pyramiding
input int      InpMaxPositions   = 3;        // Max Open Positions
input int      InpMinProfitPoints= 300;      // Min Profit (points) to Add Next

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)

Full source code available on download

Educational purposes only. Do NOT use with real money. Test on demo accounts only.

Tags:ex10014momentum-scalperpipsgrowthfreemt5xauusd

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

Community

Sign in to contributeSign In

Educational purposes only. Do NOT use with real money. Test on demo accounts only.

File NamePipsgrowth_com_EX10014.mq5
File Size21.7 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyScalping
Risk LevelHigh Risk
Timeframes
M5
Currency Pairs
XAUUSD
Min. Deposit$100