Pipsgrowth EX02004 Breakout
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX02004 SafeBreakout XAUUSD 5M — Donchian channel breakout + EMA(50) slope confirm, full 12-layer stack.
Overview
EX02004 is a Donchian channel breakout EA tuned for XAUUSD on the 5-minute chart. It uses a 20-bar channel by default (configurable through InpBreakoutBars), measures the high and low across that window on the most recent closed bar, and watches for the next bar's close to break above the channel high or below the channel low. The break has to clear the channel boundary; merely tapping the line is not a signal. The whole design is "SafeBreakout" in the sense that the trade is never taken on a tick against a fresh level — the close of a finished bar has to confirm that price has actually committed beyond the boundary, which removes most of the fakeouts you get from a naive channel-break system.
On top of the raw channel break, the EA runs a single moving average filter: an EMA(50) on the signal timeframe. For a long signal, the close has to be above the EMA and the EMA has to be flat or rising (current value greater than or equal to its previous bar's value). For a short signal, the close has to be below the EMA and the EMA has to be flat or falling. This is a slope filter as much as a level filter — a bar that breaks the channel but happens to print below a falling EMA on a long setup will be rejected. InpUseMaFilter toggles the whole EMA layer on or off; in production it stays on, but for backtests against choppy periods the operator can switch it off to see how much of the edge comes from the trend filter.
A second trend filter sits on the higher timeframe. The EA carries an EMA(50) on the H1 chart and asks whether the entry price agrees with the H1 trend direction: longs need price above H1 EMA(50), shorts need price below. If the M5 break is bullish but H1 is bearish, the trade is rejected with the reason "HTF-opposing-bull". This single check pulls out a lot of M5 breakouts that would otherwise fail against a stronger counter-trend on the hour. The H1 EMA(50) is implemented as a separate indicator handle (hHTF) so it does not pollute the M5 indicator stack.
Regime classification is the third filter. EX02004 runs a 7-state classifier called from ClassifyRegime() that combines ADX(14), ATR(14) percentile over a 50-bar window, and Bollinger Bands(20, 2.0) width. The states are StrongTrend, WeakTrend, Range, Breakout, Compress, Expand, and Choppy. A few transitions matter for entries: when the ATR is in the bottom 25th percentile of its 50-bar distribution, the regime is Compress and entries are blocked if InpUseRegimeFilter is true; when ADX(14) drops below 18, the regime is Choppy and entries are unconditionally blocked; when ADX is above 25 and ATR is in the top 25th percentile, the regime is Expand. Compress is a soft block (depending on the input), Choppy is a hard block. The other states are informational — they show up in the trade comment but do not gate entries. ManageOpenPositions() additionally force-closes any open position if the regime transitions into Choppy, which is the EA's way of not holding a position through a market that has stopped cooperating.
The position management has four layers, all of which can run on the same bar. First, a one-shot break-even: once price moves 1R in profit (R = initial SL distance in price terms), the stop is moved to entry plus one point. Second, a one-shot partial close at +1R: 50% of the position is closed if the open volume is at least twice the broker's minimum lot. Third, an ATR trailing stop: every tick, the stop is recomputed as current bid/ask minus 2.0 × ATR(14) (or plus 2.0 × ATR for shorts), and the stop is only ever ratcheted in the favorable direction. Fourth, a time exit: any position held for more than 288 M5 bars (24 hours of session time) is closed by TryClose_EX02004(). A signal flip in the opposite direction also forces an exit. Pyramid entries are coded but disabled: MAX_PYRAMID_LEVELS is set to 1, so the EA can only ever hold a single position per symbol at a time.
Sizing is risk-based. With InpRiskPercent = 0.5 (the default), CalcLot() takes 0.5% of effective capital, divides by the per-lot risk at the current SL distance (SL in price / tick size × tick value), and produces a lot size that is then normalized to the broker's lot step, lot min, lot max, and capped at InpMaxLot (default 100.0). If InpRiskPercent is set to zero, the EA falls back to InpFixedLot = 0.01, which is a useful setting for prop-firm challenge accounts where the operator wants to lock the lot size at a known value rather than recompute on every tick. OrderCalcMargin is run before the order is sent: if the order would consume more than the current free margin, the entry is refused. OpenPosition() also retries up to three times on requote/timeout/price-changed, with a 100ms sleep and a rate refresh between attempts.
The safety stack is the most defensive part of the EA. NoTradeGate() runs before every entry and refuses if: InpKillSwitch is on, spread exceeds 400 points (the input is XAUUSD-tuned, where 400 points on a 2-decimal broker equals $0.40 — a wide but not pathological gold spread), the regime is Choppy, the EA already has the maximum concurrent positions (default 1), the realized loss for the day exceeds 3% of effective capital, the cooldown window is active (5 M5 bars after a losing exit), equity has dropped below the 50.0 floor, the market is closed (weekend), a high-impact news event is in the calendar window (30 minutes each side, manual fallback if CalendarValueHistory returns no data), quotes are bad, or the symbol's trade mode is not full. IsSafeToTrade_EX02004() runs a second layer of guards: capital cap (if InpCapCapAmount > 0 and equity exceeds the cap, no new entries), min equity percentage (80% of initial balance — once equity drops 20% from the snapshot at OnInit, the EA refuses all further entries), max trades per day (50), max consecutive losses (3 → 4-hour cooldown enforced by the OnTradeTransaction handler), and the global drawdown kill switch (20% — once hit, all trading is halted and the EA only manages exits).
EX02004 carries its own GMT detection. On OnInit, DetectGMTOffset_EX02004() walks back through H1 bars looking for a weekend gap and computes the broker's GMT offset from the H1 bar that opens at 22:00 on Sunday. The detected offset is stored in g_gmtOffset and used by IsMarketOpen_EX02004() (no Saturday, no Sunday before 22:00 GMT, no Friday after 21:00 GMT) and InActiveSession_EX02004() (active if London 7-16 GMT or New York 12-21 GMT, with Asia 0-7 GMT avoided when InpAvoidAsia is true, which is the default). The session filter is independent of the optional InpUseSessionWindow flag, which is a separate broker-timezone session gate (6:00 to 20:00 broker time). The two overlap, but the GMT session is the live one and the broker-time window is the historical one — leaving the broker-time window off is the typical setting.
The OnTester() function is a custom selection criterion for the MT5 strategy tester. It computes net × profit factor divided by (1 + relative drawdown %), with hard gates: fewer than 30 trades returns 0, profit factor ≤ 0 returns 0, net ≤ 0 returns 0, and drawdown exceeding the InpMaxDDPct (20% by default) returns 0. The shape of the criterion rewards strategies with high net, high profit factor, and low drawdown simultaneously — a typical MT5 genetic optimizer would only reward profit, so this custom criterion pushes the optimizer toward balanced equity curves rather than the high-DD high-profit peaks that overfit.
The trade comment carries the regime name and a confidence number. The confidence is computed inside BreakoutSignal() as: span = channel high - channel low; dist = |close - boundary|; confidence = clamp(dist / span × 100 + 30, 10, 100). A breakout that closes 0.1% above the channel in a channel that is 0.5% wide gets a confidence around 50; a breakout that closes flush with the boundary in a narrow channel gets the floor of 10; a runaway break gets capped at 100. The number is informational — it does not gate the entry — but it shows up in the trade comment and in the strategy tester's deal list, so the operator can sort trades by confidence after a backtest.
For deployment, the EA is dry-run by default (InpDryRun = true), which means OnInit logs the signal and the lot/SL/TP it would have used but does not place the order. This is intentional: the source is shipped dry-run so that anyone loading it onto a live chart sees the signal flow before any real capital is committed. To go live, set InpDryRun = false. The minimum recommended balance is the floor (50.0) plus headroom for one trade's stop-loss at the EA's default risk: with a 0.5% risk on a $500 account, the per-trade dollar risk is $2.50, so a 200-point minimum SL on XAUUSD (the floor when ATR is small) translates to roughly 0.01 lots. The published minDeposit of 100 is enough to clear the floor with headroom for one trade at the default 0.01 fallback lot. The EA also responds to the meta-trader kill switch (InpKillSwitch = true), which is a separate manual off-switch that closes all open positions and blocks any new entries until flipped back.
The code is portable across FX majors if you change the magic and the spread cap — the brief header on line 4 says "Gold/Metals & FX majors (portable)", which is the developer's note that the logic itself is symbol-agnostic. The 400-point spread cap is XAUUSD-tuned; on EURUSD the equivalent cap would be 40-50 points. The HTF EMA(50) on H1 still works on a major — the period constant HTF_TIMEFRAME and HTF_MA_PERIOD are #defines near the top of the file and can be changed if you want a different higher timeframe for a different symbol's typical breakout horizon. The pyramid level cap, the ATR-based stops, and the regime classifier are symbol-agnostic; only the spread cap and the #define constants would need to be reviewed when porting.
Strategy Deep Dive
DonchianChannel() walks the last 20 closed M5 bars to compute the channel high and low, then BreakoutSignal() compares the previous bar's close against those bounds. The signal layer adds an EMA(50) slope check on the signal timeframe plus an H1 EMA(50) agreement check inside ConfirmEntry(). Regime gating happens in ClassifyRegime() which combines ADX(14), ATR(14) percentile over 50 bars, and Bollinger Bands width into a 7-state classifier; Choppy and (optionally) Compress are hard entry blocks. Once a signal is confirmed, the SL is ATR(14) × 1.5 and the TP is ATR(14) × 3.0, giving a 1:2 reward-to-risk ratio with a min-RR gate of 1.5. ManageOpenPositions() runs every tick: at +1R the stop is moved to break-even, 50% is closed (one-shot), and an ATR trailing stop (2.0 × ATR) takes over for the remainder. The OnTradeTransaction handler counts consecutive losses and enforces a 4-hour cooldown after 3 losses, while NoTradeGate() and IsSafeToTrade_EX02004() stack spread, capital, daily-loss, equity, market-hours, and news guards around every new entry attempt.
A long signal fires when the previous bar's close is above the highest high of the prior InpBreakoutBars (default 20) closed M5 bars AND the close is above the EMA(50) with the EMA flat-to-rising. A short signal mirrors that: close below the lowest low, below the EMA(50), EMA flat-to-falling. The break must clear the channel on a closed bar — intra-bar wicks do not count. EX02004 also requires H1 EMA(50) agreement (price above for longs, below for shorts) and refuses entries when the regime classifier returns Choppy, or Compress if the regime filter is on.
Positions are closed on the first of: an opposite-direction breakout signal on the next closed bar; the regime classifier transitioning into Choppy; the position being open for more than 288 M5 bars (24 hours of M5 session time); a manual kill switch flip; or the trade hitting the trailing-stop band. Trade comments include the regime name and a confidence score, so the operator can see which state produced the entry after the fact.
Stop-loss is placed at entry ± 1.5 × ATR(14) price-units, with a hard floor of MIN_SL_POINTS × _Point (200 points) so the broker's stops-level requirement is always met. A one-shot break-even moves the stop to entry + 1 point once price reaches +1R, and from that point onward an ATR trailing stop (2.0 × ATR(14)) takes over, only ever ratcheting in the favorable direction. The trade is also force-closed if the regime transitions to Choppy.
Take-profit is placed at entry ± 3.0 × ATR(14) — exactly twice the SL distance, which produces a 1:2 reward-to-risk ratio at the entry. A 50% partial close fires at +1R if the open volume is at least 2× the broker's minimum lot (one-shot). The remaining half is left to ride the trailing stop. The entry is gated by InpMinRR = 1.5, so if the realized TP/SL ratio at the moment of entry is below 1.5, the trade is refused with reason "RR=x.xx<x.xx".
EX02004 is built for XAUUSD on the 5-minute chart with a minimum recommended balance of $100 (the cap floor is $50, and at the default 0.5% per-trade risk on a 0.01-lot fallback, $100 gives enough headroom for a 200-point minimum stop). It is classified MEDIUM risk because of the 0.5% per-trade default plus a 20% global drawdown kill switch and a 3% daily realized-loss cap. The EA is active during the London 7-16 GMT and New York 12-21 GMT sessions, with the Asian session avoided by default, so it is best run on an ECN or RAW-spread broker with low overnight financing and tight gold spreads — anything above 400 points (0.40 USD on a 2-decimal broker) blocks entries. The default dry-run mode means the EA logs signals without sending orders until InpDryRun is flipped to false, which is the recommended workflow before any live deployment.
Strategy Logic
Pipsgrowth EX02004 Breakout — Strategy Logic Analysis (from .mq5 source)
Family: Breakout
Magic: 22202004
Version: 2.00
BRIEF:
Donchian N-bar channel breakout on last CLOSED bar (close > HH or < LL) confirmed by EMA(50) slope. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester. ATR SL, BE @1R, 50% partial @1R, ATR trailing, opposite-signal/time/session-close exits
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
NormPrice()NormVol()LogV()StopsLevelPrice()EffectiveCapital()DonchianChannel()RegimeName()BreakoutSignal()ConfirmEntry()NoTradeGate()IsNewsBlocking()SymbolCurrencies()- ...and 15 more
INTERNAL CONSTANTS (15 total):
ADR_REGIME_PERIOD= 50 //ATRpercentile window for regimeADX_TREND_THRESHOLD=25.0// >= => trend regimeADX_CHOP_THRESHOLD=18.0// < => choppyATR_PCTILE_COMPRESS=25.0// < pctl => compressATR_PCTILE_EXPAND=75.0// > pctl => expandMA_FILTER_PERIOD= 50 //EMAfilter period (signal side)BREAKOUT_REF_SHIFT= 1 // breakout measured on closed barHTF_MA_PERIOD= 50 // ---SESSION(broker server time) ---SESSION_START_HOUR= 6 // Asia->Europe handover (broker tz)SESSION_END_HOUR= 20 // ---NEWS(manual fallback ifCalendarValueHistoryunavailable) ---NEWS_BUFFER_MIN= 30 // ---EXIT/MANAGE---MAX_BARS_IN_TRADE= 288 // 24h onM5COOLDOWN_AFTER_N_LOSSES= 3 // ---ATR/RISKMODEL---MIN_SL_POINTS= 200 // hard floor for SL distanceMAX_PYRAMID_LEVELS= 1 // 1 = no pyramid
INPUT PARAMETERS (36 total across 8 groups):
- [=== Identity ===]
InpMagic=22202004// Magic number (unique perEA) - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_02004" // Trade comment - [=== Identity ===]
InpDryRun=true// Dry-run (signal+log only, no orders) - [=== Identity ===]
InpKillSwitch=false//KILL: halt all new entries + exits-only - [=== Identity ===]
InpVerbose=true// Verbose logging - [=== Risk & Sizing ===]
InpRiskPercent=0.5// Per-trade risk % of effective capital - [=== Risk & Sizing ===]
InpFixedLot=0.01// Fallback fixed lot when risk=0 - [=== Risk & Sizing ===]
InpDailyLossLimitPC=3.0// Daily realized-loss limit % of effective - [=== Risk & Sizing ===]
InpMaxConcurrent= 1 // Max concurrent positions (this magic) - [=== Risk & Sizing ===]
InpCooldownBars= 5 // Cooldown bars after a losing exit - [=== Risk & Sizing ===]
InpMaxSpreadPts= 400 // Max spread in points (XAUUSD-tuned) - [=== Capital Allocation Cap ===]
InpCapCapAmount=0.0// Capital cap amount (0=disabled,USDequity) - [=== Capital Allocation Cap ===]
InpCapCapFloor=50.0// Floor below which entries are blocked - [=== Signal ===]
InpBreakoutBars= 20 // Donchian lookback (closed bars 1..N) - [=== Signal ===]
InpUseMaFilter=true// RequireEMA(50) side agreement - [=== Regime / Confirm ===]
InpUseRegimeFilter=true// Block entries in choppy regime - [=== Regime / Confirm ===]
InpUseSessionWindow=false// Restrict toSESSION_START..END(broker tz) - [=== Regime / Confirm ===]
InpMinRR=1.5// Minimum reward:risk at entry - [=== Exit / Manage ===]
InpATRMultSL=1.5// SL distance =ATR* mult - [=== Exit / Manage ===]
InpATRMultTP=3.0// TP distance =ATR* mult - [=== Exit / Manage ===]
InpTrailATRMult=2.0// Trail distance =ATR* mult - [=== Hardening:
GMTSessions & Safety ===]InpServerGMTOffset= 0 // ServerGMToffset (0=auto-detect) - [=== Hardening:
GMTSessions & Safety ===]InpLondonStartHour= 7 // London session start (GMT) - [=== Hardening:
GMTSessions & Safety ===]InpLondonEndHour= 16 // London session end (GMT) - [=== Hardening:
GMTSessions & Safety ===]InpNYStartHour= 12 // NY session start (GMT) - [=== Hardening:
GMTSessions & Safety ===]InpNYEndHour= 21 // NY session end (GMT) - [=== Hardening:
GMTSessions & Safety ===]InpAvoidAsia=true// Avoid Asian session - [=== Hardening:
GMTSessions & Safety ===]InpAsiaStartHour= 0 // Asia session start (GMT) - [=== Hardening:
GMTSessions & Safety ===]InpAsiaEndHour= 7 // Asia session end (GMT) - [=== Hardening:
GMTSessions & Safety ===]InpNewsFilter=false// Enable news time filter - [=== Hardening:
GMTSessions & Safety ===]InpNewsFilterMinutes= 15 // News blackout minutes around session opens - [=== Hardening:
GMTSessions & Safety ===]InpMaxTradesPerDay= 50 // Max total trades per day - [=== Hardening:
GMTSessions & Safety ===]InpMinEquityPercent=80.0// Min equity as % of initial balance - [=== Hardening:
GMTSessions & Safety ===]InpMaxConsecLosses= 3 // Max consecutive losses before cooldown - [=== Safety Caps ===]
InpMaxDDPct=20.0// Max total drawdown % (0=disabled, triggers kill switch) - [=== Safety Caps ===]
InpMaxLot=100.0// Maximum lot size cap
// Pipsgrowth EX02004 Breakout — Execution Flow (from source analysis)
// Family: Breakout
// Donchian N-bar channel breakout on last CLOSED bar (close > HH or < LL) confirmed by EMA(50) slope. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester. ATR SL, BE @1R, 50% partial @1R, ATR trailing, opposite-signal/time/session-close exits
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
How to Install This EA on MT5
- 1Download the .mq5 file using the button above
- 2Open MetaTrader 5 on your computer
- 3Click File → Open Data Folder in the top menu
- 4Navigate to MQL5 → Experts and paste the .mq5 file there
- 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
- 6Drag the EA onto an H1 or H4 chart
- 7Set the range detection period, breakout buffer, and lot size in the EA dialog
- 8Enable Allow Algo Trading and click OK
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| InpMagic | 22202004 | Magic number (unique per EA) |
| InpTradeComment | "Psgrowth.com Expert_02004" | Trade comment |
| InpDryRun | true | Dry-run (signal+log only, no orders) |
| InpKillSwitch | false | KILL: halt all new entries + exits-only |
| InpVerbose | true | Verbose logging |
| InpRiskPercent | 0.5 | Per-trade risk % of effective capital |
| InpFixedLot | 0.01 | Fallback fixed lot when risk=0 |
| InpDailyLossLimitPC | 3.0 | Daily realized-loss limit % of effective |
| InpMaxConcurrent | 1 | Max concurrent positions (this magic) |
| InpCooldownBars | 5 | Cooldown bars after a losing exit |
| InpMaxSpreadPts | 400 | Max spread in points (XAUUSD-tuned) |
| InpCapCapAmount | 0.0 | Capital cap amount (0=disabled, USD equity) |
| InpCapCapFloor | 50.0 | Floor below which entries are blocked |
| InpBreakoutBars | 20 | Donchian lookback (closed bars 1..N) |
| InpUseMaFilter | true | Require EMA(50) side agreement |
| InpUseRegimeFilter | true | Block entries in choppy regime |
| InpUseSessionWindow | false | Restrict to SESSION_START..END (broker tz) |
| InpMinRR | 1.5 | Minimum reward:risk at entry |
| InpATRMultSL | 1.5 | SL distance = ATR * mult |
| InpATRMultTP | 3.0 | TP distance = ATR * mult |
| InpTrailATRMult | 2.0 | Trail distance = ATR * mult |
| InpServerGMTOffset | 0 | Server GMT offset (0=auto-detect) |
| InpLondonStartHour | 7 | London session start (GMT) |
| InpLondonEndHour | 16 | London session end (GMT) |
| InpNYStartHour | 12 | NY session start (GMT) |
| InpNYEndHour | 21 | NY session end (GMT) |
| InpAvoidAsia | true | Avoid Asian session |
| InpAsiaStartHour | 0 | Asia session start (GMT) |
| InpAsiaEndHour | 7 | Asia session end (GMT) |
| InpNewsFilter | false | Enable news time filter |
| InpNewsFilterMinutes | 15 | News blackout minutes around session opens |
| InpMaxTradesPerDay | 50 | Max total trades per day |
| InpMinEquityPercent | 80.0 | Min equity as % of initial balance |
| InpMaxConsecLosses | 3 | Max consecutive losses before cooldown |
| InpMaxDDPct | 20.0 | Max total drawdown % (0=disabled, triggers kill switch) |
| InpMaxLot | 100.0 | Maximum lot size cap |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX02004 SafeBreakout XAUUSD 5M — Donchian channel breakout + EMA(50) slope confirm, 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>
//==================== TUNABLE CONSTANTS (#define) ==================
// --- REGIME ---
#define ADR_REGIME_PERIOD 50 // ATR percentile window for regime
#define ADX_REGIME_PERIOD 14
#define ADX_TREND_THRESHOLD 25.0 // >= => trend regime
#define ADX_CHOP_THRESHOLD 18.0 // < => choppy
#define BB_REGIME_PERIOD 20
#define BB_REGIME_DEV 2.0
#define ATR_PCTILE_COMPRESS 25.0 // < pctl => compress
#define ATR_PCTILE_EXPAND 75.0 // > pctl => expand
// --- SIGNAL / FILTER ---
#define MA_FILTER_PERIOD 50 // EMA filter period (signal side)
#define BREAKOUT_REF_SHIFT 1 // breakout measured on closed bar
// --- CONFIRM / HTF ---
#define HTF_TIMEFRAME PERIOD_H1
#define HTF_MA_PERIOD 50
// --- SESSION (broker server time) ---
#define SESSION_START_HOUR 6 // Asia->Europe handover (broker tz)
#define SESSION_END_HOUR 20
// --- NEWS (manual fallback if CalendarValueHistory unavailable) ---
#define NEWS_BUFFER_MIN 30
// --- EXIT / MANAGE ---
#define BREAK_EVEN_AT_R 1.0
#define PARTIAL_TP_AT_R 1.0
#define PARTIAL_TP_RATIO 0.5
#define ATR_TRAIL_PERIOD 14
#define MAX_BARS_IN_TRADE 288 // 24h on M5
#define COOLDOWN_AFTER_N_LOSSES 3
// --- ATR / RISK MODEL ---
#define ATR_SLTP_PERIOD 14
#define MIN_SL_POINTS 200 // hard floor for SL distance
// --- SCALING (pyramid OFF by default) ---
#define MAX_PYRAMID_LEVELS 1 // 1 = no pyramid
//===================================================================
CTrade trade;
CPositionInfo posInfo;
CSymbolInfo sym;
CAccountInfo acc;Full source code available on download
Educational purposes only. Do NOT use with real money. Test on demo accounts only.
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
Markets.com
Exness
IC Markets
Similar Expert Advisors
View All Expert AdvisorsMore Breakout strategy EAs from our library
Pipsgrowth EX02026 Breakout
Pipsgrowth.com EX02026 XAUUSD_M5_Donchian_EA — Donchian breakout with RSI and speed filter, full 12-layer stack.
Pipsgrowth EX02001 Breakout
Pipsgrowth.com EX02001 HFS NS92 XAUUSD 5M — fractal Donchian breakout with RSI extreme filter, full 12-layer stack.
Pipsgrowth EX02027 Breakout
Pipsgrowth.com EX02027 EX8 Multi-Symbol VWAP+KAMA Donchian — multi-symbol scalper with ADX regime switch, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.