P
PipsGrowth
BreakoutOpen Source – Free

Pipsgrowth EX02030 Breakout

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

Pipsgrowth.com EX02030 BreakoutHunter — S/R breakout with volume confirmation, full 12-layer stack.

Overview

A focused, no-indicator breakout hunter. EX02030 scans a configurable lookback window for the highest high and lowest low, then fires a market order when the live ask or bid breaks past those boundaries by a small pip buffer. The strategy inputs are intentionally few: lookback length, buffer size, fixed lot, fixed stop-loss, fixed take-profit. What the source adds on top of that skeleton is a complete risk-and-session gate, but the trading logic itself is just two comparisons per bar.

The signal path is short and runs once per bar. A static lastBar timestamp inside OnTick() ensures that the rest of the function only fires on a fresh candle — no tick-spam entries. After the new-bar check, IsSafeToTrade_EX02030() either approves or vetoes the tick. If it vetoes (because the market is closed, we're in a news blackout, a cooldown is active, the daily loss limit is hit, or the equity floor is breached), the EA does nothing. If a position with magic 22202030 already exists on the symbol, HasTrade() short-circuits the function as well — at most one open position at a time, no pyramiding, no scaling.

When the gate clears, the EA pulls InpLookback (default 20) highs and lows starting from bar 2 — bar 1 is excluded so the most recent unsettled bar can't be the resistance or support level — and stores them in two arrays. ArrayMaximum returns the highest high (resistance), ArrayMinimum returns the lowest low (support). The buffer is InpBuffer pips (default 5) added beyond those levels, a small zone that filters out wicks that close back inside the range.

A buy fires when the current ask is greater than resistance + buffer. A sell fires when the current bid is less than support - buffer. Both go through dedicated wrappers — TryBuy_EX02030 and TrySell_EX02030 — that clamp the requested lot to the broker's min/max/step, run OrderCalcMargin to confirm the account can fund the trade, then attempt the order. Up to three retries are allowed with a 200ms sleep on transient errors: REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED. The order is submitted as a market order with fixed-pips SL and TP; no pending order sits on the book.

SL is computed as ask - InpStopLoss * _Point * 10 (default 30 pips) for buys, the mirror for sells. TP is ask + InpTakeProfit * _Point * 10 (default 60 pips). Out of the box the TP/SL ratio is 1:2. The 30-pip stop is narrow relative to a typical 20-bar XAUUSD range, so a failed breakout will eat a small loss while a successful one will pay double.

What the strategy does not do is just as important as what it does. There is no trailing stop, no break-even ratchet, no partial close, no opposite-signal exit mid-trade. The position runs to either its fixed TP or its fixed SL. The only thing that closes a position before the TP/SL hits is HasTrade() checking the next bar — and since EX02030 caps itself at one position, the practical effect is: a new breakout signal while the current position is still alive gets ignored. The risk of holding a 60-pip TP trade through a 200-pip trend is real, but the strategy accepts that in exchange for not having to manage the trade.

The hardening layer is where most of the inputs live. IsSafeToTrade_EX02030 runs seven checks:

  • Market hours: IsMarketOpen_EX02030 blocks Sunday, Saturday, Friday from 22:00 GMT onward, and Monday until 22:00 GMT. The asymmetry on Monday and Friday is intentional — it accounts for the typical Sunday-evening open and Friday-evening close of the FX market.
  • Session filter: InActiveSession_EX02030 checks the GMT hour against two windows: London (default 7–16) and New York (default 12–21). With InpUseGMTSessions = false (the default), this check passes through and the EA trades around the clock during weekdays; flip it to true to confine entries to the overlap.
  • News blackout: IsNewsTime_EX02030 queries CalendarValueHistory for high-importance events in a ±30-minute window (InpNewsBufferMinutes = 30 by default). When InpFilterNews = true, the EA refuses to enter during scheduled red-folder releases.
  • Capital cap: when InpCapAmount > 0, the effective capital becomes MathMin(InpCapAmount, equity), and the EA blocks new entries if that figure falls below InpCapFloor (default 1000). At the default InpCapAmount = 0, this branch is disabled and the EA treats the full account balance as the sizing base.
  • Equity floor: live equity must stay above InpMinEquityPct (default 70%) of the initial balance, or the EA halts. This is a hard kill switch for catastrophic drawdown.
  • Trade caps: InpMaxTradesPerDay (default 10) caps the daily entry count. A consecutive-loss tracker in OnTradeTransaction increments on every loss, and after InpMaxConsecLosses losses (default 5) it sets g_cooldownUntil = TimeCurrent() + InpCooldownHours * 3600 (default 4 hours), during which no new entries are allowed.
  • Daily loss limit: if the absolute value of g_realizedToday exceeds InpDailyLossLimitPct × initial balance (default 5%), the EA stops opening new trades until UpdateDailyCounters_EX02030 rolls the counter over at the next day boundary.

GMT translation is handled by DetectGMTOffset_EX02030, a heuristic that scores every offset in the -12 to +12 range and picks the one that places the current server time inside a weekday, business-hour band. The default returned value is 3, but the function will override that on brokers whose server time is closer to UTC.

The OnTester fitness function is profit × profitFactor / maxDD, gated to require at least 10 trades. profitFactor is clamped to [1, 1000] to prevent a single outlier trade from dominating the ranking. The formula rewards EAs that compound profit while penalising those that achieve it through tail-risk blowups — useful for comparing parameter sets in the MT5 Strategy Tester.

The strategy is range-averse. Sustained directional markets produce clean breakouts that run to TP. Range-bound markets produce repeated false breakouts that hit the 30-pip stop. The lookback window and the buffer are the two parameters that swing this most — 20 bars and 5 pips are tuned for XAUUSD M15, but a wider window (e.g., 40–50 bars) will filter more noise at the cost of late entries. On M5 the same settings will overtrade; InpMaxTradesPerDay = 10 caps the worst of it but the fixed-pips SL will still register as a loss.

Broker notes: the buffer is set in pips, not in points × spread, so a low-spread ECN account will see the cleanest signals. XAUUSD at typical retail spreads of 15–25 points is fine; an exotic pair at 50+ point spreads will eat into the buffer and may require raising InpBuffer. There is no InpDryRun flag in this build, so the EA trades from the moment it is attached to a chart. Demo it first if you want to observe behaviour before going live.

Strategy Deep Dive

OnTick() first calls UpdateDailyCounters_EX02030() to roll over daily and weekly PnL counters, then a static lastBar timestamp ensures the rest of the function only runs on a fresh candle. The next gate is IsSafeToTrade_EX02030(), which combines seven checks: market hours, optional session filter, news blackout, capital cap, equity floor, max trades per day, and an active cooldown from a recent losing streak. If the gate clears and HasTrade() returns false, the EA pulls InpLookback highs and lows starting from bar 2, identifies the highest high and lowest low of the window via ArrayMaximum and ArrayMinimum, and compares the current ask and bid to those levels plus a 5-pip buffer. A buy or sell market order is sent through TryBuy_EX02030 or TrySell_EX02030, which clamp the lot, verify margin, and retry up to three times on transient price errors. The order is submitted with fixed-pips SL and TP — there is no in-trade trailing, no break-even ratchet, no partial close, so the position runs to its limits.

Entry Signal

EX02030 fires market orders, not pending orders. A buy triggers when the current ask exceeds the highest high of the last InpLookback bars (default 20) plus a 5-pip buffer; a sell triggers when the bid drops below the lowest low minus the same buffer. The new-bar guard ensures each signal is evaluated once per candle, and the order goes through TryBuy_EX02030 / TrySell_EX02030 with three retries on transient price errors.

Exit Signal

There is no in-trade management — no trailing, no break-even, no partial close. Exit happens at the fixed TP (default 60 pips) or fixed SL (default 30 pips) that was submitted with the order, after which HasTrade() clears and the EA is free to fire again. The maximum concurrent position count is one, so a new breakout signal will not close or replace an open trade.

Stop Loss

Fixed stop-loss set at InpStopLoss pips (default 30) below the buy entry or above the sell entry, computed as InpStopLoss * _Point * 10 and submitted with the market order. The 30-pip distance is well below a typical 20-bar XAUUSD range, which is what gives the 1:2 RR with the default 60-pip TP.

Take Profit

Fixed take-profit at InpTakeProfit pips (default 60) above the buy entry or below the sell entry, set on the market order at submission time. Changing InpStopLoss without changing InpTakeProfit shifts the RR ratio: drop SL to 20 and the EA runs at 1:3; raise SL to 60 and it drops to 1:1.

Best For

Tuned for XAUUSD on the M15 chart with a $100 minimum deposit, though the same parameters are explicitly written to work on M5 and H1 as well. The strategy is range-averse: it pays best in sustained directional markets and suffers in chop, so a low-spread ECN broker on XAUUSD during the London / New York session overlap is the cleanest deployment. Set InpUseGMTSessions = true to actually enforce those windows (the default is permissive), and consider raising InpBuffer if your broker's average spread is above 20 points.

Strategy Logic

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

Family: Breakout Magic: 22202030 Version: 2.00

BRIEF: Support/resistance breakout hunter. Scans a lookback window for highest high / lowest low, enters on close beyond the level with a buffer. Fixed lot, fixed SL/TP in pips. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • HasTrade()
  • OnTradeTransaction()
  • DetectGMTOffset_EX02030()
  • ServerToGMT_EX02030()
  • IsMarketOpen_EX02030()
  • InActiveSession_EX02030()
  • IsNewsTime_EX02030()
  • IsSafeToTrade_EX02030()
  • UpdateDailyCounters_EX02030()
  • TryBuy_EX02030()
  • TrySell_EX02030()

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (3 total across 2 groups):

  • [=== GMT Session Filter (Hardening) ===] InpNewYorkEndGMT = 21 // --- Hardening: Capital Protection ---
  • [=== Capital Protection (Hardening) ===] InpCapAmount = 0.0 // Capital cap amount (0=disabled)
  • [=== Capital Protection (Hardening) ===] InpDailyLossLimitPct = 5.0 // --- Hardening: Trade Safety ---
Pseudocode
// Pipsgrowth EX02030 Breakout — Execution Flow (from source analysis)
// Family: Breakout
// Support/resistance breakout hunter. Scans a lookback window for highest high / lowest low, enters on close beyond the level with a buffer. Fixed lot, fixed SL/TP in pips. 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:
M15M5H1

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
InpNewYorkEndGMT21--- Hardening: Capital Protection ---
InpCapAmount0.0Capital cap amount (0=disabled)
InpDailyLossLimitPct5.0--- Hardening: Trade Safety ---
Source Code (.mq5)Open Source
Pipsgrowth_com_EX02030.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX02030 BreakoutHunter — S/R breakout with volume confirmation, full 12-layer stack."

#include <Trade\Trade.mqh>
input group "=== Identity ==="
input int    InpMagicNumber = 22202030;
input string InpTradeComment = "Psgrowth.com Expert_02030";

input group "=== Strategy Parameters ==="
input int    InpLookback    = 20;
input int    InpBuffer      = 5;

input group "=== Risk Management ==="
input double InpLotSize     = 0.10;
input int    InpStopLoss    = 30;
input int    InpTakeProfit  = 60;
CTrade trade; datetime lastBar=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 (Hardening) ===";
input bool    InpUseGMTSessions       = false;
input int     InpLondonStartGMT       = 7;
input int     InpLondonEndGMT         = 16;
input int     InpNewYorkStartGMT      = 12;
input int     InpNewYorkEndGMT        = 21;

// --- Hardening: Capital Protection ---
input group "=== Capital Protection (Hardening) ===";
// InpCapEnabled removed — use InpCapAmount=0 to disable
input double  InpCapAmount            = 0.0;      // Capital cap amount (0=disabled)
input double  InpCapFloor             = 1000.0;
input double  InpMinEquityPct         = 70.0;
input double  InpDailyLossLimitPct    = 5.0;

// --- Hardening: Trade Safety ---
input group "=== Trade Safety (Hardening) ===";
input int     InpMaxTradesPerDay      = 10;
input int     InpMaxConsecLosses      = 5;
input int     InpCooldownHours        = 4;
input bool    InpFilterNews           = true;
input int     InpNewsBufferMinutes    = 30;

int OnInit() {
   trade.SetExpertMagicNumber(InpMagicNumber);
   trade.SetDeviationInPoints(20);

Full source code available on download

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

Tags:ex02030breakoutpipsgrowthfreemt5xauusd

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