P
PipsGrowth
ScalpingOpen Source – Free

Pipsgrowth EX14001 Scalper

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

Pipsgrowth.com EX14001 GUNEA Optimized — dual Hull-MA trend scalper, full 12-layer stack.

Overview

The Pipsgrowth EX14001 Scalper is a closed-bar trend-following EA built around an inline Hull Moving Average consensus on a configurable signal timeframe (H4 by default). The position-management code is conservative: 0.5% risk per trade, a 1.5:1 minimum reward-to-risk on the take-profit, an ATR(14) trailing stop that ratchets behind price, and a one-shot break-even that locks risk at +100 points of profit. The system reads as a deliberate, slow scalper rather than a tick-grabber: the order book is held to a single position per symbol, and every new entry must clear a 9-gate no-trade check before a market order is sent.

The Hull Moving Average is computed inline rather than as an iCustom call. The function HullMAAt(period, tf, shift) builds the classical Allan Hull construction — Hull(n) = LWMA( 2 * LWMA(n/2) − LWMA(n), sqrt(n) ) — by pulling the close series from the signal timeframe with CopyClose and running the lightweight linear-weighted moving average across the requested period. Two Hulls are sampled per evaluation: a fast Hull at InpHullFastPeriod = 65 bars, and a slow Hull at InpHullSlowPeriod = 90 bars, each measured at two closed-bar shifts (1 and 2). The signal direction is derived from the slope of each: the fast direction is sign(hf1 − hf2) and the slow direction is sign(hs1 − hs2), where the sign function is bounded by a single _Point of dead-zone. A signal is fired only if both slopes are non-zero and both point the same way; disagreement between the two Hulls — or a flat slope on either — returns a no-trade. A confidence value (20-100) is also returned, scaled by the magnitude of the slow slope relative to the fast.

Layered over the signal is a 7-state market regime classifier. ClassifyRegime() pulls 50 bars of ATR(14) to compute an ATR percentile (how the current ATR ranks against the last 49 readings) and 50 bars of Bollinger Band width (period 20, deviation 2.0) to compute a BB-width percentile. It also reads ADX(14). The output is an ENUM_REGIME label: ADX ≥ 25 → REG_STRONG_TREND; ADX ≥ 18 → REG_WEAK_TREND; ATR-percentile ≥ 80 or BBW-percentile ≥ 75 → REG_EXPAND; BBW-percentile ≥ 60 → REG_BREAKOUT; ATR-percentile ≤ 25 with BBW-percentile ≤ 20 → REG_COMPRESS; ADX < 15 → REG_CHOPPY; the rest falls into REG_RANGE. Two of those states — CHOPPY and COMPRESS — block entries entirely; the rest are permitted. This means the EA will deliberately pass on setups during congestion or when volatility is drying up, and only engages when ADX is at least 18 or when the Bollinger envelope is opening up.

The confirmation layer requires the HTF EMA(50) to agree. ConfirmHTF() reads the closed bar of the higher timeframe (D1 by default via InpHTFtf = 7) and checks that the candle close is on the correct side of the EMA — above for long signals, below for short signals. A long signal that fires on the H4 Hull consensus but where the daily candle is sitting below its 50-EMA gets dropped on the floor. The HTF EMA is only sampled on the closed bar (shift 1), never on the still-forming bar, to avoid acting on noise.

The order flow itself runs through a 9-gate NoTradeReason() check before any ticket is sent. The gates in evaluation order: InpKillSwitch on, equity below InpCapitalCapFloor (50 by default), open position count at InpMaxConcurrentTrades (1), 100-trades-per-day hit, g_consec_losses ≥ InpCooldownAfterLosses (3), daily realized loss ≥ InpMaxDailyLossPct (3%) of effective capital, weekly realized loss ≥ InpMaxWeeklyLossPct (6%) of effective capital, spread > max(30 points, broker stops-level × 2), and either CHOPPY or COMPRESS regime. After that, the session filter requires server time to fall between 07:00 and 21:30, with an additional cut-off at Friday 21:00 to avoid the weekend closeout. Any single failing gate returns a string reason that is printed to the log and the entry is abandoned.

Sizing is risk-based. CalcLot() takes the SL distance (ATR(14) × InpATRStopMult = 2.5) and converts it into a lot size such that the per-trade risk equals InpRiskPercent (0.5% of effective capital) of the equity. The lot is floored to the broker's volume step, clamped to the symbol's min/max volume, and re-validated by OrderCalcMargin() against the free margin before the order is sent. If InpCapitalCapAmount is set to a positive value, effective capital becomes min(cap, equity) — a way to size from a fixed notional rather than from the full balance.

Once a position is open, the exit logic runs on every closed bar of the signal timeframe regardless of whether a new entry is being considered. The break-even is a one-shot: once profit ≥ InpBreakevenPoints (100 points), the SL is moved to open + 5 points (a small lock) and never reset. The ATR trail, controlled by InpTrailATRMult (2.0), pulls the stop behind price only once the position is in profit by at least the trail distance; if the ATR sample is invalid, the trail is skipped for that bar. The opposite-signal exit is the third lever — if the Hull consensus flips direction on a new bar, all live positions in the opposite direction are closed via TryClose_EX14001(), which attempts the close three times with a 200ms sleep on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED, then gives up. TryModify_EX14001() does the same retry pattern for the SL/TP modifications, but only on REQUOTE / TIMEOUT (100ms sleep).

The order layer itself is conservative. trade.SetDeviationInPoints(50) caps the slippage at 50 points on a market order, and the open attempts a single retry on REQUOTE or TIMEOUT before returning false. Filling mode is selected automatically via SetTypeFillingBySymbol. The capital cap, kill switch, and dry-run flags are all operator inputs — InpCapitalCapAmount defaults to 0.0 (no cap), InpKillSwitch defaults to false, and InpDryRun defaults to false. InpDryRun is worth knowing about: when flipped to true, the EA logs the order it would have sent (with full price, SL, TP, ATR, lots) without actually placing a ticket — useful for forward-testing the new-bar timing on a live account before risking capital.

A backtest run with the EX14001 defaults — H4 signal timeframe, D1 HTF, XAUUSD, M15 chart, 0.5% risk, 2.5 ATR stop multiplier, 1.5 RR — will produce a low trade count compared to a tick-scalper. The shape of the equity curve depends more on whether H4 Hull consensus plus D1 EMA agreement fires on the historical bar than on micro-scalping alpha, so most of the time the EA sits flat. That is by design: this is a regime-conditional trend engine, not a maker-style market-neutral grid. Run it on a sub-30-point gold-spread ECN with at least $500 to give the 0.5% sizing room to breathe through the 3-loss cooldowns, and expect long flat patches punctuated by short bursts when H4 and D1 finally line up.

Strategy Deep Dive

On every closed bar of the signal timeframe, ClassifyRegime() pulls 50 bars of ATR(14) and Bollinger Band width to bucket the market into one of seven states — strong trend, weak trend, expand, breakout, compress, choppy, or range — and CHOPPY plus COMPRESS block entries. The function HullMAAt() then samples two inline Hull Moving Averages (period 65 fast, 90 slow) at two closed-bar shifts each, building the classical LWMA(2×LWMA(n/2) − LWMA(n), sqrt(n)) formula directly from the close series; a signal fires only when both Hull slopes agree on direction and neither is flat. The signal then has to clear a daily-candle EMA(50) confirmation on the higher timeframe, a 9-gate NoTradeReason() check (kill switch, capital floor, position cap, daily/weekly loss caps, 3-trade cooldown, spread cap, session window, Friday cutoff, and the CHOPPY/COMPRESS regime block), and a margin pre-check via OrderCalcMargin() before trade.PositionOpen() sends the ticket with a 50-point slippage cap. Once open, ManageExits() runs the one-shot break-even at +100 points, the ATR trailing stop, and the opposite-signal close — each modification wrapped in a three-attempt retry loop with REQUOTE/TIMEOUT-only retries for SL/TP changes.

Entry Signal

A long fires when the fast Hull (period 65) and slow Hull (period 90) both slope up across two closed bars on the signal timeframe, and a short fires when both slope down — disagreement or a flat slope returns no signal. The signal must then clear a 7-state regime classifier (CHOPPY and COMPRESS block entries) and a higher-timeframe EMA(50) candle-close filter (D1 by default, candle must close on the correct side of the EMA). Sizing is risk-based at InpRiskPercent = 0.5% of effective capital, with the lot computed from the ATR(14) × 2.5 stop distance.

Exit Signal

Positions exit on a flip of the dual-Hull consensus to the opposite direction, a one-shot break-even at +100 points of profit that locks risk at open + 5 points, or an ATR(14) trailing stop at 2.0x multiple that ratchets behind price only when in profit past the trail distance. All three are evaluated per closed bar inside ManageExits(), with three-attempt retries on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED via TryClose_EX14001() and TryModify_EX14001().

Stop Loss

ATR(14) × InpATRStopMult = 2.5 default (on XAUUSD typically 60-90 points depending on regime), clamped to the broker stops-level minimum via ClampStop() and sent as a broker-side stop on every entry. The SL is later ratcheted up by the break-even and the ATR trail but never widened back.

Take Profit

SL distance × InpMinRR = 1.5 default, so a 75-point SL carries a ~112-point TP. Set on entry as a fixed broker-side take-profit and not adjusted afterwards — ManageExits() only moves the SL, never the TP.

Best For

Minimum recommended balance is $100 with the default 0.5% risk per trade, but the EA scales linearly with capital up to whatever InpCapitalCapAmount is set. Best run on XAUUSD M15 with the default H4 signal and D1 higher-timeframe filter, on an ECN or RAW-spread broker with sub-30-point gold spreads, and only during the 07:00-21:30 server-time window (London and New York hours). Do not override the 3% daily / 6% weekly loss caps or the 3-trade cooldown — those are what keep the regime-conditional engine from bleeding when the H4/D1 alignment breaks down.

Strategy Logic

Pipsgrowth EX14001 Scalper — Strategy Logic Analysis (from .mq5 source)

Family: Scalper Magic: 22214001 Version: 2.00

BRIEF: Inline dual Hull-MA (fast/slow) slope-color consensus signal. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • LWMA_seg()
  • HullMAAt()
  • ResetDayWeekTracking()
  • RefreshRealizedPnL()
  • EffectiveCapital()
  • HullSignal()
  • ConfirmHTF()
  • NoTradeReason()
  • CalcLot()
  • ClampStop()
  • ExecuteOpen()
  • CountMyPositions()
  • ...and 6 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (21 total across 6 groups):

  • [=== Identity & Safety ===] InpMagicNumber = 22214001 // Magic number (unique per EA)
  • [=== Identity & Safety ===] InpTradeComment = "Psgrowth.com Expert_14001" // Order comment
  • [=== Identity & Safety ===] InpDryRun = false // Dry-run: skip real order sends (default OFF)
  • [=== Identity & Safety ===] InpKillSwitch = false // Emergency kill switch (blocks new entries)
  • [=== Capital Allocation Cap ===] InpCapitalCapAmount = 0.0 // Cap amount ($, real money equity)
  • [=== Capital Allocation Cap ===] InpCapitalCapFloor = 50.0 // Floor: block new entries below this ($)
  • [=== Risk Management ===] InpRiskPercent = 0.5 // Risk per trade (% of effective capital)
  • [=== Risk Management ===] InpMaxDailyLossPct = 3.0 // Max daily loss (% of effective capital)
  • [=== Risk Management ===] InpMaxWeeklyLossPct = 6.0 // Max weekly loss (% of effective capital)
  • [=== Risk Management ===] InpMaxConcurrentTrades = 1 // Max concurrent positions (this EA/symbol)
  • [=== Risk Management ===] InpCooldownAfterLosses = 3 // Cooldown after N consecutive losses (bars)
  • [=== Signal: Dual Hull-MA ===] InpHullFastPeriod = 65 // Fast Hull period
  • [=== Signal: Dual Hull-MA ===] InpHullSlowPeriod = 90 // Slow Hull period
  • [=== Signal: Dual Hull-MA ===] InpSignalTF = 6 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Signal timeframe
  • [=== Signal: Dual Hull-MA ===] InpHTFtf = 7 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // HTF EMA agreement timeframe
  • [=== Regime & ATR Stops ===] InpATRPeriod = 14 // ATR period (regime + stops)
  • [=== Regime & ATR Stops ===] InpADXPeriod = 14 // ADX period (regime)
  • [=== Regime & ATR Stops ===] InpATRStopMult = 2.5 // ATR multiplier for SL
  • [=== Regime & ATR Stops ===] InpMinRR = 1.5 // Minimum reward:risk ratio
  • [=== Exits (BE / Trail) ===] InpBreakevenPoints = 100 // Move to BE after N profit points
  • [=== Exits (BE / Trail) ===] InpTrailATRMult = 2.0 // ATR trailing multiplier (0=off)
Pseudocode
// Pipsgrowth EX14001 Scalper — Execution Flow (from source analysis)
// Family: Scalper
// Inline dual Hull-MA (fast/slow) slope-color consensus signal. 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:
M15M5M30

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
InpMagicNumber22214001Magic number (unique per EA)
InpTradeComment"Psgrowth.com Expert_14001"Order comment
InpDryRunfalseDry-run: skip real order sends (default OFF)
InpKillSwitchfalseEmergency kill switch (blocks new entries)
InpCapitalCapAmount0.0Cap amount ($, real money equity)
InpCapitalCapFloor50.0Floor: block new entries below this ($)
InpRiskPercent0.5Risk per trade (% of effective capital)
InpMaxDailyLossPct3.0Max daily loss (% of effective capital)
InpMaxWeeklyLossPct6.0Max weekly loss (% of effective capital)
InpMaxConcurrentTrades1Max concurrent positions (this EA/symbol)
InpCooldownAfterLosses3Cooldown after N consecutive losses (bars)
InpHullFastPeriod65Fast Hull period
InpHullSlowPeriod90Slow Hull period
InpSignalTF6Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Signal timeframe
InpHTFtf7Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // HTF EMA agreement timeframe
InpATRPeriod14ATR period (regime + stops)
InpADXPeriod14ADX period (regime)
InpATRStopMult2.5ATR multiplier for SL
InpMinRR1.5Minimum reward:risk ratio
InpBreakevenPoints100Move to BE after N profit points
InpTrailATRMult2.0ATR trailing multiplier (0=off)
Source Code (.mq5)Open Source
Pipsgrowth_com_EX14001.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX14001 GUNEA Optimized — dual Hull-MA trend 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>

//================== IDENTITY & SAFETY =================
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_InpSignalTF = PERIOD_H1;
ENUM_TIMEFRAMES g_InpHTFtf = PERIOD_H1;
input group "=== Identity & Safety ==="
input int    InpMagicNumber      = 22214001;      // Magic number (unique per EA)
input string InpTradeComment     = "Psgrowth.com Expert_14001"; // Order comment
input bool   InpDryRun           = false;          // Dry-run: skip real order sends (default OFF)
input bool   InpKillSwitch       = false;         // Emergency kill switch (blocks new entries)

//================== CAPITAL ALLOCATION CAP =================
input group "=== Capital Allocation Cap ==="
// InpCapitalCapEnabled removed — use InpCapitalCapAmount=0 to disable         // Enable capital cap (REAL money, not notional)
input double InpCapitalCapAmount  = 0.0;        // Cap amount ($, real money equity)
input double InpCapitalCapFloor   = 50.0;         // Floor: block new entries below this ($)

//================== RISK =================
input group "=== Risk Management ==="
input double InpRiskPercent       = 0.5;          // Risk per trade (% of effective capital)

Full source code available on download

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

Tags:ex14001scalperpipsgrowthfreemt5xauusd

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_EX14001.mq5
File Size31.2 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyScalping
Risk LevelHigh Risk
Timeframes
M15M5M30
Currency Pairs
XAUUSD
Min. Deposit$100