P
PipsGrowth
ScalpingOpen Source – Free

Pipsgrowth EX10011 Momentum-Scalper

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

Pipsgrowth.com EX10011 ic_gold MomentumScalper — 6-vote momentum consensus scalper, full 12-layer stack.

Overview

Pipsgrowth EX10011 is a closed-bar momentum-scalper that fires trades only when at least four of six independent momentum voters agree on direction and a five-state regime classifier gives the green light. The six voters are computed inline from raw price data on the last closed bar (shift=1): a fast Hull moving average of period 21 against a slow Hull of period 55 (sloping up = long vote), an EMA-ribbon alignment check across periods 8/21/50 (all stacked in the trade direction), a Heikin-Ashi candle colour built from the OHLC of bars 1 and 2 (green = long vote), a MACD histogram direction on the (12,26,9) classic pair (main minus signal expanding in the trade direction), an RSI(14) side check that defaults to RSI ≥ 55 for long votes and RSI ≤ 45 for short votes (the asymmetric 55/45 split is what makes the EA prefer trades with confirmed trend bias rather than neutral-momentum setups), and a Bollinger Band squeeze-breakout check using the (20, 2.0) bands on close — a long vote when the current bar's band width is at least 1.4× the minimum width of the prior 100 bars, indicating that price has just broken out of a compression. Each voter adds one tally; the result is a confidence score in 0–100 (votes / 6 * 100) and the entry fires only when votes >= InpMinVotes (default 4). The default threshold of four means the EA needs roughly two-thirds of its voters to align before risking capital, so a single noisy indicator cannot drive a position on its own.

The five-state regime classifier runs every tick and is independent of the signal stack. It reads the same three handles — ADX(14), ATR(14), and Bollinger Bands(20, 2.0) — and walks a 100-bar lookback to compute two percentile features: where the current ATR sits in its own recent range, and where the current Bollinger width sits in its own recent range. StrongTrend is the state where ADX ≥ 28 and the ATR percentile is at or above the 70th percentile; WeakTrend covers the ADX-≥-20 band without the high-ATR confirmation; Range is the compressed state when Bollinger width is in the bottom 30% of its own distribution; Breakout fires only when both the ATR and the Bollinger width percentiles are at or above 85%; and everything else lands in Choppy. The classifier blocks entries in Choppy and Range, allows them in WeakTrend, StrongTrend, and Breakout, and uses the live state to force-close positions the moment it rolls back into Choppy or Range. That asymmetry — letting the regime deteriorate open positions even when the signal is still valid — is the EA's built-in defence against a momentum setup quietly running into chop.

The HTF confirmation layer reads a single EMA(50) on a higher timeframe (default M15) and refuses to fire a long unless price is on or above the line, and a short unless price is on or below it. The default InpRequireHTF = true means that, out of the box, the EA will not chase a long when the higher timeframe trend is clearly down. Spread is gated twice — once in ConfirmFilters and once in NoTradeGate — at InpMaxSpreadPts of 30 points, which is intentionally tight for an XAUUSD scalper and pushes the operator towards a low-spread ECN or RAW broker. The R:R floor at InpMinRR of 1.2 is checked against the projected SL/TP distance, so any setup whose implied reward-to-risk would fall below 1.2 is rejected before PlaceEntry is reached. Risk is sized at InpRiskPercent of 0.5% of effective capital per trade, the lowest of the Momentum-Scalper family, with EffectiveCapital() returning min(InpCapitalCapAmount, equity) when a capital cap is set and raw equity otherwise. The 0.01 fixed-lot fallback never appears in the code — InpAutoLot is true by default and risk sizing is the only path. A capital-floor of $50 (InpCapitalCapFloor) blocks entries below that equity threshold.

Position management is a three-stage cascade that runs on every tick through ManageOpenPositions. When unrealised profit reaches 1.0R (where R is the initial ATR-anchored stop distance), the stop is ratcheted to entry + 1 point for longs (mirror for shorts) — a one-shot break-even that the function will not repeat on the same ticket. At the same 1.0R threshold, but only if remaining volume is greater than 1.9× the broker's minimum lot, half the position is closed via TryClosePartial_EX10011 and the comment tag becomes the EA's standard trade comment. After that, an ATR trailing stop at InpATRMulTrail of 2.0× ATR(14) tightens the stop every tick in the favourable direction, gated by the broker's SYMBOL_TRADE_STOPS_LEVEL so the broker never rejects a stop move for minimum-distance violation. Exits other than the cascade are: an opposite-momentum signal (the same 6-vote check, evaluated for the trade's opposite direction, on a closed bar), the regime-collapse force-close into Choppy or Range, a maximum-hold of 240 bars (four hours on M1, twenty hours on M5, sixty hours on M15), and the live no-trade gate for daily/weekly loss caps and the cooldown timer.

The no-trade gate is a stack of independent checks, all of which must pass for PlaceEntry to be reached: kill switch off, session open (London 8–12 server, New York 13–17 server, weekends closed, Fridays at or after 18:00 closed), trades-today under InpMaxTradesPerDay of 10, no active 60-minute cooldown after three consecutive losing closes, equity above the $50 floor, daily realised PnL not more negative than 3% of effective capital, weekly realised PnL not more negative than 9% of effective capital, regime not in Choppy or Range, spread at or under 30 points, and the symbol's SYMBOL_TRADE_MODE allowing trades. Daily and weekly realised PnL are walked directly from the deal history filtered by magic number, so the counters are accurate even after a terminal restart. The session window of 4h London plus 4h New York with the weekend and Friday-evening blocks is a deliberately conservative frame — the EA expects to find both flow and tight spreads in those eight hours, and the rest of the trading day is reserved for management of positions opened during the window.

InpDryRun ships as true, which means that on a fresh install every entry and every exit is logged but no order is sent to the broker — the operator must explicitly flip the flag to false before any live trade fires. InpKillSwitch is false by default and acts as a panic-button: when toggled to true the next OnTick call forces NoTradeGate to return true, the no-trade code path then exits, and any open position is closed by ManageOpenPositions on the same tick. Sends are hardened with a single retry on TRADE_RETCODE_REQUOTE, TRADE_RETCODE_PRICE_CHANGED, and TRADE_RETCODE_TIMEOUT after a fresh sym.RefreshRates(). Closes and partial closes are retried up to three times at 200ms intervals on the same four transient retcodes, and modifies are retried up to three times at 100ms intervals on requote and timeout. The filling mode is auto-picked from SYMBOL_FILLING_MODE in FOK > IOC > RETURN order, with the chosen mode then written via trade.SetTypeFillingBySymbol(_Symbol) to make the CTrade object aware of the choice. Slippage is hard-coded at DEV_POINTS of 20 for the trade object and ULONG_MAX for the closing helpers (the helper falls back to the symbol's default deviation). The OnTester custom criterion is (net * PF) / (1 + balance_dd) with a 30-trade hard floor and a dd <= 0 guard, which means the optimiser ranks parameter sets by composite quality rather than raw net profit, and zero-drawdown runs are penalised to discourage curve-fitted flatlines.

The single most consequential input is InpMinVotes. Tightening it to 5 produces a low-frequency, high-conviction run; loosening it to 3 produces a higher trade count with weaker consensus. InpRSILevel is the asymmetric tuning knob: 55 (the default) biases entries towards the higher-RSI side of momentum confirmation, lowering it to 50 produces more symmetric long/short behaviour, raising it to 60 reduces long entries to only the strongest RSI readings. InpRequireHTF is the safety switch — when set to false the EA will fire in both directions regardless of the higher timeframe, and that mode is only sensible for traders who actively want counter-trend scalps. InpMaxOpenTrades defaults to 1, which means the EA never pyramids and never hedges — a second entry attempt on the same symbol is blocked at the position-count check, not by the signal. InpATRMulTP of 2.5 vs InpATRMulSL of 1.5 produces a default TP:SL of 1.67:1, comfortably above the 1.2 R:R floor in InpMinRR, and the 2.0× ATR trailing multiplier in InpATRMulTrail is what converts the partial-close stage into a longer-run trade without giving back the early profit.

When backtesting, expect the EA to behave like a momentum-then-manage system: a small number of high-conviction entries during the eight server-hour trading window, a 50% partial close at 1.0R on the majority of winners, and the trailing stop doing most of the work on the remainder. The 240-bar max-hold exit means that on the M1 chart a trade cannot sit for more than four hours; on the M5 chart, twenty hours; on the M15 chart, sixty hours. The deal-history-walked daily and weekly loss caps mean that the optimiser will see real drawdown gating, not phantom blocking, and the 30-trade OnTester floor combined with the dd <= 0 guard means a parameter set with fewer than 30 trades or zero drawdown scores exactly 0. The strategy is rated HIGH risk in the corpus because the 0.5% per-trade risk, the 3% daily cap, the 9% weekly cap, and the 1.67:1 R:R still allow significant account-level drawdown on a streak of failed momentum breaks, especially on a broker that widens spreads during the news windows the EA does not explicitly block.

Strategy Deep Dive

On every tick, OnTick refreshes the symbol, runs TrackLossStreakAndRealized to walk the deal history filtered by magic and update daily/weekly PnL counters plus the consecutive-loss counter that arms the 60-minute cooldown after three losses, then calls RegimeGate(0) so the global G_REGIME is current, then runs ManageOpenPositions to handle the per-tick exit cascade on any open ticket, and finally — only on a fresh bar — runs NoTradeGate, EntrySignal, and ConfirmFilters before PlaceEntry. The signal engine computes the six voters inline on the last closed bar: Hull-MA fast and slow are built from the HMA(price, N) = LWMA(2*LWMA(price, N/2) - LWMA(price, N), sqrt(N)) formula on clsArr, Heikin-Ashi is built from raw OHLC on bars 1 and 2, EMA ribbon alignment uses iMA handles for periods 8/21/50, MACD histogram direction uses iMACD(12,26,9) on PRICE_CLOSE, RSI(14) side uses iRSI with the InpRSILevel threshold, and the Bollinger squeeze-breakout compares the current band width against the minimum of the last 100 bars with a 1.4× expansion requirement. A long fires only when at least InpMinVotes of those six voters align with the candidate side, then ConfirmFilters demands price be on the correct side of the M15 EMA(50) HTF, the projected TP:SL clear 1.2, and the spread be at or under 30 points. Sizing is risk-percent based on 0.5% of effective capital; trade objects use a single retry on requote/price-changed/timeout, and closing helpers retry up to three times on the same four transient retcodes. InpDryRun ships true so the EA logs every intended order without sending it, and InpKillSwitch arms a panic-button that flattens all open positions on the next tick.

Entry Signal

Entries are gated by a six-vote momentum consensus evaluated on the last closed bar (shift=1): inline Hull-MA(21/55) slope, EMA(8/21/50) ribbon alignment, inline Heikin-Ashi colour, MACD(12,26,9) histogram direction, RSI(14) side at the asymmetric InpRSILevel default of 55, and a Bollinger(20,2.0) squeeze-breakout requiring current width ≥ 1.4× the 100-bar minimum. The signal fires only when at least InpMinVotes (default 4) of those six voters align with the candidate side, then ConfirmFilters requires the price to be on the correct side of the M15 EMA(50) HTF, the projected R:R to clear InpMinRR=1.2, and the spread to be at or under InpMaxSpreadPts=30.

Exit Signal

Three exit paths run in parallel. The momentum-vote stack evaluates the same six voters for the trade's opposite direction on each new closed bar; if the opposite side clears InpMinVotes, TryClose_EX10011 closes the position with up to three retries at 200ms on requote/timeout/price-off/price-changed. The regime classifier force-closes any open position the moment G_REGIME rolls back into Choppy (0) or Range (1). The hard time exit fires at MAX_HOLD_BARS of 240 bars (4h on M1, 20h on M5, 60h on M15), calculated from open time and current bar-0 timestamp.

Stop Loss

Initial stop is ATR(14) × InpATRMulSL (default 1.5) from the entry price, with a hard floor at the broker's SYMBOL_TRADE_STOPS_LEVEL inside PlaceEntry. Position sizing uses 0.5% of effective capital per trade via EffectiveCapital(), and a 3% daily / 9% weekly loss cap is enforced by walking the deal history filtered by magic number. There is no global account-level stop — the per-trade SL plus the loss caps form the only downside containment.

Take Profit

Initial take-profit is ATR(14) × InpATRMulTP (default 2.5), giving a 1.67:1 TP:SL ratio that comfortably clears the InpMinRR=1.2 floor. At 1.0R of profit, half the position is closed via TryClosePartial_EX10011 (gated by remaining volume > 1.9 × LotsMin) and the stop is moved to entry + 1 point for break-even; the remainder is then governed by an ATR(14) × InpATRMulTrail (default 2.0) trailing stop that ratchets only in the favourable direction.

Best For

Designed for XAUUSD on M1 (works M1 through M15 per the file header) with an ECN or RAW-spread broker that can keep XAUUSD spread at or under 30 points during the four London hours (8-12 server) and four New York hours (13-17 server) — Asia is excluded by the SessionOK check. Minimum recommended balance: $100 with the capital-cap floor at $50, but the 0.5% per-trade risk translates to a usable 0.01-0.02 lot only on $500+ where the 3% daily and 9% weekly loss caps have room to absorb a normal losing streak. Run on a VPS colocated with the broker so the 1.67:1 TP:SL plus the 2.0× ATR trailing stop can clear spread costs on every fill, flip InpDryRun from true to false before any live order, and use InpKillSwitch as a panic-button to flatten and halt the EA on the next tick.

Strategy Logic

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

Family: Momentum-Scalper Magic: 22210011 Version: 2.00

BRIEF: Multi-indicator momentum-scalping consensus. A trade is taken only when a closed-bar momentum vote (inline Hull-MA slope, EMA-ribbon alignment, Heikin-Ashi color, MACD-hist direction, RSI side, BB-squeeze breakout) agrees with regime + HTF + R/R + session/spread/no-trade gates. Capital-allocation- cap governs all risk math. Exits: ATR trail, BE-at-R, partial TP1, opposite momentum exit, regime-change exit. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • EffectiveCapital()
  • RegimeGate()
  • MomentumVote()
  • ConfirmFilters()
  • NoTradeGate()
  • RiskOK()
  • PlaceEntry()
  • ManageOpenPositions()
  • NormalizePrice()
  • NormalizeVolume()
  • StopsLevelPrice()
  • SessionOK()
  • ...and 12 more

INTERNAL CONSTANTS (1 total):

  • COOLDOWN_MIN = 60 // ==================== INPUTS (18 total) =============================

INPUT PARAMETERS (22 total across 7 groups):

  • [=== Identity ===] InpMagic = 22210011 // Magic number
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_10011" // Trade comment
  • [=== Identity ===] InpTimeframe = 1 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Signal timeframe
  • [=== Identity ===] InpHTF = 6 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // HTF trend timeframe
  • [=== Risk & Sizing ===] InpRiskPercent = 0.5 // Risk % per trade of effective cap
  • [=== Risk & Sizing ===] InpDailyLossLimitPct = 3.0 // Daily loss limit % of effective cap
  • [=== Risk & Sizing ===] InpWeeklyLossLimitPct = 9.0 // Weekly loss limit % of effective cap
  • [=== Risk & Sizing ===] InpMaxOpenTrades = 1 // Max concurrent trades (this EA/symbol)
  • [=== Risk & Sizing ===] InpMaxTradesPerDay = 10 // Max new entries per day
  • [=== Risk & Sizing ===] InpAutoLot = true // Use auto lot (false=fixed)
  • [=== Capital Cap ===] InpCapitalCapAmount = 0.0 // Capital cap amount ($ equity)
  • [=== Capital Cap ===] InpCapitalCapFloor = 50.0 // Floor below which no new entries ($)
  • [=== Signal ===] InpMinVotes = 4 // Min momentum votes (of 6) to fire
  • [=== Signal ===] InpRSILevel = 55.0 // RSI long side level (0-100)
  • [=== Regime / Confirm ===] InpRequireHTF = true // Require HTF trend agreement
  • [=== Regime / Confirm ===] InpMinRR = 1.2 // Min reward:risk ratio
  • [=== Regime / Confirm ===] InpMaxSpreadPts = 30.0 // Max spread (points)
  • [=== Exit / Manage ===] InpATRMulSL = 1.5 // ATR SL multiplier
  • [=== Exit / Manage ===] InpATRMulTP = 2.5 // ATR TP multiplier
  • [=== Exit / Manage ===] InpATRMulTrail = 2.0 // ATR trailing multiplier
  • [=== Operational ===] InpDryRun = true // Dry-run (no live sends)
  • [=== Operational ===] InpKillSwitch = false // Kill switch (flatten + stop)
Pseudocode
// Pipsgrowth EX10011 Momentum-Scalper — Execution Flow (from source analysis)
// Family: Momentum-Scalper
// Multi-indicator momentum-scalping consensus. A trade is taken only when a closed-bar momentum vote (inline Hull-MA slope, EMA-ribbon alignment, Heikin-Ashi color, MACD-hist direction, RSI side, BB-squeeze breakout) agrees with regime + HTF + R/R + session/spread/no-trade gates. Capital-allocation- cap governs all risk math. Exits: ATR trail, BE-at-R, partial TP1, opposite momentum exit, regime-change exit. 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:
M1M15

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
InpMagic22210011Magic number
InpTradeComment"Psgrowth.com Expert_10011"Trade comment
InpTimeframe1Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Signal timeframe
InpHTF6Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // HTF trend timeframe
InpRiskPercent0.5Risk % per trade of effective cap
InpDailyLossLimitPct3.0Daily loss limit % of effective cap
InpWeeklyLossLimitPct9.0Weekly loss limit % of effective cap
InpMaxOpenTrades1Max concurrent trades (this EA/symbol)
InpMaxTradesPerDay10Max new entries per day
InpAutoLottrueUse auto lot (false=fixed)
InpCapitalCapAmount0.0Capital cap amount ($ equity)
InpCapitalCapFloor50.0Floor below which no new entries ($)
InpMinVotes4Min momentum votes (of 6) to fire
InpRSILevel55.0RSI long side level (0-100)
InpRequireHTFtrueRequire HTF trend agreement
InpMinRR1.2Min reward:risk ratio
InpMaxSpreadPts30.0Max spread (points)
InpATRMulSL1.5ATR SL multiplier
InpATRMulTP2.5ATR TP multiplier
InpATRMulTrail2.0ATR trailing multiplier
InpDryRuntrueDry-run (no live sends)
InpKillSwitchfalseKill switch (flatten + stop)
Source Code (.mq5)Open Source
Pipsgrowth_com_EX10011.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX10011 ic_gold MomentumScalper — 6-vote momentum consensus 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>

//==================== TUNABLE CONSTANTS (NOT inputs) ================
#define ATR_PERIOD          14
#define BB_PERIOD           20
#define BB_DEVIATION        2.0
#define RSI_PERIOD          14
#define MACD_FAST           12
#define MACD_SLOW           26
#define MACD_SIGNAL         9
#define EMA_FAST            8
#define EMA_MID             21
#define EMA_SLOW            50
#define HULL_FAST           21
#define HULL_SLOW           55
#define HTF_EMA_PERIOD      50
#define HTF_TIMEFRAME       PERIOD_M15
#define ATRPCT_LOOKBACK     100
#define BBW_LOOKBACK        100
#define ADX_PERIOD          14
#define ADX_STRONG          28.0
#define ADX_WEAK            20.0
#define ATRPCT_STRONG       0.70
#define BBW_COMPRESS_K      0.70
#define SESSION_LDN_START   8
#define SESSION_LDN_END     12
#define SESSION_NY_START    13
#define SESSION_NY_END      17
#define MAX_HOLD_BARS       240
#define BE_TRIGGER_R        1.0
#define PARTIAL_TP1_R       1.0
#define PARTIAL_PCT         50
#define SPREAD_ROLL_LOOKBACK 60
#define DEV_POINTS          20
#define COOLDOWN_LOSSES     3
#define COOLDOWN_MIN        60

//==================== INPUTS (18 total) =============================
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;

Full source code available on download

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

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