P
PipsGrowth
ScalpingOpen Source – Free

Pipsgrowth EX10003 Momentum-Scalper

MT5 Expert Advisor (Open Source) · XAUUSD · M5

Pipsgrowth.com EX10003 LSTMRisk XAUUSD 5M — LSTM-risk momentum confluence scalper, full 12-layer stack.

Overview

Pipsgrowth EX10003 Momentum-Scalper brands itself as an 'LSTM-risk' model, but the source is honest about a constraint: a real long short term memory network cannot be inlined into pure MQL5. What you actually get is a 5-vote momentum confluence that mimics what an LSTM directional classifier would output, namely a +1, -1, or 0 call on the last closed bar packaged with a 0-100 confidence score. For a trader evaluating the EA, that distinction matters because the bot is a momentum scalper, not a deep learning model, but the practical effect is the same: a single position is opened only when at least four of five independent momentum signals agree on direction, and that direction must also match the higher timeframe trend.

The five voters are evaluated on the bar at shift=1, so no current bar repaint is possible. The first voter is the EMA stack: EMA(8) on the signal timeframe above EMA(21) votes long, below votes short. The second is a momentum burst check: a bar whose body is larger than 0.4 * ATR(14) counts as a burst, and a bullish burst adds a buy vote while a bearish burst adds a sell vote. The third is MACD(12,26,9) histogram sign. The fourth is RSI(14) above 50 for buys and below 50 for sells. The fifth is an inline Hull MA(21) slope, computed by hand from WMA primitives inside the HullMA() function rather than via iMA, so the smoothing kernel does not depend on the indicator being available. The Hull calculation returns false on bad data rather than silently emitting a zero.

A direction is set only when one side leads by at least two votes. A 3-2 split returns 0 and no signal fires. With the default InpVoteMin of 4 out of 5, the confidence floor is 80 percent, which means a 4-1 vote clears the bar but a 3-2 split never produces a direction at all. The practical effect is that EX10003 trades only on unusually strong bar-1 agreement. Most bars do not produce a trade, which is a deliberate conservatism rather than a bug.

The confirmation layer then checks two things. First, the higher timeframe EMA(50) must agree with the direction, meaning the close at shift=1 must be above the HTF EMA for a long and below for a short. The default InpHtfTimeframe of 8 falls through the case statement to PERIOD_H1, and InpSignalTf of 0 also falls through to H1, so out of the box both default to H1. On a gold M5 chart, that means the user is effectively running a 1-hour signal with a 1-hour trend filter, not a 5-minute signal with a 1-hour filter. Changing InpSignalTf to 2 (M5) is the realistic way to use the EA on the M5 chart it is named for. Second, the implied reward to risk must clear InpMinRR of 1.2, which acts as a sanity check on the SL/TP math rather than a strategy filter.

Risk and sizing are tight by design. SL is placed at 1.8 * ATR(14) from entry and TP at 3.0 * ATR(14), so the default R:R is approximately 1.67. Lot size is fixed fractional at 0.5 percent of effective capital with a 0.01 fixed lot fallback if the risk calculation yields zero. Effective capital is the smaller of account equity and InpCapAmount (which defaults to 0 and disables the cap), plus the day's realized PnL for this magic. Daily loss limit is 3 percent and weekly is 6 percent, both computed against the same effective capital number. There is no martingale, no grid, and no pyramid; PYRAMID_MAX and PYRAMID_ATR_STEP are defined as constants but never referenced in the live code.

The regime classifier ClassifyRegime() returns one of seven states, namely StrongTrend, WeakTrend, Range, Breakout, Compress, Expand, and Choppy, based on ADX(14) at the 20 threshold, a 100-bar ATR-percentile, and Bollinger Band width. Despite being advertised as a 12-layer architecture in the header, the regime class does not actually filter entries in EX10003. The only regime checks in the entry path are a volatility floor (InpAtrPctMin of 0.10) and a hard reject on Choppy. The classifier does, however, force a position close if it transitions to Choppy on a live trade.

In-trade management runs on every tick. Three features are enabled by default. Break even moves SL to 5 points past entry once the trade reaches +1R. A 50 percent partial close fires at +1.5R, but only if the remaining volume would still be at least 1.5 times the broker's minimum lot, a small detail that prevents the partial from being rejected on micro accounts. An ATR(14) trail at 2.5x ATR, with a 100-point ratchet step, tightens SL behind price as the trade moves. Beyond those, an opposite signal close fires if the 5-vote momentum signal flips direction on a new bar, a 240-bar (about 20 hours on M5) max hold exit closes any stale position, and the Choppy regime close fires as already described.

A practical detail that matters before any live run: InpDryRun is true by default. Out of the box the EA will print what it would do and not place an order. Setting InpDryRun to false and leaving InpKillSwitch at false is required before any live trading. The InpMaxSpreadPts default of 350 is generous at roughly 35 pips on a gold symbol, which matches the volatility profile of XAUUSD on M5 and the reality that gold spread can spike into the high 20s around the New York open and the London fix. The session window of 7 to 21 in the CanTrade() gate is the London plus New York window with Asia explicitly excluded, and the weekend filter blocks Sunday and Saturday.

The source has a few non functional curiosities worth flagging. The MapTimeframeInt function is defined seven times in the file, identically, a sloppy copy paste that compiles and runs correctly but adds visual noise. NEWS_BLOCK_MINS is defined as 30 but the constant is never read anywhere in the file, so the EA has no news filter despite the constant's name. The MapTimeframeInt(0) and MapTimeframeInt(8) fall through to H1 is an additional quirk: the user must explicitly map the inputs to a value in 1 to 7 or the EA silently runs H1 logic on an M5 chart.

For a backtest, expect a moderate trade count, a low to moderate win rate, and most winners coming from the partial plus trail combination rather than from a full TP hit. The 80 percent confidence floor on entries means trade frequency will be lower than a typical scalper. The HTF EMA filter eliminates most counter trend attempts. The 3 percent daily loss cap halts the EA early on bad days, which is good for capital preservation but means the equity curve will have visible dead days. The Strategy Tester fitness function OnTester returns net*pf/(1+dd) with a 30-trade minimum, so the optimizer rewards high profit factor and penalizes drawdown rather than rewarding raw net profit alone.

In live use, a sub-100-millisecond ECN broker with raw spread on XAUUSD is the realistic minimum. Below $1,000 the partial+trail logic will frequently round the remaining lot to the broker minimum and the BE step of 5 points will often be eaten by spread on a 5-digit gold quote, so the EA tends to work best on accounts that can support a 0.10 lot without exceeding the 0.5 percent risk. Above the 0.5 percent risk, the ATR-driven stops will already be wide enough to absorb a single bad tick during NY open volatility, which is the most common loss scenario in the backtest.

Strategy Deep Dive

Five momentum voters score the bar at shift=1, and only a 4-1 or 5-0 split that also leads by two votes sets a direction. The seven state regime classifier runs the same bar but only its Choppy output blocks entries; its other states are logged but not used to gate signals. OpenPos() always prints the lot, SL, and TP through a dry-run path first, because InpDryRun ships as true. After the entry, ManagePositions() is the only live code path that touches the position: it moves SL to break even at +1R, fires a 50 percent partial at +1.5R, and then trails at 2.5x ATR(14) with a 100-point ratchet step. OnTester() returns net*pf/(1+dd) with a 30-trade floor, so optimizer runs reward low-drawdown setups over raw net profit. The single position cap from InpMaxConcurrent plus the 3 percent daily loss gate and the 350-point spread cap form the live safety stack, and the InpHtfTimeframe plus InpSignalTf inputs both fall through to H1 by default unless the user explicitly sets them to 1-7.

Entry Signal

A direction fires when at least 4 of 5 momentum voters agree on bar-1 with a 2-vote margin (so a 3-2 split never sets a direction), then the close at shift=1 must sit on the correct side of the HTF EMA(50) and the implied R:R must clear the 1.2 minimum before OpenPos() fires. Entries only run on a fresh bar and only when effective ATR-percentile is at or above InpAtrPctMin of 0.10, the kill switch is off, the spread is under InpMaxSpreadPts of 350, and the hour is between 7 and 21 excluding weekends.

Exit Signal

The ManagePositions() loop checks every open position on every tick: a 5-vote opposite-signal close, a Choppy-regime close from ClassifyRegime(), a 240-bar (about 20 hours on M5) max-hold time stop, a +1R break-even at +5 points, a 50 percent partial close at +1.5R (only if the residual volume is at least 1.5x the broker min lot), and an ATR(14) trail at 2.5x with a 100-point ratchet step. If none of those trigger, the original SL at 1.8x ATR(14) and TP at 3.0x ATR(14) close the trade.

Stop Loss

Stop-loss is computed at InpAtrSlMult of 1.8 times ATR(14) from the entry price and is then floored by the symbol's StopsLevel distance inside RespectStops(). The default risk per trade is 0.5 percent of effective capital via CalcLot(), with a 0.01 fixed-lot fallback, and a hard 3 percent daily loss / 6 percent weekly loss gate inside CanTrade() blocks any further entries once the day's realized PnL for this magic breaches the limit.

Take Profit

Take-profit is set at InpAtrTpMult of 3.0 times ATR(14) from the entry, which gives a default R:R of roughly 1.67. The 1.2 InpMinRR check in ConfirmEntry() rejects any setup where the ATR-derived TP would produce a worse ratio. In trade, the 50 percent partial at +1.5R typically closes well before the full TP is reached, and the remainder is left to the ATR trail.

Best For

Suits a trader who runs XAUUSD on the M5 chart and is present during the London and New York windows (7 to 21 server time, Asia excluded). Minimum recommended balance: 100 USD at the 0.5 percent risk default, with a raw-spread ECN broker that can keep XAUUSD spread under 30 points during NY open. Because InpDryRun ships true and InpSignalTf defaults to H1, only enable the EA after setting InpDryRun to false, InpSignalTf to 2 (M5), and InpHtfTimeframe to 5 (H1) explicitly.

Strategy Logic

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

Family: Momentum-Scalper Magic: 22210003 Version: 2.00

BRIEF: ML/LSTM-predicted directional risk model with EMA-trend context and momentum burst entry. ML cannot be inlined in pure MQL5, so the LSTM signal is replaced with a native multi- indicator momentum confluence (EMA-stack side + MACD-hist flip + RSI side + body-vs-ATR burst + inline Hull-MA slope) on the last CLOSED bar, returning +1/-1/0 with a 0..100 confidence. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • HullMA()
  • NormPrice()
  • NormLot()
  • RespectStops()
  • BufVal()
  • EffectiveCapital()
  • RegimeStr()
  • MomentumSignal()
  • ConfirmEntry()
  • CanTrade()
  • CalcLot()
  • MarginOK()
  • ...and 6 more

INTERNAL CONSTANTS (1 total):

  • VOTE_TOTAL = 5 // ================= GLOBALS =================

INPUT PARAMETERS (24 total across 7 groups):

  • [=== Identity ===] InpMagic = 22210003 // Magic number (unique per EA)
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_10003" // Trade comment
  • [=== Identity ===] InpHtfTimeframe = 8 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // HTF trend timeframe
  • [=== Identity ===] InpSignalTf = 0 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Signal timeframe (default chart)
  • [=== Risk & Sizing ===] InpRiskPercent = 0.5 // Risk per trade (% of effective capital)
  • [=== Risk & Sizing ===] InpFixedLot = 0.01 // Fallback fixed lot if risk=0 (lots)
  • [=== Risk & Sizing ===] InpDailyLossPct = 3.0 // Daily loss limit (% of effective capital)
  • [=== Risk & Sizing ===] InpWeeklyLossPct = 6.0 // Weekly loss limit (% of effective capital)
  • [=== Risk & Sizing ===] InpAtrSlMult = 1.8 // ATR multiplier for stop-loss (x)
  • [=== Risk & Sizing ===] InpAtrTpMult = 3.0 // ATR multiplier for take-profit (x)
  • [=== Risk & Sizing ===] InpMinRR = 1.2 // Minimum reward:risk ratio (x)
  • [=== Capital Cap (mandatory) ===] InpCapAmount = 0.0 // Real-money equity cap ($)
  • [=== Capital Cap (mandatory) ===] InpCapFloor = 50.0 // Block new trades if effective < floor ($)
  • [=== Signal / Confirm ===] InpVoteMin = 4 // Min votes (of 5) to fire (>=3)
  • [=== Signal / Confirm ===] InpHtfEmaPeriod = 50 // HTF EMA period for trend confirm
  • [=== Regime ===] InpAdxMin = 20 // Min ADX for trend regime (>=0)
  • [=== Regime ===] InpAtrPctMin = 0.10 // Min ATR% (ATR/price*100) for adequate vol
  • [=== Exit / Manage ===] InpEnableBE = true // Move to break-even at +1R
  • [=== Exit / Manage ===] InpEnablePartial = true // Take 50% partial at +1.5R
  • [=== Exit / Manage ===] InpEnableTrail = true // Enable ATR trailing stop
  • [=== Safety ===] InpDryRun = true // Dry-run (no live orders)
  • [=== Safety ===] InpKillSwitch = false // Master kill switch
  • [=== Safety ===] InpMaxSpreadPts = 350 // Max spread (points) for entry
  • [=== Safety ===] InpMaxConcurrent = 1 // Max concurrent positions (this magic)
Pseudocode
// Pipsgrowth EX10003 Momentum-Scalper — Execution Flow (from source analysis)
// Family: Momentum-Scalper
// ML/LSTM-predicted directional risk model with EMA-trend context and momentum burst entry. ML cannot be inlined in pure MQL5, so the LSTM signal is replaced with a native multi- indicator momentum confluence (EMA-stack side + MACD-hist flip + RSI side + body-vs-ATR burst + inline Hull-MA slope) on the last CLOSED bar, returning +1/-1/0 with a 0..100 confidence. 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
InpMagic22210003Magic number (unique per EA)
InpTradeComment"Psgrowth.com Expert_10003"Trade comment
InpHtfTimeframe8Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // HTF trend timeframe
InpSignalTf0Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Signal timeframe (default chart)
InpRiskPercent0.5Risk per trade (% of effective capital)
InpFixedLot0.01Fallback fixed lot if risk=0 (lots)
InpDailyLossPct3.0Daily loss limit (% of effective capital)
InpWeeklyLossPct6.0Weekly loss limit (% of effective capital)
InpAtrSlMult1.8ATR multiplier for stop-loss (x)
InpAtrTpMult3.0ATR multiplier for take-profit (x)
InpMinRR1.2Minimum reward:risk ratio (x)
InpCapAmount0.0Real-money equity cap ($)
InpCapFloor50.0Block new trades if effective < floor ($)
InpVoteMin4Min votes (of 5) to fire (>=3)
InpHtfEmaPeriod50HTF EMA period for trend confirm
InpAdxMin20Min ADX for trend regime (>=0)
InpAtrPctMin0.10Min ATR% (ATR/price*100) for adequate vol
InpEnableBEtrueMove to break-even at +1R
InpEnablePartialtrueTake 50% partial at +1.5R
InpEnableTrailtrueEnable ATR trailing stop
InpDryRuntrueDry-run (no live orders)
InpKillSwitchfalseMaster kill switch
InpMaxSpreadPts350Max spread (points) for entry
InpMaxConcurrent1Max concurrent positions (this magic)
Source Code (.mq5)Open Source
Pipsgrowth_com_EX10003.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX10003 LSTMRisk XAUUSD 5M — LSTM-risk momentum confluence 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>

CTrade         trade;
CPositionInfo  position;
CSymbolInfo    sym;
CAccountInfo   acc;

//================= INPUTS (20 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;
      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;
      case 4: return PRICE_LOW;
      case 5: return PRICE_MEDIAN;
      case 6: return PRICE_TYPICAL;
      case 7: return PRICE_WEIGHTED;
      default: return PRICE_CLOSE;
   }
}
ENUM_TIMEFRAMES g_InpHtfTimeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_InpSignalTf = PERIOD_H1;
input group "=== Identity ==="
input int      InpMagic          = 22210003;    // Magic number (unique per EA)
input string   InpTradeComment   = "Psgrowth.com Expert_10003"; // Trade comment
input int InpHtfTimeframe = 8; // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1)     // HTF trend timeframe
input int InpSignalTf = 0; // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Signal timeframe (default chart)

ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
   switch(tf)
   {

Full source code available on download

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

Tags:ex10003momentum-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_EX10003.mq5
File Size40.7 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyScalping
Risk LevelHigh Risk
Timeframes
M5
Currency Pairs
XAUUSD
Min. Deposit$100