P
PipsGrowth
ScalpingOpen Source – Free

Pipsgrowth EX10002 Momentum-Scalper

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

Pipsgrowth.com EX10002 RSI Momentum XAUUSD 5M — Fast/Slow RSI cross + 200-EMA trend filter, full 12-layer stack.

Overview

EX10002 Momentum-Scalper reads gold momentum through a pair of Relative Strength Index lines stacked on top of a slow 200-EMA regime filter, and enters only when both sides of the indicator agree. On every closed bar the EA pulls two RSI buffers from the same close price stream — a fast 9-period RSI and a slow 21-period RSI — and watches the spread between them. The fast line is the timing wheel: it has to clear the slow 50-line (long) or fall under it (short) at the same time it crosses the slow RSI. The slow line is the conviction filter: the 21-period RSI has to read above 50 for buys and below 50 for sells, so the EA never fades a regime in motion. The 200-EMA on the same chart is the final gate — the bar-1 close has to be above it for buys and below it for sells. No single one of these three legs is enough on its own; all three have to align on the same bar, which is why the signal fires relatively rarely even on a busy pair like XAUUSD.

When a true crossover is not available, EX10002 falls back to a continuation branch. If the previous bar closed above the 200-EMA with a body covering more than 50% of its range, the fast RSI already above the slow RSI, and the fast RSI above the buy level (55 by default), the EA will treat that as a strong-trend bar and take the long. The mirror branch fires shorts under the EMA with the same body-quality and threshold conditions. Continuation entries are flagged with a 60/100 confidence score; crossover entries score the magnitude of the RSI separation, capped at 100.

Before any order goes out, the trade has to clear three independent confirmation gates. The first is regime: ADX(14) has to read at least 15 to certify that the market is trending, the current ATR has to sit between the 15th and 95th percentile of its last-50 reading (a cheap proxy that filters both dead-vol and spike candles), and the Bollinger Band width at 20 periods and 2.0 deviations has to be wider than the 10th percentile of its recent history so the EA refuses to trade in a tight squeeze. The second gate is higher-timeframe alignment: the EA copies an H1 50-EMA and requires the H1 close to be on the same side of that EMA as the trade direction. The third gate is participation: the current bar's tick volume has to be at least 80% of the rolling 20-bar average, otherwise the move is treated as unrepresentative and the trade is skipped.

Sizing follows the same conservative logic. The stop distance is two ATRs (InpATRMultiplier=2.0 by default), but never narrower than the broker's published stops-level floor. The take-profit sits at the same ATR distance scaled by the reward-to-risk multiple (InpMinRR=1.0 by default, so 1:1). Lot size is computed from the risk percent (3% of effective capital) divided by the loss-per-lot at that stop distance. The fixed-lot input (0.01) acts as a fallback when risk percent is set to zero. The capital cap is opt-in via InpCapitalCapAmount — if set, effective capital becomes the lesser of that number and account equity plus today's realized PnL, and entries are blocked below a $50 floor.

Once a position is live, EX10002 runs four management threads in series. The first watches the fast RSI for momentum decay — if the position is long and the fast RSI has dropped back under 50 while price is still above the entry, the EA closes the trade on the assumption that the impulse is gone. The second watches the signal evaluator for a counter-direction signal and exits on the first bar that flips. The third checks whether ADX has fallen out of the regime window and closes if the trend has died. The fourth is a hard time stop at 240 bars in trade, which forces a settlement even on quiet ranges. On top of those soft exits, the EA installs a one-shot break-even stop at the InpBETriggerR multiple (1R by default), shifted five points past entry to cover spread and commission. If InpUsePartialTP is on, the EA also closes half the position at the same 1R level when the volume is large enough to be split above the broker's minimum lot. After 1R is locked, an ATR trailing stop takes over at 2.5× the current ATR, ratcheting tighter on every bar that prints a new favorable price.

Risk is capped on three time horizons. Each trade risks 3% of effective capital. The day caps at 15% of effective capital in realized PnL, and the week at 25%. Cooldown fires after three consecutive losses — the EA blocks new entries for twelve bars on the working timeframe. The signal evaluator only runs on closed bars (g_lastEntryBar guard), so a single fast-market cascade cannot open a cluster of entries. Sending retries are double-layered: TryEntry catches transient REQUOTE/PRICE_OFF/TIMEOUT codes and resends once with refreshed prices, while the close and modify helpers loop up to three times at 200ms backoff before declaring failure. Filling mode is auto-selected from the broker's published mask, preferring FOK and falling back to IOC, then RETURN. The OnTester formula scores optimization runs as net profit times profit factor divided by one plus the relative balance drawdown, with a 30-trade minimum so a single lucky streak cannot game the criterion.

The 12-layer header in the source is not aspirational here — every layer has matching code. REGIME is the three-axis ADX/ATR-percentile/BB-width check. SIGNAL is the dual-RSI crossover with body-quality continuation fallback. ENTRY is the TryEntry path. CONFIRM is the H1-EMA plus tick-volume check. NO-TRADE is the capital floor, daily/weekly loss caps, cooldown, spread filter, session window, and one-bar-per-bar guard in OnTick. CAPITAL CAP is the opt-in effective-capital computation. RISK and SIZING are the per-trade percent and ATR distance calculation. MANAGE is the break-even, optional partial TP, and ATR trailing. EXIT is the four-thread soft-exit stack. SCALING is the lot rounding and broker-step clamp. OnTester is the custom criterion. The 200-EMA is the spine that ties the whole structure together — every entry and every exit references price relative to it.

Strategy Deep Dive

EX10002 is built around a 7-handle indicator stack: fast RSI(9), slow RSI(21), EMA(200) on the working timeframe, ADX(14), ATR(14), Bollinger Bands(20, 2.0), and an H1 50-EMA for higher-timeframe alignment. The OnTick handler runs the management block first so existing positions are serviced even when entry conditions would otherwise block new orders, then refreshes the daily/weekly realized PnL windows, recomputes effective capital, and walks through the no-trade gates — capital floor, daily loss cap at 15%, weekly loss cap at 25%, cooldown until time, single-bar-per-bar guard, spread filter at 250 points, terminal-and-symbol trade-allowed check, and the optional session and news windows — before calling EvaluateSignal. The signal path reads bar-1 indicator values only, which is why the strategy works on closed-bar timing even when the EA is attached to every tick. TryEntry checks regime, confirmation, position count, and margin availability in that order, then builds the SL/TP and dispatches the order with one transient-retry safety net. The custom OnTester formula scores optimization runs as net profit times profit factor divided by one plus relative balance drawdown, with a 30-trade minimum.

Entry Signal

EX10002 enters on the closed bar when the 9-period fast RSI crosses the 21-period slow RSI while both are on the right side of 50 (fast above 55 with slow above 50 for longs, fast below 45 with slow below 50 for shorts) and the bar-1 close is beyond the 200-EMA in the trade direction. A continuation branch catches strong body bars (body>0.5 of range) when the cross hasn't printed but the fast RSI is still on the correct side of the slow. The position then has to pass the regime gate (ADX>=15, ATR percentile 15-95, BB width>10), the H1 50-EMA side check, and a tick-volume filter at 80% of the 20-bar average before any order is sent.

Exit Signal

Exits happen on the first matching event: a fast-RSI momentum decay (fast<50 on a long while price is still above entry, mirror for shorts), a counter-direction signal from the same dual-RSI evaluator, a regime break (ADX falling out of the trend window), or the 240-bar hard time stop. A break-even stop moves to entry +5 points the moment the trade reaches 1R; if InpUsePartialTP is enabled, half the position closes at that 1R threshold. After 1R is locked the stop is replaced by an ATR trailing stop at 2.5x ATR, ratcheting tighter on each favorable bar.

Stop Loss

Stop loss is set to 2.0× the current ATR(14) from the entry price, but never narrower than the broker's published stops-level floor. The risk is sized at 3% of effective capital, with a $50 capital floor and an opt-in InpCapitalCapAmount ceiling that limits the equity the EA is allowed to risk.

Take Profit

Take profit is set to the same ATR distance as the stop multiplied by the reward-to-risk input (InpMinRR=1.0 by default, so 1:1). The position is then handed to break-even, optional half-close, and ATR trailing logic. The break-even shift is offset by 5 points past entry to cover spread and commission, and the trailing stop activates at 2.5× ATR after 1R is reached.

Best For

EX10002 is built for XAUUSD on the M5 timeframe, with M15 as the secondary slot when traders want fewer signals and wider stops. Recommended starting balance is $100 per magic number; risk level is HIGH because the default 3% per-trade risk, 2.0× ATR stops, and 1:1 R:R are tuned for the M5 gold-session volatility profile. Run on a low-spread ECN or RAW broker — the 250-point spread cap and 20-point execution deviation assume execution under 25 pips on gold. The London and New York sessions (8-17 server time) are the productive window because ADX, ATR percentile, and H1 trend alignment all need the active FX hours. Cooldown, regime, and the tick-volume filter do most of the loss-limiting work, so traders who want to add this to a portfolio should size the magic as a satellite, not a core position.

Strategy Logic

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

Family: Momentum-Scalper Magic: 22210002 Version: 2.00

BRIEF: RSI momentum — Fast RSI (>55 / <45) crossing above/below Slow RSI (>50 / <50) in the direction of price>200-EMA. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • ComputeEffectiveCapital()
  • UpdateRealizedPnL()
  • RegimeOK()
  • EvaluateSignal()
  • ConfirmOK()
  • CountOurPositions()
  • CalcLotForATRStop()
  • NormalizeLot()
  • TryEntry()
  • ManageTrades()
  • ModifySLTP()
  • ClosePosition()
  • ...and 6 more

INTERNAL CONSTANTS (28 total):

  • DEF_BB_PERIOD = 20 // BB period
  • DEF_BB_DEVIATION = 2.0 // BB deviation
  • DEF_TREND_MA_PERIOD = 200 // Trend filter EMA period
  • DEF_ATR_PCT_LOOKBACK = 50 // ATR-percentile lookback
  • DEF_ATR_PCT_LO = 15 // ATR percentile min allowed (dead-vol filter)
  • DEF_ATR_PCT_HI = 95 // ATR percentile max allowed (spike filter)
  • DEF_BBW_PCT_LO = 10 // BB-width percentile min (avoid dead squeeze)
  • DEF_HTF_TF = PERIOD_H1 // HTF trend timeframe
  • DEF_HTF_EMA_PERIOD = 50 // HTF EMA period
  • DEF_VOL_LOOKBACK = 20 // Tick-volume rolling average
  • DEF_SESSION_START = 7 // London/NY session start hour (server)
  • DEF_SESSION_END = 21 // Session end hour (server)
  • DEF_NEWS_START_HOUR = 12 // Soft news-blackout start
  • DEF_NEWS_END_HOUR = 14 // Soft news-blackout end
  • DEF_MAX_BARS_IN_TRADE = 240 // Max bars in trade (time exit)
  • ...and 13 more

INPUT PARAMETERS (31 total across 7 groups):

  • [=== Tunable Strategy ===] InpUsePartialTP = false // Use partial take-profit (false=let winners run)
  • [=== Tunable Strategy ===] InpTrendMAPeriod = 200 // Trend EMA period (core trend filter)
  • [=== Tunable Strategy ===] InpTrailAtrMult = 2.5 // ATR trailing multiplier
  • [=== Tunable Strategy ===] InpMaxBarsInTrade = 240 // Max bars in trade (time exit)
  • [=== Tunable Strategy ===] InpMaxSpread = 250 // Max spread in points
  • [=== Tunable Strategy ===] InpSessionStart = 0 // Session start hour (0=24h)
  • [=== Tunable Strategy ===] InpSessionEnd = 24 // Session end hour (24=24h)
  • [=== Tunable Strategy ===] InpNewsStart = 0 // News blackout start (0=disabled)
  • [=== Tunable Strategy ===] InpNewsEnd = 0 // News blackout end (0=disabled)
  • [=== Tunable Strategy ===] InpMomentumDecayRSI = 50.0 // RSI level for momentum decay exit
  • [=== Tunable Strategy ===] InpBETriggerR = 1.0 // Break-even trigger in R multiples
  • [=== Tunable Strategy ===] InpMinHoldBars = 3 // Min bars before soft exits allowed
  • [=== Identity ===] InpMagic = 22210002 // Magic number (unique per EA)
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_10002" // Trade comment
  • [=== Identity ===] InpDryRun = false // Dry-run (no live sends)
  • [=== Identity ===] InpKillSwitch = false // Kill switch (closes-all on tick)
  • [=== Risk & Sizing ===] InpRiskPercent = 3.0 // Risk per trade (% of effective capital)
  • [=== Risk & Sizing ===] InpFixedLot = 0.01 // Fixed lot fallback (used when Risk%<=0)
  • [=== Risk & Sizing ===] InpDailyLossLimitPercent = 15.0 // Daily loss limit (% of effective capital)
  • [=== Risk & Sizing ===] InpWeeklyLossLimitPercent = 25.0 // Weekly loss limit (% of effective capital)
  • [=== Risk & Sizing ===] InpMaxConcurrent = 1 // Max concurrent positions (this EA+symbol)
  • [=== Capital Allocation Cap ===] InpCapitalCapAmount = 0.0 // Capital cap amount ($ REAL MONEY equity)
  • [=== Capital Allocation Cap ===] InpCapitalCapFloor = 50.0 // Floor below which new entries are blocked ($)
  • [=== Signal (RSI Momentum) ===] InpRSIFastPeriod = 9 // Fast RSI period
  • [=== Signal (RSI Momentum) ===] InpRSISlowPeriod = 21 // Slow RSI period
  • [=== Signal (RSI Momentum) ===] InpRSIBuyLevel = 55.0 // Fast RSI buy threshold
  • [=== Signal (RSI Momentum) ===] InpRSISellLevel = 45.0 // Fast RSI sell threshold
  • [=== Regime / Confirm ===] InpMinADX = 15.0 // Minimum ADX main (trend strength)
  • [=== Regime / Confirm ===] InpMinRR = 1.0 // Minimum reward:risk for entry
  • [=== Exit / Manage ===] InpATRPeriod = 14 // ATR period (SL/trail)
  • [=== Exit / Manage ===] InpATRMultiplier = 2.0 // ATR SL multiplier
Pseudocode
// Pipsgrowth EX10002 Momentum-Scalper — Execution Flow (from source analysis)
// Family: Momentum-Scalper
// RSI momentum — Fast RSI (>55 / <45) crossing above/below Slow RSI (>50 / <50) in the direction of price>200-EMA. 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:
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
InpUsePartialTPfalseUse partial take-profit (false=let winners run)
InpTrendMAPeriod200Trend EMA period (core trend filter)
InpTrailAtrMult2.5ATR trailing multiplier
InpMaxBarsInTrade240Max bars in trade (time exit)
InpMaxSpread250Max spread in points
InpSessionStart0Session start hour (0=24h)
InpSessionEnd24Session end hour (24=24h)
InpNewsStart0News blackout start (0=disabled)
InpNewsEnd0News blackout end (0=disabled)
InpMomentumDecayRSI50.0RSI level for momentum decay exit
InpBETriggerR1.0Break-even trigger in R multiples
InpMinHoldBars3Min bars before soft exits allowed
InpMagic22210002Magic number (unique per EA)
InpTradeComment"Psgrowth.com Expert_10002"Trade comment
InpDryRunfalseDry-run (no live sends)
InpKillSwitchfalseKill switch (closes-all on tick)
InpRiskPercent3.0Risk per trade (% of effective capital)
InpFixedLot0.01Fixed lot fallback (used when Risk%<=0)
InpDailyLossLimitPercent15.0Daily loss limit (% of effective capital)
InpWeeklyLossLimitPercent25.0Weekly loss limit (% of effective capital)
InpMaxConcurrent1Max concurrent positions (this EA+symbol)
InpCapitalCapAmount0.0Capital cap amount ($ REAL MONEY equity)
InpCapitalCapFloor50.0Floor below which new entries are blocked ($)
InpRSIFastPeriod9Fast RSI period
InpRSISlowPeriod21Slow RSI period
InpRSIBuyLevel55.0Fast RSI buy threshold
InpRSISellLevel45.0Fast RSI sell threshold
InpMinADX15.0Minimum ADX main (trend strength)
InpMinRR1.0Minimum reward:risk for entry
InpATRPeriod14ATR period (SL/trail)
InpATRMultiplier2.0ATR SL multiplier
Source Code (.mq5)Open Source
Pipsgrowth_com_EX10002.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX10002 RSI Momentum XAUUSD 5M — Fast/Slow RSI cross + 200-EMA trend filter, full 12-layer stack."

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


input group "=== Tunable Strategy ==="
input bool           InpUsePartialTP      = false;           // Use partial take-profit (false=let winners run)
input int            InpTrendMAPeriod     = 200;             // Trend EMA period (core trend filter)
input double         InpTrailAtrMult      = 2.5;             // ATR trailing multiplier
input int            InpMaxBarsInTrade    = 240;             // Max bars in trade (time exit)
input int            InpMaxSpread         = 250;             // Max spread in points
input int            InpSessionStart      = 0;               // Session start hour (0=24h)
input int            InpSessionEnd        = 24;              // Session end hour (24=24h)
input int            InpNewsStart         = 0;               // News blackout start (0=disabled)
input int            InpNewsEnd           = 0;               // News blackout end (0=disabled)
input double         InpMomentumDecayRSI  = 50.0;            // RSI level for momentum decay exit
input double         InpBETriggerR        = 1.0;             // Break-even trigger in R multiples
input int            InpMinHoldBars       = 3;               // Min bars before soft exits allowed

//--- Non-operator tunables (kept as #define to keep input count <= 22) ---//
#define DEF_BB_PERIOD           20          // BB period
#define DEF_BB_DEVIATION        2.0         // BB deviation
#define DEF_TREND_MA_PERIOD     200         // Trend filter EMA period
#define DEF_ATR_PCT_LOOKBACK    50          // ATR-percentile lookback
#define DEF_ATR_PCT_LO          15          // ATR percentile min allowed (dead-vol filter)
#define DEF_ATR_PCT_HI          95          // ATR percentile max allowed (spike filter)
#define DEF_BBW_PCT_LO          10          // BB-width percentile min (avoid dead squeeze)
#define DEF_HTF_TF              PERIOD_H1   // HTF trend timeframe
#define DEF_HTF_EMA_PERIOD      50          // HTF EMA period
#define DEF_VOL_LOOKBACK        20          // Tick-volume rolling average
#define DEF_SESSION_START       7           // London/NY session start hour (server)
#define DEF_SESSION_END         21          // Session end hour (server)
#define DEF_NEWS_START_HOUR     12          // Soft news-blackout start
#define DEF_NEWS_END_HOUR       14          // Soft news-blackout end
#define DEF_MAX_BARS_IN_TRADE   240         // Max bars in trade (time exit)
#define DEF_BE_TRIGGER_R        1.0         // Break-even trigger (R multiples)
#define DEF_BE_OFFSET_POINTS    5           // BE lock offset (points)
#define DEF_PARTIAL_FRAC        0.5         // Partial TP fraction
#define DEF_PARTIAL_R           1.0         // Partial TP trigger (R multiples)
#define DEF_TRAIL_START_R       1.0         // Trail activation (R multiples)
#define DEF_TRAIL_ATR_MULT      2.5         // ATR trail multiplier
#define DEF_COOLDOWN_BARS       12          // Bars cooldown after consecutive losses
#define DEF_COOLDOWN_LOSSES     3           // Consecutive losses to trigger cooldown
#define DEF_MAX_PYRAMID         3           // Max pyramid levels (hard cap)
#define DEF_PYRAMID_SPACING_ATR 1.5         // Pyramid spacing (ATR multiples)
#define DEF_MAX_SPREAD_POINTS   250         // Max spread (points) — auto-clamped to stops
#define DEF_DEVIATION_POINTS    20          // Order send deviation (points)
#define DEF_MOMENTUM_DECAY_RSI  50.0        // Exit when fast RSI re-crosses 50

//--- Input Groups --------------------------------------------------//
input group "=== Identity ==="
input long              InpMagic           = 22210002;                              // Magic number (unique per EA)
input string            InpTradeComment    = "Psgrowth.com Expert_10002";           // Trade comment

Full source code available on download

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

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