P
PipsGrowth
ScalpingOpen Source – Free

Pipsgrowth EX14015 Scalper

MT5 Expert Advisor (Open Source) · XAUUSD · M1

Pipsgrowth.com EX14015 EMA_Fractal_Scalper — 3-EMA trend scalper with Williams Fractal entries, full 12-layer stack.

Overview

EX14015 EMA Fractal Scalper is a 3-EMA trend-pullback system that fires only when the slow, medium, and fast exponential averages stack in a clean sequence, then waits for a Williams Fractal pivot to confirm the reversal of a short-term dip. The EA does not chase breakouts and it does not fade ranges. It looks for an established directional bias, identifies a controlled retracement into the fast EMA, and enters on the first confirmed fractal swing that closes back on the right side of the slow average. Magic 22214015, four native indicator handles, twenty-two inputs grouped into EMA, Fractal, Trade, Stop Loss, Session, and Dashboard sections.

The trend gate is structural. The EA creates three iMA handles on the chart's current period with applied price selectable from seven modes (close by default, or open, high, low, median, typical, weighted). The check is a strict ordering: an uptrend is when EMA20 sits above EMA50 and EMA50 sits above EMA100, a downtrend is the mirror, and any other arrangement is treated as a ranging market and produces no signal. OnInit enforces this with an INIT_PARAMETERS_INCORRECT return if the user enters the periods in the wrong order. This is more than a numerical check — it is the EA's hard filter, which means a chopped, overlapping EMA stack never generates entries, no matter how many fractals print.

The entry trigger is a Williams Fractal pivot occurring on the back side of a pullback. The EA reads the iFractals handle (buffer 0 for upper fractals, buffer 1 for lower fractals) and indexes the confirmed fractal at Fractal_Offset bars back, which defaults to 2 — the standard two-bar confirmation delay. For a buy, the code requires the recent bar's low to have dipped below EMA20 (the pullback) but its close to have finished back above EMA100 (the trend is intact). It then checks that the lower-fractal buffer at the offset bar is not EMPTY and not zero. A sell mirrors this: a high above EMA20, a close below EMA100, and a non-empty upper-fractal at the offset bar. Crucially, the function tracks the time of the last signal via g_lastSignalTime and ignores any fractal that does not bring a newer timestamp, so a single valid swing cannot fire multiple times across consecutive ticks.

Stop loss placement is adaptive and pivot-aware. The CalculateSLDistance() function reads the last bar's close, high, and low plus the medium and slow EMAs. For a regular buy, the stop is the distance from the close down to EMA50 plus a 50-point buffer. The function then checks whether the bar's low came within 1.5x of EMA100 as it did to EMA50 — if so, the trade is classified as a deep pullback and the stop instead anchors to EMA100 with the same 50-point buffer. This isDeepPullback flag is propagated to the order comment (_DEEP or _REG) so the trade history records which anchor was used. The result is a stop that hugs whichever medium- or slow-EMA pivot the price actually tested, and that respects the configurable MinSL of 50 and MaxSL of 500 points. A buy's stop is therefore dynamic, but always between 0.5 and 5.0 price units on a 5-digit gold symbol.

Take profit is a fixed multiple. The EA multiplies the SL distance by RiskRewardRatio (1.5 default) and projects that same distance from the entry in the favorable direction. There is no trailing stop, no breakeven move, no partial close, and no signal-based exit — the position is held until either the broker-side SL, the broker-side TP, or a margin call ends it. The TP is attached at order placement, not managed dynamically, which means the same trade cannot benefit from a continued trend unless the trader manually intervenes. This is intentional in the design: the EA's edge is in the entry filter, not in the exit management.

Lot sizing is dual-mode. With FixedLotSize = 0.01 (non-zero) the EA returns a normalized 0.01 lot for every order. Set FixedLotSize to 0 and the EA switches to CalculateLotSize(), which converts the SL distance in points into a lot size that risks RiskPercent of the account balance. The function pulls tick value, tick size, and point from the symbol, computes a pip value, and divides risk-amount by slPips * pipValue before flooring to the lot step and clamping to the broker's min/max. The result is a risk-based sizing model that adapts to the actual stop distance — a tight 50-point SL on a $1,000 account at 1% risk produces 0.20 lots on most gold symbols, while a 500-point deep pullback produces roughly 0.02 lots. With FixedLotSize at 0.01, the same trade would still be 0.01 lots regardless.

The pre-trade gate is layered. OnTick() runs only on a new bar, then calls IsTradingAllowed() which checks MQL_TRADE_ALLOWED and TERMINAL_TRADE_ALLOWED, plus the session filter (8 to 20 server hours when enabled, with overnight support for inverted windows). The function then copies all four indicator buffers with a depth of Fractal_Offset + 5 bars, demands the bar count exceed barsNeeded + EMA_Slow_Period to ensure the slow EMA has stabilized, and checks the current spread against MaxSpreadPoints = 30 raw points. A single-position check via HasOpenPosition() runs last — if there is any open position on the symbol with the matching magic, the EA returns without scanning for new signals. There is no scaling, no pyramiding, no averaging, and no grid.

Three retry helpers are declared at the bottom of the file — TryClose_EX14015, TryClosePartial_EX14015, and TryModify_EX14015 — all wrapping the CTrade object. Each retries up to three times on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED codes, with a 200ms sleep between attempts for closes and 100ms for modifies. None of them are actually called from OnTick() in this build, which means the order placement path goes directly through the raw MqlTradeRequest, and the retry helpers sit unused. The Request.deviation = 30 raw points is the only slippage guard, and the GetFillingMode() helper probes SYMBOL_FILLING_MODE to choose FOK, IOC, or RETURN in that order of preference.

The chart dashboard is informative but not a control surface. It draws a 220x200 rectangle label in the upper-left corner showing the live trend classification (UPTREND, DOWNTREND, or RANGING), the most recent confirmed fractal direction, the current spread against the cap, the session status, whether a position is open, and the live values of EMA20, EMA50, and EMA100. A trio of color-coded corner labels at the top of the chart identifies the three EMA lines. The dashboard updates on every tick, the EMA labels persist on bar close, and the entire overlay is removed on deinit. The header's twelve-layer claim (REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester) is a marketing summary; the wired layers are trend regime, fractal signal, entry execution, spread/session/position confirmation, risk-percent lot sizing, and the SL/TP bracket. There is no capital cap layer that closes trades on equity drop, no OnTester custom metric, no signal-based exit, and no scaling logic.

The right account is a small one. The minimum deposit of $100 is workable only because FixedLotSize defaults to 0.01 — a sub-fractional position that survives a 50-point stop with about $0.50 of risk on a typical gold symbol. Running on risk-percent mode at 1% on $100 with a 50-point stop still produces near-min lots, but the same setting on $1,000 with a 500-point deep pullback stop produces a more meaningful position. A clean 5-digit gold broker with 30-point average spread during the 8-to-20 server window is the working baseline. The EA is server-time aware, not session-name aware, so the user must align SessionStartHour and SessionEndHour with the broker's GMT offset for the intended liquidity window — for many gold brokers this is 8-to-20 GMT to capture London and New York without the dead Asian middle.

What to expect in backtest is a low-frequency trend-pullback model. The EA averages far fewer than one trade per day on a typical gold M1 chart because fractals only print at confirmed swing points and the EMA stack filter eliminates most of those. Expect a string of small losses when the stack chops, punctuated by 1.5R winners when a clean pullback prints inside a trending day. There is no recovery mode, no martingale, and no basket TP — a bad run is a bad run, and the only safety net is the spread filter, the session filter, and the SL. The dashboard will show RANGING for most of any range day, which is the design behaving as intended: it does not trade what it cannot classify.

Strategy Deep Dive

Three iMA handles (20, 50, 100) plus one iFractals handle feed the bar-by-bar check in OnTick(), which only runs on a new bar. CheckSignal() reads bar 1's close plus the three EMA values, classifies the trend by strict ordering, then looks for a pullback-plus-fractal confluence at the offset bar; a buy needs EMA20 > EMA50 > EMA100, a low below EMA20, a close above EMA100, and a non-empty lower-fractal at the offset. g_lastSignalTime prevents re-firing on the same swing. CalculateSLDistance() chooses between EMA50 and EMA100 as the stop anchor based on the bar's low, adds 50 points, and clamps to MinSL 50 / MaxSL 500; CalculateLotSize() uses FixedLotSize 0.01 by default or falls back to 1% risk-based sizing. IsTradingAllowed() enforces the 8-to-20 server-time window and broker permissions before anything else fires. The position runs untouched until SL or TP closes it.

Entry Signal

Entry fires on a confirmed Williams Fractal at Fractal_Offset (default 2) bars back, gated by a strict 3-EMA stack: EMA20 > EMA50 > EMA100 for buys (or the mirror for sells), a pullback where the prior bar's low dipped below EMA20 but closed above EMA100, and a g_lastSignalTime check that only allows newer fractals to fire. The pullback-plus-fractal confluence means a swing without EMA-stack alignment produces nothing.

Exit Signal

Exits are broker-side only: the EA attaches both SL and TP at order placement and does not manage the position thereafter — no trailing stop, no breakeven, no signal-based close, no partial close. The only paths to a flat position are the SL hit, the TP hit at 1.5R, or a margin call. The three declared retry helpers (TryClose, TryClosePartial, TryModify) are not wired into OnTick in this build.

Stop Loss

The CalculateSLDistance() function anchors the stop to EMA50 (regular pullback) or EMA100 (deep pullback, when the prior bar's low came within 1.5x of EMA100 as it did EMA50) plus a 50-point buffer, then clamps the result to a MinSL of 50 and MaxSL of 500 points. The deep vs regular classification is preserved in the order comment as _DEEP or _REG so the trade history records which EMA anchor was used.

Take Profit

Take profit is slDistance * RiskRewardRatio (1.5 default) projected from the entry, attached as a broker-side TP at order placement. There is no dynamic TP, no multi-stage TP, and no basket-TP — the same target is set for every order regardless of the SL anchor (EMA50 or EMA100) or the resulting lot size.

Best For

Best on XAUUSD M1 (works M1–M5) with a clean 5-digit broker, server time aligned to 8–20 GMT to cover London and New York, minimum deposit $100. Pair it with FixedLotSize=0.01 for micro-lot operation or switch to 1% risk on a $1,000+ account. The 30-point spread cap means it tolerates normal retail spreads but rejects high-spike news events, and the trend-stack filter means it produces very few entries on ranging days — best used in trending market conditions, not mean-reversion.

Strategy Logic

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

Family: Scalper Magic: 22214015 Version: 2.00

BRIEF: Trend-following scalping strategy using 3 EMAs (20, 50, 100) for trend identification and Williams Fractal indicator for entry signals during pullbacks. SL below EMA50/EMA100, TP at 1:1.5 risk-reward ratio. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • andleEmaFast
  • andleEmaMedium
  • andleEmaSlow
  • andleFractal

KEY FUNCTIONS:

  • IsTradingAllowed()
  • CopyIndicatorData()
  • CheckSignal()
  • HasOpenPosition()
  • CalculateSLDistance()
  • CalculateLotSize()
  • NormalizeLot()
  • ExecuteBuyTrade()
  • ExecuteSellTrade()
  • GetRetcodeDescription()
  • DrawEMALines()
  • CreateDashboard()
  • ...and 6 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (22 total across 6 groups):

  • [=== EMA Settings ===] EMA_Fast_Period = 20 // EMA Fast Period
  • [=== EMA Settings ===] EMA_Medium_Period = 50 // EMA Medium Period
  • [=== EMA Settings ===] EMA_Slow_Period = 100 // EMA Slow Period
  • [=== EMA Settings ===] EMA_Price = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // EMA Applied Price
  • [=== Fractal Settings ===] Fractal_Offset = 2 // Fractal Bar Offset (confirmed bar index)
  • [=== Trade Settings ===] RiskPercent = 1.0 // Risk Per Trade (%)
  • [=== Trade Settings ===] FixedLotSize = 0.01 // Fixed Lot Size (0=use Risk%)
  • [=== Trade Settings ===] RiskRewardRatio = 1.5 // Risk:Reward Ratio (TP multiplier)
  • [=== Trade Settings ===] MaxSpreadPoints = 30 // Maximum Spread (points)
  • [=== Trade Settings ===] MagicNumber = 22214015 // Magic Number
  • [=== Trade Settings ===] InpTradeComment = "Psgrowth.com Expert_14015" // Trade Comment
  • [=== Stop Loss Settings ===] UseEMA100ForDeepPullback = true // Use EMA100 SL for Deep Pullbacks
  • [=== Stop Loss Settings ===] SL_Buffer_Points = 50 // SL Buffer (points)
  • [=== Stop Loss Settings ===] MinSL_Points = 50 // Minimum SL Distance (points)
  • [=== Stop Loss Settings ===] MaxSL_Points = 500 // Maximum SL Distance (points)
  • [=== Session Filter ===] UseSessionFilter = true // Enable Session Filter
  • [=== Session Filter ===] SessionStartHour = 8 // Session Start Hour (Server Time)
  • [=== Session Filter ===] SessionEndHour = 20 // Session End Hour (Server Time)
  • [=== Dashboard ===] ShowDashboard = true // Show Dashboard on Chart
  • [=== Dashboard ===] ShowIndicatorLines = true // Draw EMA Lines on Chart
  • [=== Dashboard ===] DashboardBgColor = clrBlack // Dashboard Background
  • [=== Dashboard ===] DashboardTextColor = clrWhite // Dashboard Text Color
Pseudocode
// Pipsgrowth EX14015 Scalper — Execution Flow (from source analysis)
// Family: Scalper
// Trend-following scalping strategy using 3 EMAs (20, 50, 100) for trend identification and Williams Fractal indicator for entry signals during pullbacks. SL below EMA50/EMA100, TP at 1:1.5 risk-reward ratio. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

ON_INIT:
    Create indicator handles: andleEmaFast, andleEmaMedium, andleEmaSlow, andleFractal
    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:
M1

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
EMA_Fast_Period20EMA Fast Period
EMA_Medium_Period50EMA Medium Period
EMA_Slow_Period100EMA Slow Period
EMA_Price1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // EMA Applied Price
Fractal_Offset2Fractal Bar Offset (confirmed bar index)
RiskPercent1.0Risk Per Trade (%)
FixedLotSize0.01Fixed Lot Size (0=use Risk%)
RiskRewardRatio1.5Risk:Reward Ratio (TP multiplier)
MaxSpreadPoints30Maximum Spread (points)
MagicNumber22214015Magic Number
InpTradeComment"Psgrowth.com Expert_14015"Trade Comment
UseEMA100ForDeepPullbacktrueUse EMA100 SL for Deep Pullbacks
SL_Buffer_Points50SL Buffer (points)
MinSL_Points50Minimum SL Distance (points)
MaxSL_Points500Maximum SL Distance (points)
UseSessionFiltertrueEnable Session Filter
SessionStartHour8Session Start Hour (Server Time)
SessionEndHour20Session End Hour (Server Time)
ShowDashboardtrueShow Dashboard on Chart
ShowIndicatorLinestrueDraw EMA Lines on Chart
DashboardBgColorclrBlackDashboard Background
DashboardTextColorclrWhiteDashboard Text Color
Source Code (.mq5)Open Source
Pipsgrowth_com_EX14015.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX14015 EMA_Fractal_Scalper — 3-EMA trend scalper with Williams Fractal entries, full 12-layer stack."
#include <Trade\Trade.mqh>

//+------------------------------------------------------------------+
//| INPUT PARAMETERS                                                   |
//+------------------------------------------------------------------+

//=== EMA Settings ===
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_APPLIED_PRICE g_EMA_Price = PRICE_CLOSE;
input group "=== EMA Settings ==="
input int EMA_Fast_Period = 20;                  // EMA Fast Period
input int EMA_Medium_Period = 50;                 // EMA Medium Period
input int EMA_Slow_Period = 100;                  // EMA Slow Period
input int EMA_Price = 1; // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // EMA Applied Price

//=== Fractal Settings ===
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_APPLIED_PRICE g_EMA_Price = PRICE_CLOSE;
input group "=== Fractal Settings ==="
input int Fractal_Offset = 2; // Fractal Bar Offset (confirmed bar index)

//=== Trade Settings ===
ENUM_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
   switch(ap)
   {
      case 1: return PRICE_CLOSE;
      case 2: return PRICE_OPEN;
      case 3: return PRICE_HIGH;

Full source code available on download

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

Tags:ex14015scalperpipsgrowthfreemt5xauusd

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_EX14015.mq5
File Size39.0 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyScalping
Risk LevelHigh Risk
Timeframes
M1
Currency Pairs
XAUUSD
Min. Deposit$100