P
PipsGrowth
BreakoutOpen Source – Free

Pipsgrowth EX02017 Breakout

MT5 Expert Advisor (Open Source) · XAUUSD · M15

Pipsgrowth.com EX02017 GoldScalper_FractalBreak_HighLowBreak — Williams fractal breakout scalper, full 12-layer stack.

Overview

Pipsgrowth EX02017 is a Williams-fractal breakout scalper engineered for XAUUSD on the M15 chart. The EA watches the most recent confirmed upper and lower Williams fractals — those are the local pivot highs and lows that print when an M15 candle has two lower-high neighbours on each side (for the upper fractal) or two higher-low neighbours (for the lower fractal) — and waits for a closed-bar close to break through the fractal level by at least FractalBuffer pips (5 pips by default). The break must occur on a freshly closed bar; live-tick breaches are not enough.

The signal layer is intentionally lean. There is no ADX regime classifier, no multi-timeframe EMA, no SuperTrend, no Gaussian channel. Just the iFractals handle on PERIOD_M15 plus an iATR(14) handle to size the stop. The EA refreshes the fractal and ATR buffers in RefreshIndicators() each new M15 bar, scanning a 30-bar window for the most recent non-EMPTY upper and lower fractal values, then updates two globals — lastFractalHigh and lastFractalLow — that the entry logic consults in OnTick().

When a long break fires, the EA calls OpenPosition(ORDER_TYPE_BUY). The function sizes the lot via CalculatePositionSize(): if UseMoneyManagement is true, it risks RiskPercent of account balance (2.0% by default), divides by the per-pip value of the symbol, and floors to the lot step. If money management is off, it falls back to FixedLotSize (0.01 by default). The stop distance is the maximum of three things: currentATR * 1.5, StopLossPips * pipSize (15 pips default), and minDist * 1.5 where minDist is the broker's stops_level expressed in price units (with a 10-pip fallback). This floor-driven SL means the EA widens its stop on volatile gold sessions and tightens during quiet ones, but it never goes below the static 15-pip reference or below the broker's minimum-stop distance.

Take-profit distance is max(SL * 2, minDist * 1.5), giving a 1:2 reward-to-risk ratio that the source guards with a minDist floor so the TP is never placed inside the broker's minimum-stop zone. SL and TP are normalized through NormalizePrice_EX02017, which rounds to the symbol's tick size. Before sending, the EA calls OrderCalcMargin to confirm the account can fund the order, and then it sends via the CTrade wrapper with the configured magic (22202017) and a Slippage of 3 points. If the broker returns REQUOTE, TIMEOUT, PRICE_OFF, or PRICE_CHANGED, the EA retries the entry up to three times with 200ms between attempts.

Risk management is handled at the account level, not the position level. There is no trailing stop, no break-even ratchet, no partial close — the position is held to its static SL or TP, and the EA only opens one position at a time (CountPositions() >= 1 short-circuits the entry block). The hardening stack takes over once trades start flowing. OnTradeTransaction watches for deal additions with the EA's magic, sums the deal's profit + swap + commission, and updates g_realizedToday and g_realizedWeek. When realized daily loss reaches InpDailyLossLimitPct of initial balance (5% by default), IsSafeToTrade_EX02017 blocks all new entries. When g_consecLosses crosses InpMaxConsecLosses (5 by default), a cooldown is set: g_cooldownUntil = TimeCurrent() + InpCooldownHours * 3600 (4 hours), and the EA pauses new entries until that wall-clock deadline passes.

The session gate is a hard wall. DetectGMTOffset_EX02017 runs on OnInit and walks offsets from -12 to +12 GMT, scoring each by weekday (Mon-Fri +10) and hour (7-21 +5), then locks in the best score as g_gmtOffset. With the default config, InpUseGMTSessions is on, InpLondonStartGMT/InpLondonEndGMT define 7-16 GMT, and InpNewYorkStartGMT/InpNewYorkEndGMT define 12-21 GMT. InActiveSession_EX02017 checks whether the current GMT hour falls inside either window. The market-open guard also blocks Saturday, Sunday before 22 GMT, and Friday from 22 GMT onward. IsNewsTime_EX02017 queries the MQL5 economic calendar via CalendarValueHistory for events in a ±InpNewsBufferMinutes (30 minutes) window, and blocks entries if any high-importance event lands in that band.

Capital protection is configurable but inactive by default. InpCapAmount is 0.0 out of the box, which disables the cap. When set above zero, the effective capital is min(InpCapAmount, equity), and if that effective capital falls below InpCapFloor (1000.0), the EA refuses to trade. The kill switch is InpMinEquityPct (70.0% of initial balance): if equity drops below 70% of the snapshot taken in OnInit, IsSafeToTrade_EX02017 blocks entries.

The Tester criterion in OnTester() is profit * profitFactor / maxDD, gated by profitFactor in (0, 1000], maxDD > 0, and at least 10 trades. Note the gates here are looser than the rest of the EX02 family — the trade-count minimum is 10 instead of 30, reflecting the lower-frequency nature of a one-position-at-a-time M15 breakout EA.

In practice this is a set-and-forget gold breakout: minimal inputs, a single fractal-based signal on the M15, a static SL/TP, and a hardening stack that protects the account rather than micro-managing open trades. It's suited for traders who want a clean Williams-fractal implementation without the multi-layer confirmation stack that the more complex EX02 EAs bring.

Strategy Deep Dive

On every new M15 bar the EA refreshes its iFractals and iATR(14) buffers, walks a 30-bar window for the most recent non-empty upper and lower fractal values, and stores them in lastFractalHigh and lastFractalLow. The entry block then compares the prior bar's close to those levels with the FractalBuffer (5 pips); a long fires when the close breaks above the upper fractal plus the buffer, a short on the mirror. The order goes through OrderCalcMargin, fills via the auto-detected FOK/IOC/RETURN mode from GetAllowedFilling, and retries up to three times on requote, timeout, price-off, or price-changed returns. Position management is account-level only: OnTradeTransaction sums daily and weekly P&L, enforces the InpDailyLossLimitPct daily loss cap and InpCooldownHours cooldown after InpMaxConsecLosses, while the session gate uses DetectGMTOffset_EX02017 plus CalendarValueHistory to keep entries inside the London-NY window and away from high-impact news.

Entry Signal

Long entry fires when a closed M15 bar's close trades above the most recent confirmed upper Williams fractal plus the 5-pip FractalBuffer; the short mirror fires when the close breaks below the most recent lower fractal minus the buffer. The EA only takes one position at a time, sizes it to risk RiskPercent (2.0% default) of account balance, and only when the live spread is below MaxSpreadPips (25 pips).

Exit Signal

Positions are held to the static SL or TP — there is no trailing stop, no break-even, and no partial close. The EA enforces exits only at the position-shape level (one position, then idle until the next fractal break). Account-level exits come from the hardening stack: a 4-hour cooldown after InpMaxConsecLosses (5) losers, a full-day block when InpDailyLossLimitPct (5%) of initial balance is realized, and a news-time block for high-impact events within InpNewsBufferMinutes (30).

Stop Loss

Stop-loss distance is the maximum of ATR(14) × 1.5, the static 15-pip StopLossPips reference, and 1.5 × minDist (the broker's stops_level with a 10-pip fallback), so the stop widens on volatile sessions and floors at the static or broker minimum. The level is tick-normalized via NormalizePrice_EX02017 and validated against the broker's stops_level before the order is sent.

Take Profit

Take-profit distance is the maximum of SL × 2 and 1.5 × minDist, giving a 1:2 reward-to-risk ratio on every trade. The TP is also tick-normalized and validated against the broker's stops_level so it never lands inside the minimum-stop zone.

Best For

Suited for traders running XAUUSD on M15 with a low-spread ECN or RAW account (the EA blocks entries when spread exceeds 25 pips) and a balance of $100 or more, given the 2% per-trade default risk. The London-NY session gate and the ±30-minute news filter assume a broker whose server time can be reliably converted to GMT — the auto-detect in DetectGMTOffset_EX02017 handles most server-time setups, but verify the result in the strategy-tester journal before going live. The one-position, hold-to-SL/TP posture makes this a low-screen-time EA: a good fit for traders who want Williams-fractal breakout exposure without watching the chart.

Strategy Logic

Pipsgrowth EX02017 Breakout — Strategy Logic Analysis (from .mq5 source)

Family: Breakout Magic: 22202017 Version: 2.00

BRIEF: Gold scalping strategy trading breakouts of Williams fractals with ATR-based stop loss and take profit, spread filter, and money management. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • SafePositionModify()
  • RefreshIndicators()
  • OpenPosition()
  • CalculatePositionSize()
  • IsNewBar()
  • GetPipSize()
  • CheckFilters()
  • CountPositions()
  • DetectGMTOffset_EX02017()
  • ServerToGMT_EX02017()
  • IsMarketOpen_EX02017()
  • InActiveSession_EX02017()
  • ...and 8 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (4 total across 3 groups):

  • [=== Trade Settings ===] FractalBuffer = 5 // Pips buffer above/below fractal
  • [=== GMT Session Filter ===] InpNewYorkEndGMT = 21 // --- Hardening: Capital Protection ---
  • [=== Capital Protection ===] InpCapAmount = 0.0 // Capital cap amount (0=disabled, effective capital = min(capAmount, equity))
  • [=== Capital Protection ===] InpMinEquityPct = 70.0 // --- Hardening: Trade Safety ---
Pseudocode
// Pipsgrowth EX02017 Breakout — Execution Flow (from source analysis)
// Family: Breakout
// Gold scalping strategy trading breakouts of Williams fractals with ATR-based stop loss and take profit, spread filter, and money management. 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:
M15

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 onto an H1 or H4 chart
  7. 7Set the range detection period, breakout buffer, and lot size in the EA dialog
  8. 8Enable Allow Algo Trading and click OK

EA Parameters

ParameterDefaultDescription
FractalBuffer5Pips buffer above/below fractal
InpNewYorkEndGMT21--- Hardening: Capital Protection ---
InpCapAmount0.0Capital cap amount (0=disabled, effective capital = min(capAmount, equity))
InpMinEquityPct70.0--- Hardening: Trade Safety ---
Source Code (.mq5)Open Source
Pipsgrowth_com_EX02017.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX02017 GoldScalper_FractalBreak_HighLowBreak — Williams fractal breakout scalper, full 12-layer stack."
#include <Trade\Trade.mqh>

input group "=== Risk Management ==="
input bool   UseMoneyManagement = true;
input double RiskPercent        = 2.0;
input double FixedLotSize       = 0.01;

input group "=== Trade Settings ==="
input int    StopLossPips       = 15;
input int    Slippage           = 3;
input int    MagicNumber        = 22202017;
input string InpTradeComment    = "Psgrowth.com Expert_02017";
input int    FractalBuffer      = 5;          // Pips buffer above/below fractal

input group "=== Filters ==="
input bool   UseSpreadFilter    = true;
input double MaxSpreadPips      = 25.0;

CTrade trade;
int handleFractals, handleATR;
datetime lastBarTime = 0;
double currentATR;
double lastFractalHigh = 0, lastFractalLow = 0;

//--- Hardening Globals
int      g_gmtOffset       = 3;
int      g_tradesToday     = 0;
datetime g_dayStartTime    = 0;
double   g_initialBalance  = 0.0;
datetime g_cooldownUntil   = 0;
int      g_consecLosses    = 0;
double   g_realizedToday   = 0.0;
double   g_realizedWeek    = 0.0;
datetime g_weekStartTime   = 0;

// --- Hardening: GMT Session Filter ---
input group "=== GMT Session Filter ===";
input bool    InpUseGMTSessions       = true;
input int     InpLondonStartGMT       = 7;
input int     InpLondonEndGMT         = 16;
input int     InpNewYorkStartGMT      = 12;
input int     InpNewYorkEndGMT        = 21;

// --- Hardening: Capital Protection ---
input group "=== Capital Protection ===";
input double  InpCapAmount            = 0.0;      // Capital cap amount (0=disabled, effective capital = min(capAmount, equity))
input double  InpCapFloor             = 1000.0;
input double  InpMinEquityPct         = 70.0;

// --- Hardening: Trade Safety ---
input group "=== Trade Safety ===";
input int     InpMaxTradesPerDay      = 10;
input int     InpMaxConsecLosses      = 5;
input int     InpCooldownHours        = 4;
input double  InpDailyLossLimitPct    = 5.0;

Full source code available on download

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

Tags:ex02017breakoutpipsgrowthfreemt5xauusd

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_EX02017.mq5
File Size21.8 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyBreakout
Risk LevelMedium Risk
Timeframes
M15
Currency Pairs
XAUUSD
Min. Deposit$100