P
PipsGrowth
ScalpingOpen Source – Free

Pipsgrowth EX10009 Momentum-Scalper

MT5 Expert Advisor (Open Source) · XAUUSD · M5, M15

Pipsgrowth.com EX10009 gold_scalping — MACD cross + RSI extreme momentum scalper, full 12-layer stack.

Overview

Pipsgrowth EX10009 Momentum-Scalper sits at the heart of the EX10 momentum family: an XAUUSD M5/M15 scalper that trades MACD-line crossovers gated by an ADX trend-strength filter, an RSI-zone agreement check, and a higher-timeframe EMA50 trend agreement — with a 7-state regime classifier sitting in front of every entry. The strategy's core insight is that a raw MACD cross fires constantly in noise; the value comes from filtering those crosses so that the EA only acts when the move has enough trend strength to follow through. Magic number 22210009, version 2.00, two-decade-old MQL5 with #property strict.

The signal stack is built around four closed-bar conditions. First, the CoreSignal() function (lines 447-482) reads the MACD main line and signal line at shift 1 (the last fully closed bar) and the previous bar at shift 2, and demands a true crossover — bMACDm[1] > bMACDs[1] && bMACDm[2] <= bMACDs[2] for bullish, the mirror for bearish. The cross alone is rejected. Second, the same function checks bADX[1] >= 20.0 (the ADX_TREND_THRESHOLD define) — without trend strength, no trade. Third, RSI(14) must agree with the direction: bullish entries require rsiNow < 65 AND rsiNow > 40 (oversold + 5), bearish entries require rsiNow > 35 AND rsiNow < 60 (overbought − 5). The RSI bands are deliberately narrow (RSI_OVERSOLD = 35, RSI_OVERBOUGHT = 65) so the EA trades pullbacks, not extremes. Fourth, the close of the signal bar must agree with the LTF EMA(50) — close > emaNow for longs, close < emaNow for shorts. All four conditions are AND-ed inside CoreSignal(). The function also returns a confidence score derived from ADX*1.5 + (RSI-extreme distance)*2.0 clamped to 100 — passed forward for logging and to support future weighting.

Confirmation runs through ConfirmEntry() (lines 485-509). The HTF EMA(50) is read on a higher timeframe selected by the InpHTFTimeframe input — note that the input's int range only goes 1-7 (M1 through D1), and the default value of 8 falls through to MapTimeframeInt's default case which returns PERIOD_H1, so out of the box the HTF is H1. A long is blocked if the signal bar's close is below the HTF EMA50 (a long into a higher-timeframe downtrend is refused), and shorts are blocked on the mirror. Spread must be at or below InpMaxSpreadPoints (default 50 points; for XAUUSD that's 5 pips of spread tolerance, which is fine for an ECN/raw broker but tight on retail). The session gate is 1 <= hour < 23 local time plus no-Sunday/no-Saturday, so the EA is in sleep mode only for the 23:00-01:00 server window plus weekends. The pre-trade reward-to-risk ratio check is the final gate: (TP_dist / SL_dist) < InpMinRR (default 1.5) blocks the trade. Because InpATR_TPmult = 2.0 and InpATR_SLmult = 1.5, the natural RR is 2.0/1.5 = 1.33, which is below the 1.5 minimum — meaning the default settings actually never fire unless the user either widens SL to 1.33× ATR (1.33/1.5 = 0.89 ratio... no wait, 1.5/2.0 = 0.75) or raises RR awareness. This is a meaningful configuration caveat: the out-of-the-box RR filter effectively hard-blocks the EA. Traders who set InpMinRR = 1.0 (or 1.2) will see entries; traders who leave it at 1.5 will see almost nothing.

The 7-state regime classifier (ClassifyRegime() lines 424-444) is built from ADX(14) + ATR(14)-percentile + BB(20,2.0)-width-percentile. The state machine reads ADX >= 28 + ATR-pctile >= 70 + BB-width-pctile >= 70 to declare REG_EXPAND; ADX >= 28 alone as REG_STRONG_TREND; ADX >= 20 (and not strong) as REG_WEAK_TREND; BB-width-pctile <= 15 as REG_COMPRESS; ATR-pctile >= 75 as REG_BREAKOUT; ATR-pctile <= 25 && BB-width-pctile <= 30 as REG_RANGE; and ADX < 15 as REG_CHOPPY. The classifier's job is mostly defensive: the no-trade gate hard-blocks CHOPPY and COMPRESS regimes, and the management loop closes any open position when the regime flips to CHOPPY. The other states are not gating — STRONG_TREND, WEAK_TREND, RANGE, BREAKOUT, EXPAND are passed through with the regime name logged for post-trade analysis. The regime label travels into the trade comment via RegimeName(g_regime) so each open order is tagged with the regime under which it was taken — useful when sorting backtest results.

Risk and sizing flow through CalcLotByRisk(slDistance) (lines 613-625). The function reads EffectiveCapital() which is min(InpCapitalCapAmount, account equity) if a cap is set, otherwise just account equity. The dollar risk is 0.5% of that by default (InpRiskPercent = 0.5), and the lot size is riskCash / (slDist * tickValue / tickSize), normalized to the symbol's volume step and clamped to min/max. This is the lowest risk-per-trade default in the EX10 family (EX10007/EX10008 default 0.7%) — a deliberate conservative choice for the MACD-cross approach, which has a higher per-trade frequency than the EMA-cross variants. The capital cap is opt-in: InpCapitalCapAmount = 0.0 disables it. The InpCapitalCapFloor = 50.0 defines the line below which no new entries are taken when the cap is active. PreCheckMargin() calls OrderCalcMargin before sending and aborts if the result exceeds free margin — a critical safety net for ECN accounts that allow low-free-margin scaling.

The exit stack in ManageExits() (lines 726-839) is the most complete in the EX10 family. On every tick it walks all open positions and runs six checks in order. (1) Opposite-signal exit: a fresh CoreSignal() value of −1 closes a long, +1 closes a short. (2) Regime change to CHOPPY closes the position immediately. (3) Time stop at MAX_BARS_IN_TRADE = 60 bars (5 hours on M5, 15 hours on M15) closes any position still open past its max hold. (4) Break-even one-shot: when rMult >= InpBE_TriggerR (= 1.0R), the stop is moved to entry price (with stop-level adjustment). (5) Partial TP: when price reaches open + 1.0 * TP_dist for longs (mirror for shorts), and only if vol >= 2*min_lot, the EA closes 50% of the position. (6) ATR trail at ATR_TRAIL_MULT = 2.5wider than the 1.01.5 trail used in EX10007/EX10008 — moves the stop each tick to curPrice − 2.5*ATR for longs, and only tightens (never loosens). (7) Session-close: at hour >= SESSION_END_HOUR − 1 (= 22), all positions are force-closed. The combination produces trades that bank at +1R, scale out at the 2.0R target, and trail the rest with a wide ATR envelope so the winner can extend through 3-4R moves without being shaken out.

Order execution is wrapped in retry logic — TryClose_EX10009, TryClosePartial_EX10009, and TryModify_EX10009 (lines 1015-1060) each loop up to 3 attempts on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED with 200ms backoff. TryEntry (lines 647-706) catches requote/price-off on the initial send and retries once with price=0 so the broker fills at current market. The default filling policy is auto-detected by symbol via SetTypeFillingBySymbol(_Symbol). Deviation is set to InpMaxSpreadPoints = 50 (the same as the spread filter — a single tolerance number covers both entry slippage and the max-spread gate, which simplifies the mental model).

The no-trade gate (lines 512-546) is conservative. It hard-blocks: kill-switch on, spread > 50 points, weekend, off-session (hour < 1 or hour >= 23), REG_CHOPPY, REG_COMPRESS, max concurrent positions reached, BelowFloor(), daily loss ≥ 3% of effective capital, weekly loss ≥ 6%, cooldown still active, or SYMBOL_TRADE_MODE not in FULL/LONGONLY/SHORTONLY. The daily/weekly loss checks read realized PnL from the deal history (filtered by magic and symbol) — not from the EA's own bookkeeping, which means swap and commission are included. TrackLossStreak() walks the recent close deals and counts consecutive losers; once the count reaches InpCooldownLosses = 3, it sets cooldownUntil = lastCloseTime + COOLDOWN_BARS * PeriodSeconds = 12 bars = 60 minutes on M5 / 3 hours on M15.

The OnTester() fitness function (lines 1003-1013) returns (net * PF) / (1.0 + DD) with a 30-trade minimum — so the optimizer will reward combinations with high net profit, profit factor, and low drawdown, but reject any pass that didn't generate at least 30 trades. For strategy-tester use, set the optimization criterion to Custom max and use this expression. For live use, the InpDryRun=true default is the most important parameter in the file: it ships as a paper-trading EA, and the user must explicitly set it to false to send real orders. Combined with InpKillSwitch, the operator has a one-flag panic button.

What to expect in backtest: a 1.5R/1.5×ATR SL vs 2.0R/2.0×ATR TP setup will show a healthy mix of partial-TP winners and BE-flat losers, with a few trail-extended runners carrying 3-5R. Because the regime classifier hard-blocks CHOPPY/COMPRESS and the MACD signal already requires ADX ≥ 20, the EA will sit out of low-volatility regimes entirely, then fire frequently when trend strength returns. The default settings on M5 XAUUSD on an H1-trending day will produce 4-10 entries per session; the default settings on a quiet Asian session will produce 0-1. The session window of 01:00-22:59 server time covers the full London and New York sessions and most of the Asian session — effectively 24/5 minus a 2-hour late-evening pause.

Strategy Deep Dive

MACD-line crossovers fire constantly, so the EA wraps a 4-condition AND stack around them: ADX(14) ≥ 20 (trend-strength floor), RSI(14) in a narrow 40-65 zone (pullback not extreme), close above LTF EMA(50) (trend agreement), and the MACD cross itself on the last closed bar. The resulting signal still gets two more gates: HTF EMA(50) agreement on a higher timeframe (default H1) and a TP/SL ratio that meets InpMinRR. Below both gates sits a 7-state regime classifier built from ADX + ATR-percentile + BB-width-percentile; CHOPPY and COMPRESS regimes are hard-blocked from entry. The risk stack applies 0.5% of effective capital per trade (the lowest default in the EX10 family), with capital cap opt-in and a $50 floor. InpDryRun=true ships as default — the operator must explicitly disable dry-run to send live orders. The exit cascade is the most complete in the EX10 family: opposite-signal, regime=CHOPPY, 60-bar time stop, BE at +1R, 50% partial at +2.0×ATR, ATR(14) trail at 2.5×ATR that only tightens, and session-close at hour 22:00+.

Entry Signal

Long entry fires when MACD(12,26,9) main line crosses above its signal line on the closed bar AND ADX(14) is at or above 20 AND RSI(14) sits between 40 and 65 (RSI extreme pullback zone) AND the close is above the LTF EMA(50). Short entry mirrors all four conditions. Confirmation then requires HTF EMA(50) agreement, spread ≤ 50 points, session hour between 1 and 23, and TP/SL ratio ≥ InpMinRR (default 1.5). The signal is read once per bar (shift=1) so no repaint.

Exit Signal

Exit stack runs six checks per tick: opposite-signal closes the position, regime flip to CHOPPY closes immediately, time stop at 60 bars fires the close, break-even at +1R moves stop to entry, partial close of 50% volume at +1R, and ATR(14) trailing at 2.5×ATR that only tightens. Session-close forces all positions closed at hour 22:00 and later.

Stop Loss

Per-trade stop-loss is InpATR_SLmult × ATR(14) (default 1.5×), giving roughly 1.5× the recent 14-bar range as the SL distance. The SL is sized to the risk percent (0.5% of effective capital by default) and clamped to the symbol's stop-level minimum. Stops only ratchet in the profitable direction (BE at +1R, then ATR trail tightens).

Take Profit

TP1 (used for partial close of 50%) is at open + 2.0× ATR(14); the final TP for the residual position is left open so the ATR(14) trail at 2.5×ATR can carry the winner. With SL at 1.5×ATR and TP1 at 2.0×ATR, the natural RR is 1.33, but the user-configurable InpMinRR=1.5 default effectively hard-blocks the EA until that floor is lowered.

Best For

Minimum recommended balance: $100. Best on XAUUSD M5 during the 01:00-22:59 server-time window (London and New York fully covered, Asian session partly covered). Requires an ECN or RAW-spread broker — the 50-point spread gate plus the InpMinRR=1.5 floor together mean retail accounts with widened spreads will be excluded from most entries. The 0.5% per-trade risk and 3%/6% daily/weekly loss caps make this a conservative risk profile for the EX10 family, but the MACD-cross approach and the default InpMinRR=1.5 mismatch mean this is not a 'set-and-forget' EA: the operator should set InpMinRR to 1.0-1.2 for default RR (1.5/2.0), or widen InpATR_TPmult to 2.25+ to satisfy the 1.5 floor naturally. InpDryRun=true is the safe shipping default — start in paper mode, verify the trade frequency on your broker's spread, then disable dry-run for live use.

Strategy Logic

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

Family: Momentum-Scalper Magic: 22210009 Version: 2.00

BRIEF: Core signal = MACD(main/signal) cross confirmed by RSI extreme pullback AND ADX>threshold, on the last CLOSED bar

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • EffectiveCapital()
  • BelowFloor()
  • CountMyPositions()
  • NormalizeVolume()
  • NormalizePrice()
  • StopsLevelPrice()
  • AdjustSLforStops()
  • AdjustTPforStops()
  • ATRPercentile()
  • BBWidth()
  • BBWidthPercentile()
  • CoreSignal()
  • ...and 17 more

INTERNAL CONSTANTS (1 total):

  • SPREAD_ROLLING_LOOKBACK = 30 // ==================================================================

INPUT PARAMETERS (21 total across 6 groups):

  • [=== Identity ===] InpMagic = 22210009 // Magic number (unique per EA)
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_10009" // Trade comment
  • [=== Identity ===] InpDryRun = true // Dry-run (no live orders)
  • [=== Identity ===] InpKillSwitch = false // Kill switch (close-only mode)
  • [=== Risk & Sizing ===] InpRiskPercent = 0.5 // Risk per trade (% of effective capital)
  • [=== Risk & Sizing ===] InpDailyLossLimit = 3.0 // Daily loss limit (% of effective capital)
  • [=== Risk & Sizing ===] InpWeeklyLossLimit = 6.0 // Weekly loss limit (% of effective capital)
  • [=== Risk & Sizing ===] InpMaxConcurrent = 1 // Max concurrent open trades
  • [=== Risk & Sizing ===] InpMaxSymbolExposure = 1 // Max open trades on this symbol
  • [=== Risk & Sizing ===] InpCooldownLosses = 3 // Loss streak cooldown trigger
  • [=== Capital Allocation Cap ===] InpCapitalCapAmount = 0.0 // Cap amount (real-money equity $)
  • [=== Capital Allocation Cap ===] InpCapitalCapFloor = 50.0 // Floor below which no new entries
  • [=== Signal ===] InpADXPeriod = 14 // ADX period
  • [=== Signal ===] InpRSIPeriod = 14 // RSI period
  • [=== Signal ===] InpMACDFast = 12 // MACD fast EMA period
  • [=== Regime & Confirm ===] InpHTFTimeframe = 8 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher-timeframe bias frame
  • [=== Regime & Confirm ===] InpMinRR = 1.5 // Minimum reward:risk ratio
  • [=== Regime & Confirm ===] InpMaxSpreadPoints = 50 // Max allowed spread (points)
  • [=== Exit & Manage ===] InpATR_SLmult = 1.5 // ATR stop-loss multiplier
  • [=== Exit & Manage ===] InpATR_TPmult = 2.0 // ATR take-profit multiplier (also TP1)
  • [=== Exit & Manage ===] InpBE_TriggerR = 1.0 // Break-even trigger (in R multiples)
Pseudocode
// Pipsgrowth EX10009 Momentum-Scalper — Execution Flow (from source analysis)
// Family: Momentum-Scalper
// Core signal = MACD(main/signal) cross confirmed by RSI extreme pullback AND ADX>threshold, on the last CLOSED bar

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:
M5M15

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
InpMagic22210009Magic number (unique per EA)
InpTradeComment"Psgrowth.com Expert_10009"Trade comment
InpDryRuntrueDry-run (no live orders)
InpKillSwitchfalseKill switch (close-only mode)
InpRiskPercent0.5Risk per trade (% of effective capital)
InpDailyLossLimit3.0Daily loss limit (% of effective capital)
InpWeeklyLossLimit6.0Weekly loss limit (% of effective capital)
InpMaxConcurrent1Max concurrent open trades
InpMaxSymbolExposure1Max open trades on this symbol
InpCooldownLosses3Loss streak cooldown trigger
InpCapitalCapAmount0.0Cap amount (real-money equity $)
InpCapitalCapFloor50.0Floor below which no new entries
InpADXPeriod14ADX period
InpRSIPeriod14RSI period
InpMACDFast12MACD fast EMA period
InpHTFTimeframe8Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher-timeframe bias frame
InpMinRR1.5Minimum reward:risk ratio
InpMaxSpreadPoints50Max allowed spread (points)
InpATR_SLmult1.5ATR stop-loss multiplier
InpATR_TPmult2.0ATR take-profit multiplier (also TP1)
InpBE_TriggerR1.0Break-even trigger (in R multiples)
Source Code (.mq5)Open Source
Pipsgrowth_com_EX10009.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX10009 gold_scalping — MACD cross + RSI extreme momentum scalper, full 12-layer stack."

#include <Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
#include <Trade\OrderInfo.mqh>
#include <Trade\DealInfo.mqh>

//--- Non-input tunables (#define constants)
#define MACD_SLOW_EMA          26
#define MACD_SIGNAL_PERIOD     9
#define BB_PERIOD              20
#define BB_DEV                 2.0
#define ATR_PERIOD             14
#define ATR_PCTILE_LOOKBACK    100
#define ADX_TREND_THRESHOLD    20.0
#define ADX_STRONG_TREND       28.0
#define RSI_OVERSOLD           35.0
#define RSI_OVERBOUGHT         65.0
#define SESSION_START_HOUR     1
#define SESSION_END_HOUR       23
#define HTF_EMA_PERIOD         50
#define MAX_BARS_IN_TRADE      60
#define PARTIAL_TP_PCT         50
#define ATR_TRAIL_MULT         2.5
#define COOLDOWN_BARS          12
#define PYRAMID_MAX_LEVELS     5
#define PYRAMID_DEFAULT_OFF    true
#define SPREAD_ROLLING_LOOKBACK 30

//==================================================================
// INPUTS (18 total — within 12-22 hard cap)
//==================================================================
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
   switch(tf)
   {
      case 1: return PERIOD_M1;
      case 2: return PERIOD_M5;
      case 3: return PERIOD_M15;
      case 4: return PERIOD_M30;
      case 5: return PERIOD_H1;
      case 6: return PERIOD_H4;
      case 7: return PERIOD_D1;
      default: return PERIOD_H1;
   }
}

ENUM_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
   switch(ap)
   {
      case 1: return PRICE_CLOSE;
      case 2: return PRICE_OPEN;
      case 3: return PRICE_HIGH;

Full source code available on download

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

Tags:ex10009momentum-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_EX10009.mq5
File Size35.9 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyScalping
Risk LevelHigh Risk
Timeframes
M5M15
Currency Pairs
XAUUSD
Min. Deposit$100