P
PipsGrowth
ScalpingOpen Source – Free

Pipsgrowth EX10005 Momentum-Scalper

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

Pipsgrowth.com EX10005 Scalper XAUUSD 5M — fractal breakout momentum scalper, full 12-layer stack.

Overview

Pipsgrowth EX10005 Momentum-Scalper trades fractal breakouts on XAUUSD. The signal it cares about is a structural one: the close of the most recent completed bar either breaking above the last confirmed up-fractal or breaking below the last confirmed down-fractal, in the direction that price already has relative to a 50-period EMA. Everything else in the EA exists to either qualify that breakout or survive its consequences.

How the fractal signal forms

The source defines a confirmed fractal as the kind Bill Williams originally charted — a bar whose high is the highest of the surrounding 5-bar window (up-fractal) or whose low is the lowest (down-fractal). The MT5 iFractals indicator populates those levels with a two-bar delay, which is why the EA reads from shift 2 inward, never from the forming bar. The EvaluateSignal() function copies both the upper and lower fractal buffers for DEF_FRACTAL_BARS = 5 closed bars, scans for the most recent non-empty value, and on bar 1 checks three things: is close > EMA(50) (or < for shorts), did close actually cross the last fractal level, and is the bar's body — MathAbs(close1 - open1) — at least 0.25 × ATR(14). All three have to clear before the EA reports a direction. A confidence score is computed from the body-to-ATR ratio and capped at 100, but it is only used for logging; the actual gating is binary.

Why fractal breakouts on gold

Gold is a market that trends in bursts and respects the geometry of previous swing points. Fractal breakouts capture the moment a swing high or swing low gives way, which is the moment where stops cluster and momentum tends to extend. The EMA(50) on the working timeframe provides the directional bias so the EA only buys fractal-ups and only sells fractal-downs. The 50-period EMA on H1 (DEF_HTF_TF = PERIOD_H1, DEF_HTF_EMA_PERIOD = 50) is checked by ConfirmOK(): the close of the last H1 bar has to be on the same side of the H1 EMA as the working-timeframe direction. A 20-bar tick-volume ratio of at least 0.8 (DEF_VOL_MIN_RATIO) further disqualifies the trade if the breakout is happening on a thin tape.

Regime gates

The RegimeOK() function runs before the entry is dispatched. ADX(14) main line has to be at least 18 (InpMinADX = 18.0) — below that, the market is chop and breakouts fail. ATR-percentile gating uses a 50-bar lookback (DEF_ATR_PCT_LOOKBACK = 50): the current ATR must be between the 15th and 95th percentiles of that distribution. Below 15 means dead volatility where the breakout will not pay for spread; above 95 means a news spike where the spread will widen and stops will slip. Bollinger Bands(20, 2.0) are sampled for their width; a current width below the 10th percentile of the lookback distribution is a "squeeze" — a low-conviction state the EA refuses. These three gates running together explain why EX10005 fires only on real, sustained directional moves and stays quiet through Asian-session churn.

Stop, target, and position sizing

The stop is ATR(14) × 2.0 (InpATRMultiplier = 2.0) away from entry, with a floor at the broker's stops-level. The take-profit is the same distance × InpMinRR = 1.5, so each trade is entered with a 1:1.5 reward-to-risk. Position sizing is risk-percent based: InpRiskPercent = 0.5% of effective capital, divided by the per-lot loss at the ATR stop, normalized to the symbol's lot step. The InpFixedLot = 0.01 is the fallback when risk is set to zero or the lot computation hits a degenerate case. OrderCalcMargin pre-checks that the resulting order fits inside free margin before any trade.Buy() or trade.Sell() call goes out.

Position management in flight

ManageTrades() runs on every tick for every open position. It checks for opposite-signal exits first — if the EA sees a fractal-down signal on bar 1 while holding a long, it closes immediately. It also closes if the ADX(14) collapses below 18 (logged as "regime-change-ADX"). After those, a time exit fires at DEF_MAX_BARS_IN_TRADE = 240 bars (roughly 20 hours on M5). At 1R of profit, the stop is moved to break-even plus 5 points (DEF_BE_OFFSET_POINTS = 5). At 1R, 50% of the position is closed in a one-shot partial (DEF_PARTIAL_FRAC = 0.5). At 1R, an ATR(14) trail at 2.5× ATR begins, ratcheting the stop behind price without ever moving it backward. The partial TP is marked in the deal comment with [P] so it never re-triggers.

Pyramid mode (off by default)

InpEnablePyramid = false is the shipped default. When toggled on, the EA looks for its most profitable open position of either type, refuses to act unless that position is in profit, and adds a new entry only if the current price has moved at least DEF_PYRAMID_SPACING_ATR = 1.5 ATRs beyond the original open. Hard cap is DEF_MAX_PYRAMID = 3 per direction. RegimeOK() is rechecked before each add. There is no martingale and no lot escalation — the new leg is sized by the same risk formula as the first.

Loss-cap and cooldown architecture

UpdateRealizedPnL() rebuilds the daily and weekly realized P&L from HistoryDealsTotal() on every tick, filtering by magic and symbol, summing profit plus swap plus commission. Daily cap is 3% of effective capital (InpDailyLossLimitPercent = 3.0); weekly cap is 6% (InpWeeklyLossLimitPercent = 6.0). If either trips, no new entries are sent for the rest of the day or week. The cooldown layer watches the last hour of deal history; three consecutive losses (DEF_COOLDOWN_LOSSES = 3) push the EA into a 12-bar no-entry state (DEF_COOLDOWN_BARS = 12). A separate capital floor at InpCapitalCapFloor = 50.0 USD halts entries when effective equity drops below it.

Order-execution safety

OnInit() reads SYMBOL_FILLING_MODE and picks FOK, IOC, or RETURN in that order. trade.SetDeviationInPoints(20) caps the slippage the broker is allowed to charge. The spread filter is dynamic: the default ceiling is 250 points (DEF_MAX_SPREAD_POINTS = 250), but the EA also reads SYMBOL_TRADE_STOPS_LEVEL and, if the broker's stops-level is below 250, the spread cap is reduced to 4× the stops-level so a tight-stop entry can never be sent into a wider spread than its own protective distance. InpDryRun = true is the shipped default; with it on, the EA logs what it would have sent but does not place orders — the right starting posture for any broker-test or prop-firm trial.

When it should run and where

The session filter is server-time 7 to 21, the windows where London and New York overlap and XAUUSD is in genuine directional flow. Hours 12 to 14 are a soft news blackout (DEF_NEWS_START_HOUR = 12, DEF_NEWS_END_HOUR = 14) — non-feed, time-based only, so it will quiet the EA across the regular US-data release slot. Weekends are blocked. The OnTester formula is (net × profit-factor) / (1 + relative-DD) with a 30-trade minimum — that is what the MT5 Strategy Tester's optimization graph will rank the inputs by, so any parameter sweep is being scored on net × pf / (1 + DD) and not raw profit.

Bottom line

EX10005 is a regime-gated, fractal-breakout scalper for XAUUSD. It is conservative about when it trades (ADX/ATR-percentile/BB-width gates all have to clear), aggressive about how it manages a trade once on (1R BE, 50% partial, ATR trail), and quiet the rest of the time. With pyramid off, max three positions, and a 240-bar time exit, the worst-case live profile is well-bounded; the only requirement is a broker that keeps gold's spread inside the 250-point cap and the stops-level tight enough that the spread filter does not choke the entries.

Strategy Deep Dive

EX10005 runs a per-tick loop in OnTick() that, on every closed bar (shift=1, never shift=0), calls EvaluateSignal() to read iMA(50) plus the iFractals upper and lower buffers for a 5-bar window, and only reports a direction when the bar's close has crossed the most recent confirmed fractal level in the direction the EMA(50) side dictates, with the bar's body at least 0.25 × ATR(14). The signal then has to clear RegimeOK() (ADX(14) ≥ 18, ATR-percentile between 15 and 95, BB(20, 2.0) width above the 10th percentile of its 10-bar lookback), ConfirmOK() (close of the last H1 bar on the same side of H1 EMA(50) as the working-TF direction, plus tick-volume ratio ≥ 0.8 of the 20-bar average), the concurrent-position cap (3 per symbol), and the daily/weekly realized-loss caps (3% / 6%). CalcLotForATRStop() sizes the position at 0.5% risk, then OrderCalcMargin pre-checks the margin. Position management runs in ManageTrades() on every tick: opposite-signal close, regime-change close, 240-bar time exit, one-shot break-even at 1R with a 5-point offset, one-shot 50% partial at 1R, and an ATR(14) × 2.5 trailing stop that only ratchets forward. Three consecutive losses put the EA in a 12-bar cooldown. Pyramid mode (off by default) is profit-only, ATR-spaced, and capped at 3 levels per direction.

Entry Signal

Entries fire when the close of the most recent completed bar breaks above the last confirmed up-fractal (long) or below the last confirmed down-fractal (short), with price already on the corresponding side of EMA(50) and the bar body at least 0.25 × ATR(14). The 5-bar fractal scan only reads from shift=2 inward, so the forming bar is never used. The signal must also pass the regime gate (ADX(14) ≥ 18, ATR percentile between 15 and 95, BB-width above the 10th percentile), the HTF H1 EMA(50) alignment, and a tick-volume ratio ≥ 0.8 of the 20-bar average.

Exit Signal

Exits run in this order in ManageTrades(): opposite-signal close (fractal in the other direction on bar 1), regime-change close (ADX collapse under 18), time exit at 240 bars, then a one-shot break-even at 1R (entry + 5 points), a one-shot 50% partial at 1R, and an ATR(14) × 2.5 trailing stop that starts at 1R and only ratchets forward. A daily cap at 3% of effective capital and a weekly cap at 6% halt new entries for the rest of the period.

Stop Loss

Stop-loss is ATR(14) × 2.0 (InpATRMultiplier = 2.0) from entry, with a floor at the broker's stops-level. Risk per trade is 0.5% of effective capital (InpRiskPercent = 0.5%). A daily loss cap of 3% and a weekly cap of 6% of effective capital halt new entries once breached, and three consecutive losses trigger a 12-bar cooldown.

Take Profit

Take-profit is the ATR stop distance × InpMinRR = 1.5, giving a 1:1.5 reward-to-risk on entry. A 50% partial close fires at 1R profit (one-shot, marked [P] in the comment), and a break-even stop plus 5 points locks at the same 1R trigger. After 1R, an ATR(14) × 2.5 trail takes over and only ratchets forward.

Best For

Best for traders running XAUUSD on the M5 chart (M15 supported) during the London and New York windows (server hours 7 to 21, with a 12 to 14 soft-news blackout). The EA defaults to dry-run, so it is appropriate for a fresh broker test or a prop-firm evaluation before going live. Minimum recommended balance: $100 at the shipped 0.5% risk. Risk level is HIGH because of the 0.5% per-trade risk, the 3x concurrent cap, and the breakout strategy's reliance on trending gold moves. The spread cap of 250 points (auto-tightened to 4× the broker's stops-level) means a low-spread gold broker is required.

Strategy Logic

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

Family: Momentum-Scalper Magic: 22210005 Version: 2.00

BRIEF: Fractal breakout scalp — close breaks the most recent confirmed UP/DOWN fractal in the direction of price vs EMA(50)

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • ComputeEffectiveCapital()
  • UpdateRealizedPnL()
  • RegimeOK()
  • EvaluateSignal()
  • ConfirmOK()
  • CountOurPositions()
  • CountOurPositionsByType()
  • CalcLotForATRStop()
  • NormalizeLot()
  • TryEntry()
  • TryPyramid()
  • ManageTrades()
  • ...and 8 more

INTERNAL CONSTANTS (30 total):

  • DEF_FRACTAL_BARS = 5 // Bars inspected for last confirmed fractal
  • DEF_TREND_MA_PERIOD = 50 // Trend filter EMA period (matches source thesis)
  • DEF_BB_PERIOD = 20 // BB period
  • DEF_BB_DEVIATION = 2.0 // BB deviation
  • 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_VOL_MIN_RATIO = 0.8 // Min vol vs rolling-MA ratio
  • 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
  • ...and 15 more

INPUT PARAMETERS (18 total across 7 groups):

  • [=== Identity ===] InpMagic = 22210005 // Magic number
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_10005" // Trade comment
  • [=== Identity ===] InpDryRun = true // Dry-run (no live sends)
  • [=== Identity ===] InpKillSwitch = false // Kill switch (closes-all on tick)
  • [=== Risk & Sizing ===] InpRiskPercent = 0.5 // Risk per trade (% of effective capital)
  • [=== Risk & Sizing ===] InpFixedLot = 0.01 // Fixed lot fallback (used when Risk%<=0)
  • [=== Risk & Sizing ===] InpDailyLossLimitPercent = 3.0 // Daily loss limit (% of effective capital)
  • [=== Risk & Sizing ===] InpWeeklyLossLimitPercent = 6.0 // Weekly loss limit (% of effective capital)
  • [=== Risk & Sizing ===] InpMaxConcurrent = 3 // 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 (Fractal Breakout + EMA) ===] InpRequireFractalBreak = true // Require fractal breakout confirmation
  • [=== Signal (Fractal Breakout + EMA) ===] InpMinBodyATR = 0.25 // Min breakout-body size (x ATR)
  • [=== Regime / Confirm ===] InpMinADX = 18.0 // Minimum ADX main (trend strength)
  • [=== Regime / Confirm ===] InpMinRR = 1.5 // Minimum reward:risk for entry
  • [=== Exit / Manage ===] InpATRPeriod = 14 // ATR period (SL/trail)
  • [=== Exit / Manage ===] InpATRMultiplier = 2.0 // ATR SL multiplier
  • [=== Scaling (Pyramid) ===] InpEnablePyramid = false // Enable pyramiding (default OFF)
Pseudocode
// Pipsgrowth EX10005 Momentum-Scalper — Execution Flow (from source analysis)
// Family: Momentum-Scalper
// Fractal breakout scalp — close breaks the most recent confirmed UP/DOWN fractal in the direction of price vs EMA(50)

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
InpMagic22210005Magic number
InpTradeComment"Psgrowth.com Expert_10005"Trade comment
InpDryRuntrueDry-run (no live sends)
InpKillSwitchfalseKill switch (closes-all on tick)
InpRiskPercent0.5Risk per trade (% of effective capital)
InpFixedLot0.01Fixed lot fallback (used when Risk%<=0)
InpDailyLossLimitPercent3.0Daily loss limit (% of effective capital)
InpWeeklyLossLimitPercent6.0Weekly loss limit (% of effective capital)
InpMaxConcurrent3Max concurrent positions (this EA+symbol)
InpCapitalCapAmount0.0Capital cap amount ($ REAL MONEY equity)
InpCapitalCapFloor50.0Floor below which new entries are blocked ($)
InpRequireFractalBreaktrueRequire fractal breakout confirmation
InpMinBodyATR0.25Min breakout-body size (x ATR)
InpMinADX18.0Minimum ADX main (trend strength)
InpMinRR1.5Minimum reward:risk for entry
InpATRPeriod14ATR period (SL/trail)
InpATRMultiplier2.0ATR SL multiplier
InpEnablePyramidfalseEnable pyramiding (default OFF)
Source Code (.mq5)Open Source
Pipsgrowth_com_EX10005.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX10005 Scalper XAUUSD 5M — fractal breakout momentum scalper, full 12-layer stack."

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

//--- Non-operator tunables (kept as #define to keep input count <= 22) ---//
#define DEF_FRACTAL_BARS         5          // Bars inspected for last confirmed fractal
#define DEF_TREND_MA_PERIOD      50         // Trend filter EMA period (matches source thesis)
#define DEF_BB_PERIOD            20         // BB period
#define DEF_BB_DEVIATION         2.0        // BB deviation
#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_VOL_MIN_RATIO        0.8        // Min vol vs rolling-MA ratio
#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_MAX_SYMBOL_EXPOSURE  3          // Max positions per symbol (this EA)

//--- Input Groups --------------------------------------------------//
input group "=== Identity ==="
input long               InpMagic           = 22210005;                            // Magic number
input string             InpTradeComment    = "Psgrowth.com Expert_10005";  // Trade comment
input bool               InpDryRun          = true;                               // Dry-run (no live sends)
input bool               InpKillSwitch      = false;                              // Kill switch (closes-all on tick)

input group "=== Risk & Sizing ==="
input double             InpRiskPercent     = 0.5;        // Risk per trade (% of effective capital)
input double             InpFixedLot        = 0.01;       // Fixed lot fallback (used when Risk%<=0)
input double             InpDailyLossLimitPercent  = 3.0;  // Daily loss limit (% of effective capital)
input double             InpWeeklyLossLimitPercent = 6.0;  // Weekly loss limit (% of effective capital)
input int                InpMaxConcurrent   = 3;          // Max concurrent positions (this EA+symbol)

input group "=== Capital Allocation Cap ==="
// InpCapitalCapEnabled removed — use InpCapitalCapAmount=0 to disable     // Enable capital-allocation cap
input double             InpCapitalCapAmount  = 0.0;    // Capital cap amount ($ REAL MONEY equity)

Full source code available on download

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

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