Pipsgrowth EX02020 Breakout
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX02020 AdvancedDonchianEA_copy — Advanced Donchian breakout with multi-indicator confirmation, full 12-layer stack.
Overview
Pipsgrowth EX02020 ships as a Donchian-style breakout framework wrapped in a complete, twelve-layer trade-management stack. Reading the source from the top down makes one thing clear immediately: the four indicator hooks that drive the breakout decision — GetEntrySignal(), GetExitSignal(), GetIndicatorStopLoss(), and GetIndicatorTakeProfit() — are placeholders that return SIGNAL_NONE, false, and 0.0 respectively. As published, the EA will not open a single position on its own. What the file does deliver, in great detail, is the surrounding infrastructure that any breakout signal would need to be tradable on a real account: a hard stop-loss ladder, a ratcheting trailing stop, a breakeven move, a dynamic profit-lock ratchet, an end-of-day force-close, a Forex Factory news gate, a three-slot session clock, a GMT offset detector, a drawdown governor, a consecutive-loss cooldown, a capital cap with a floor, daily and weekly realized-PnL accounting, and a margin pre-checked, three-retry order sender. The file's brief promises a Donchian channel breakout for XAUUSD on M5; the runtime delivers every part of that promise except the price-channel calculation itself, which is left to the developer to fill in.
The trade-management engine is the heart of this EA. On every tick, after the initial conditions pass (trading allowed, EA not stopped), HandleSessionAndTimeManagement() walks the three session slots, sets minutes_until_session_end and the pause/force-close flags, and either lets trading proceed or returns false to halt the cycle. When trading is allowed, ManageOpenPositions() iterates every position whose magic equals InpMagicNumber=22202020 and the symbol equals _Symbol, then chains ManageSLTP() → ManageTrailingAndBreakeven() → ManageProfitLock() → ManageTimeBasedExit() → ManageSignalBasedExit(). Each of those helpers is a thin wrapper around the real worker functions: ApplyHardSL_TP_IfNotSet() first tries the indicator SL/TP hooks (which return 0.0), then falls back to InpHardSL_Points=50 for the stop and InpFixedTP_Points=100 for the target. ApplyTrailingStop() activates once price has moved InpTrailingStop_Points=20 in profit and only ratchets the stop in 5-point steps. ApplyBreakEven() moves the stop to entry plus InpBreakEvenLockPoints=2 once profit reaches InpBreakEvenTriggerPoints=30. ApplyProfitLock() is gated off by default (InpUseProfitLock=false) but, when enabled, it pulls the stop every InpProfitLockStepPoints=20 of further profit, sitting InpProfitLockSecurePoints=10 behind price. CheckTimeBasedSL() is also gated off (InpUseTimeBasedSL=false); flipping it to true with InpTimeBasedSLMinutes=120 will close any position older than two hours regardless of profit.
The entry side is where this EA is most unusual. ProcessSignalAndOpenTrade() calls GetEntrySignal() once per tick and bails if the return is SIGNAL_NONE — which is the only possible return from the published file. OpenTradeWithSignal() then computes the lot via CalculateLotSize() (fixed InpLotSize=0.01 by default, or auto-scaled where InpAutoLot_Increment=0.01 per InpAutoLot_CapitalPerIncrement=1000 of equity, clamped to InpAutoLot_MinAllowedLot=0.01 and InpAutoLot_MaxAllowedLot=10.0), builds the SL and TP from the indicator hooks, and routes the order to OpenMarketOrder(). The order function checks OrderCalcMargin against free margin, applies a StopsLevel guard (the SL/TP are widened to StopsLevel + InpMaxSlippage + 1 points if the broker's minimum stops distance would otherwise reject them), then sends with up to three retries on TRADE_RETCODE_REQUOTE, _TIMEOUT, _PRICE_OFF, and _PRICE_CHANGED, sleeping 200 ms between attempts. For a developer filling in the four Get*() hooks with real Donchian math, this entire path is ready to use as-is.
Safety gates are layered. Before any signal is even read, CheckTradeFilters() runs the Forex Factory news check (IsForexFactoryNewsEventActive(), which WebRequests the XML feed https://nfs.faireconomy.media/ff_calendar_thisweek.xml, parses <event> blocks via ParseFFNews(), and matches the base/quote currency — or the literal ALL tag — against an InpNewsBufferMinutes=30 window; results are cached for 10 minutes), then IsTradingDayAllowed() (Mon–Fri by default via InpTradingDays=TRADING_DAYS_MON_TO_FRI), then IsDrawdownLimitOk() (which compares Balance − Equity to InpMaxDrawdownPercent=20.0% and InpMaxDrawdownAmount=0.0, with the amount check off). The hardening block then applies the optional capital cap (InpCapAmount=0.0 means disabled; when set, the effective capital is min(cap, equity) and a hard pause fires if it falls below InpCapFloor=1000.0), an equity floor (InpMinEquityPct=70.0 of g_initialBalance), and a realized-today loss limit (InpDailyLossLimitPct=5.0 of the initial balance). CanOpenNewTrade() then enforces InpOneTradeOnly=true / InpMaxOpenTrades=1, the daily trade counter (InpMaxTradesPerDay=5), the bars-between-trades gate (InpMinBarsBetweenTrades=1), the g_pause_until_time cooldown set by UpdateConsecutiveLossesAndPause() after InpMaxConsecutiveLosingTrades=3 consecutive losses (60-minute pause via InpPauseMinutesAfterLosingStreak), the per-direction profit check (InpAllowOnlyProfitableAdditions=true requires every existing position of the same direction to be at least InpMinProfitPerTradeToAdd=5.0 points in the black), and the spread ceiling (InpMaxSpreadPoints=10). A second session gate sits behind that: when InpUseGMTSessions=true, InActiveSession_EX02020() translates server time to GMT via DetectGMTOffset_EX02020() (a best-of heuristic over offsets −12..+12, scoring weekday 1–5 at +10 and hour 7–21 at +5) and only allows trading when GMT hour falls in InpLondonStartGMT=7..InpLondonEndGMT=16 or InpNewYorkStartGMT=12..InpNewYorkEndGMT=21.
The lot-routing math itself is worth understanding. CalculateLotSize() returns the fixed InpLotSize=0.01 when InpLotSizingMethod=LOT_FIXED; when flipped to LOT_AUTO_SCALED, it picks account.Balance() or account.Equity() per InpAutoLotBaseType (default BASE_ACCOUNT_EQUITY), divides by InpAutoLot_CapitalPerIncrement=1000, multiplies by InpAutoLot_Increment=0.01, and clamps to the [InpAutoLot_MinAllowedLot, InpAutoLot_MaxAllowedLot] window. The result is then floored to the broker's LotsStep, clamped again to the broker's LotsMin and LotsMax, and rejected with an error log if it ends up below LotsMin. OnTradeTransaction() tracks the realized PnL of every closed deal for the magic, increments g_realizedToday and g_realizedWeek, and feeds the close-PnL to UpdateConsecutiveLossesAndPause() for the cooldown logic. A custom OnTester() returns profit × profitFactor / maxDD when the trade count is at least 10, otherwise 0 — a single-number fitness score for the MT5 optimizer.
The honest summary: Pipsgrowth EX02020 is best treated as a customizable breakout shell. It is feature-complete on the management side — every parameter a serious XAUUSD trader would want for stops, time exits, news, sessions, drawdown, and capital protection is present and exposed as an input. The signal side, however, is a developer hook. Anyone planning to run this on a live account needs to either replace the four Get* functions with real Donchian (or other breakout) logic, or wire them to iCustom / iHighest / iLowest calls against the channel of their choice. Once that is done, the rest of the file is ready to go and the published defaults form a reasonable starting point: $0.01 lot, 50-point hard stop, 100-point take profit, 20/5 trailing, 30/2 breakeven, 3-loss 60-min cooldown, 5% daily realized cap, 20% drawdown governor, and London/New York session windows. Pipsgrowth publishes the entire source so a competent MQL5 developer can read the placeholder hooks, drop in their own breakout math, and ship a working EA in an afternoon.
Strategy Deep Dive
The published source is a trade-management shell. Each tick begins with CheckInitialConditions() (trading allowed, EA not stopped), then HandleSessionAndTimeManagement() walks the three session slots and force-close windows, and ManageOpenPositions() chains SL/TP → trailing/BE → profit lock → time SL → signal exit across every position whose magic equals 22202020. CheckTradeFilters() then runs the Forex Factory news XML gate (cached 10 minutes, with InpNewsBufferMinutes=30 buffer around the event), the trading-day mask, the drawdown governor, the consecutive-loss cooldown, the daily-trade cap, the per-direction profitability filter, and the spread ceiling. If everything is green, ProcessSignalAndOpenTrade() calls GetEntrySignal() — and because that function returns SIGNAL_NONE in the published file, the EA sits idle until a developer fills in the four Get* hooks with real breakout math. Order execution is robust: OrderCalcMargin pre-check, StopsLevel guard, and a three-retry 200ms loop on requote/timeout/price-off/price-changed. OnTradeTransaction() accumulates daily and weekly realized PnL and drives the InpMaxConsecutiveLosingTrades=3 → 60-minute pause logic. OnTester() returns profit × profitFactor / maxDD for the MT5 optimizer (zero when trades < 10).
Entry is driven by the GetEntrySignal() hook on every tick. In the published source this function is a placeholder that returns SIGNAL_NONE, so no orders are generated until a developer replaces it with a real Donchian (or other) breakout calculation. The file documents the intended behavior — channel-breakout entries for XAUUSD M5 with full confirmation, regime, and risk layers — but the price-channel math itself is left for the implementer.
Exits are managed exclusively by the trade-management chain, since GetExitSignal() is also a placeholder. The pipeline runs ApplyHardSL_TP_IfNotSet() (50-point hard stop, 100-point take profit by default), ApplyTrailingStop() (ratchets the stop in 5-point steps once price is 20 points in profit), ApplyBreakEven() (moves the stop to entry + 2 points at 30 points of profit), ApplyProfitLock() (gated off by default; when on, sits 10 points behind price and steps every 20 points), CheckTimeBasedSL() (off by default; closes any position older than 120 minutes), and ManageSignalBasedExit() (which would honor a future indicator exit).
Per-trade stop is InpHardSL_Points=50 (5 pips on a 5-digit XAUUSD broker), set in ApplyHardSL_TP_IfNotSet(). The breakeven move fires at 30 points of profit and locks 2 points (InpBreakEvenTriggerPoints=30, InpBreakEvenLockPoints=2). An optional ATR-based stop is wired through InpUseATRStop=false with InpATR_SL_Period=14 and InpATR_SL_Multiplier=2.0, but the indicator hook that would supply it currently returns 0.0. The portfolio-level stop is a 20% drawdown governor (InpMaxDrawdownPercent=20.0) that pauses all new entries when Balance − Equity reaches that threshold.
Per-trade target is InpFixedTP_Points=100 (10 pips on a 5-digit XAUUSD broker), giving a default 2:1 reward-to-risk against the 50-point hard stop. There is no dynamic TP scaling — GetIndicatorTakeProfit() is a placeholder that returns 0.0. A partial-close helper (TryClosePartial_EX02020) is present in the source with a 3-retry 200ms loop, ready to be wired into the entry path once the signal layer is implemented.
Minimum recommended balance: $100 (the source validates this against mySymbol.LotsMin() × the fixed InpLotSize=0.01). The EA is purpose-built for XAUUSD on M5 — the magic is 22202020, the comment string is Psgrowth.com Expert_02020, and the SL/TP defaults (50 / 100 points) are sized for gold on a 5-digit broker. Run it on a low-spread ECN or RAW account (the spread ceiling of InpMaxSpreadPoints=10 will reject most market-maker quotes on gold) and during the London and New York sessions (the GMT gates 07–16 and 12–21 align with the deepest gold liquidity).
Strategy Logic
Pipsgrowth EX02020 Breakout — Strategy Logic Analysis (from .mq5 source)
Family: Breakout
Magic: 22202020
Version: 2.00
BRIEF:
Advanced Donchian channel breakout EA with comprehensive money management, session control, smart exit timing, and multi-indicator confirmation for XAUUSD. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
StringToTime()Log()ParseFFDateTime()ExtractTag()ParseFFNews()InitializeTradeObjects()ResetStateVariables()ValidateInputParameters()ValidateLotSettings()ValidateRiskSettings()ValidateSessionSettings()ValidateNewsSettings()- ...and 45 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (81 total across 10 groups):
- [===
GMTSessionFilter(Hardening) ===]InpNewYorkEndGMT= 21 // --- Hardening: Capital Protection --- - [=== Capital
Protection(Hardening) ===]InpCapAmount=0.0// Capital cap amount (0=disabled) - [=== Trade Settings ===]
InpLotSize=0.01// Fixed LotSize(ifLotSizingMethodisLOT_FIXED) - [=== Trade Settings ===]
InpMagicNumber=22202020// Magic Number for orders (unique identifier for thisEA) - [=== Trade Settings ===]
InpTradeComment= "Psgrowth.com Expert_02020" // TradeComment - [=== Trade Settings ===]
InpMaxSlippage= 5 // Slippage in points (max allowed price deviation) - [=== Trade Settings ===]
InpMaxSpreadPoints= 10 // Maximum allowed spread in points (0 for no check) - [=== Trade Settings ===]
InpOneTradeOnly=true// Allow only one trade at a time (per symbol for thisEA) - [=== Trade Settings ===]
InpMaxOpenTrades= 1 // Maximum allowed open trades at the same time - [=== Trade Settings ===]
InpAllowOnlyProfitableAdditions=true// Only open new trades if all existing (by thisEA) are in profit - [=== Trade Settings ===]
InpMinProfitPerTradeToAdd=5.0// Min. profit in points for each existing trade to open new one - [=== Trade Settings ===]
InpMaxDrawdownPercent=20.0// Max drawdown % allowed (0 to disable) - [=== Trade Settings ===]
InpMaxDrawdownAmount=0.0// Max drawdown amount in account currency (0 to disable) - [=== Trade Settings ===]
InpMaxTradesPerDay= 5 // Max trades per day (0 for unlimited) - [=== Trade Settings ===]
InpMinBarsBetweenTrades= 1 // Min bars between opening new trades - [=== Trade Settings ===]
InpMaxConsecutiveLosingTrades= 3 // Pause trading after this many consecutive losses (0 to disable) - [=== Trade Settings ===]
InpPauseMinutesAfterLosingStreak= 60 // Minutes to pause after reaching losing streak - [=== Trade Settings ===]
InpAvoidTradingDuringNews=false// Avoid trading during news events - [=== Trade Settings ===]
InpNewsBufferMinutes= 30 // Minutes before and after news to avoid trading - [=== Trade Settings ===]
InpAvoidTradingDuringHighImpactNews=true// Avoid high impact news - [=== Trade Settings ===]
InpAvoidTradingDuringMediumImpactNews=false// Avoid medium impact news - [=== Trade Settings ===]
InpAvoidTradingDuringLowImpactNews=false// Avoid low impact news - [=== Trade Settings ===]
InpNewsTimeZoneOffsetHours= 0 // Offset in hours fromUTC(e.g., 2 forUTC+2, -5 forUTC-5) - [=== Trade Settings ===]
InpNewsSource=NEWS_SOURCE_FOREX_FACTORY// News source for news filtering - [=== Money Management & Lot Sizing ===]
InpLotSizingMethod=LOT_FIXED// Lot Sizing Method - [=== Money Management & Lot Sizing ===]
InpAutoLotBaseType=BASE_ACCOUNT_EQUITY// Capital base for auto lot calculation - [=== Money Management & Lot Sizing ===]
InpAutoLot_Increment=0.01// Lot size to add (e.g.,0.01) - [=== Money Management & Lot Sizing ===]
InpAutoLot_CapitalPerIncrement= 1000 // For every X amount of capital - [=== Money Management & Lot Sizing ===]
InpAutoLot_MaxAllowedLot=10.0// Maximum lot size allowed by auto calculation - [=== Money Management & Lot Sizing ===]
InpAutoLot_MinAllowedLot=0.01// Minimum lot size allowed by auto calculation - [=== Money Management & Lot Sizing ===]
InpOrderType=ORDER_TYPE_BUY_SELL// Order type - [=== Stop Loss Management ===]
InpUseHardSL=true// Enable Hard Stop Loss - [=== Stop Loss Management ===]
InpHardSL_Points= 50 // Fixed Stop Loss in points (0 to disable) - [=== Stop Loss Management ===]
InpUseTrailingStop=true// Enable Trailing Stop - [=== Stop Loss Management ===]
InpTrailingStop_Points= 20 // Trailing Stop activation in points of profit - [=== Stop Loss Management ===]
InpTrailingStep_Points= 5 // Trailing Stop step in points - [=== Stop Loss Management ===]
InpUseATRStop=false// UseATR-based stop loss (Placeholder for indicator logic) - [=== Stop Loss Management ===]
InpATR_SL_Period= 14 //ATRperiod for SL calculation - [=== Stop Loss Management ===]
InpATR_SL_Multiplier=2.0//ATRmultiplier for SL - [=== Stop Loss Management ===]
InpMoveSLToBreakEven=true// Move SL to breakeven after X points - [=== Stop Loss Management ===]
InpBreakEvenTriggerPoints= 30 // Points in profit to trigger breakeven move - [=== Stop Loss Management ===]
InpBreakEvenLockPoints= 2 // Lock X points profit at breakeven (e.g., entry + 2 points) - [=== Stop Loss Management ===]
InpUseTimeBasedSL=false// Close trade after X minutes - [=== Stop Loss Management ===]
InpTimeBasedSLMinutes= 120 // Minutes before time-based SL triggers - [=== Take Profit & Profit Management ===]
InpFixedTP_Points= 100 // Fixed Take Profit in points (0 to disable) - [=== Take Profit & Profit Management ===]
InpUseProfitLock=false// Enable dynamic profit locking - [=== Take Profit & Profit Management ===]
InpProfitLockTriggerPoints= 50 // Start locking profit after this many points in profit - [=== Take Profit & Profit Management ===]
InpProfitLockStepPoints= 20 // Move SL every X points further in profit (after trigger) - [=== Take Profit & Profit Management ===]
InpProfitLockSecurePoints= 10 // How many points behind current price to lock (e.g., if price moves 20, SL moves to current - 10) - [=== Take Profit & Profit Management ===]
InpProfitLockOnlyAfterBE=true// Only start profit lock after breakeven is reached - [=== Sessions Control Settings ===]
InpEnableSessionControl=false// Enable sessions control - [=== Sessions Control Settings ===]
InpEnableSession1=true// Enable session 1 - [=== Sessions Control Settings ===]
InpSession1Start= "08:00" // Session 1 start time (HH:MM server time) - [=== Sessions Control Settings ===]
InpSession1End= "16:00" // Session 1 end time (HH:MM server time) - [=== Sessions Control Settings ===]
InpEnableSession2=false// Enable session 2 - [=== Sessions Control Settings ===]
InpSession2Start= "18:00" // Session 2 start time (HH:MM server time) - [=== Sessions Control Settings ===]
InpSession2End= "22:00" // Session 2 end time (HH:MM server time) - [=== Sessions Control Settings ===]
InpEnableSession3=false// Enable session 3 - [=== Sessions Control Settings ===]
InpSession3Start= "00:00" // Session 3 start time (HH:MM server time) - [=== Sessions Control Settings ===]
InpSession3End= "00:00" // Session 3 end time (HH:MM server time) - [=== Sessions Control Settings ===]
InpPauseBeforeEndOfSession=true// Stop opening new trades before end of active session - [=== Sessions Control Settings ===]
InpPauseMinutesBeforeEndOfSession= 30 // Minutes before end of session to pause new trades - [=== Sessions Control Settings ===]
InpForceCloseAllTradesAtSessionEnd=false// Force close all trades at the end of an active session - [=== Sessions Control Settings ===]
InpForceCloseMinutesBeforeSessionEnd= 5 // Minutes before session end to force close - [=== Sessions Control Settings ===]
InpCloseAllTradesAtEndOfDay=false// Close all trades at specificEODtime - [=== Sessions Control Settings ===]
InpEndOfDayCloseTime= "23:50" //EODtime to close all trades (HH:MM server time) - [=== Smart Exit Timing Settings ===]
InpEnableSmartExitManagement=false// Enable Smart ExitManagement(currently simplified) - [=== Smart Exit Timing Settings ===]
InpSmartExitStartMinutesBeforeSessionEnd= 60 // When to start "smartly" managing (e.g., no new trades, check for early profitable close) - [=== Notifications & Logging ===]
InpEnableAlerts=true// Enable Terminal Alerts for important events - [=== Notifications & Logging ===]
InpEnableEmailNotify=false// Enable Email Notifications - [=== Notifications & Logging ===]
InpEnablePushNotify=false// Enable Push Notifications - [=== Notifications & Logging ===]
InpLogTradeEvents=true// Log trade open/close/modify events - [=== Notifications & Logging ===]
InpLogTickEvents=false// Log detailed tick processing (for debugging, can be verbose) - [=== Trading Days Settings ===]
InpTradingDays=TRADING_DAYS_MON_TO_FRI// Days to allow trading - [=== Trading Days Settings ===]
InpTradeMonday=true// Trade on Monday - [=== Trading Days Settings ===]
InpTradeTuesday=true// Trade on Tuesday - [=== Trading Days Settings ===]
InpTradeWednesday=true// Trade on Wednesday - [=== Trading Days Settings ===]
InpTradeThursday=true// Trade on Thursday - [=== Trading Days Settings ===]
InpTradeFriday=true// Trade on Friday - [=== Trading Days Settings ===]
InpTradeSaturday=false// Trade on Saturday - [=== Trading Days Settings ===]
InpTradeSunday=false// Trade on Sunday
// Pipsgrowth EX02020 Breakout — Execution Flow (from source analysis)
// Family: Breakout
// Advanced Donchian channel breakout EA with comprehensive money management, session control, smart exit timing, and multi-indicator confirmation for XAUUSD. 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
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 |
|---|---|---|
| InpNewYorkEndGMT | 21 | --- Hardening: Capital Protection --- |
| InpCapAmount | 0.0 | Capital cap amount (0=disabled) |
| InpLotSize | 0.01 | Fixed Lot Size (if LotSizingMethod is LOT_FIXED) |
| InpMagicNumber | 22202020 | Magic Number for orders (unique identifier for this EA) |
| InpTradeComment | "Psgrowth.com Expert_02020" | Trade Comment |
| InpMaxSlippage | 5 | Slippage in points (max allowed price deviation) |
| InpMaxSpreadPoints | 10 | Maximum allowed spread in points (0 for no check) |
| InpOneTradeOnly | true | Allow only one trade at a time (per symbol for this EA) |
| InpMaxOpenTrades | 1 | Maximum allowed open trades at the same time |
| InpAllowOnlyProfitableAdditions | true | Only open new trades if all existing (by this EA) are in profit |
| InpMinProfitPerTradeToAdd | 5.0 | Min. profit in points for each existing trade to open new one |
| InpMaxDrawdownPercent | 20.0 | Max drawdown % allowed (0 to disable) |
| InpMaxDrawdownAmount | 0.0 | Max drawdown amount in account currency (0 to disable) |
| InpMaxTradesPerDay | 5 | Max trades per day (0 for unlimited) |
| InpMinBarsBetweenTrades | 1 | Min bars between opening new trades |
| InpMaxConsecutiveLosingTrades | 3 | Pause trading after this many consecutive losses (0 to disable) |
| InpPauseMinutesAfterLosingStreak | 60 | Minutes to pause after reaching losing streak |
| InpAvoidTradingDuringNews | false | Avoid trading during news events |
| InpNewsBufferMinutes | 30 | Minutes before and after news to avoid trading |
| InpAvoidTradingDuringHighImpactNews | true | Avoid high impact news |
| InpAvoidTradingDuringMediumImpactNews | false | Avoid medium impact news |
| InpAvoidTradingDuringLowImpactNews | false | Avoid low impact news |
| InpNewsTimeZoneOffsetHours | 0 | Offset in hours from UTC (e.g., 2 for UTC+2, -5 for UTC-5) |
| InpNewsSource | NEWS_SOURCE_FOREX_FACTORY | News source for news filtering |
| InpLotSizingMethod | LOT_FIXED | Lot Sizing Method |
| InpAutoLotBaseType | BASE_ACCOUNT_EQUITY | Capital base for auto lot calculation |
| InpAutoLot_Increment | 0.01 | Lot size to add (e.g., 0.01) |
| InpAutoLot_CapitalPerIncrement | 1000 | For every X amount of capital |
| InpAutoLot_MaxAllowedLot | 10.0 | Maximum lot size allowed by auto calculation |
| InpAutoLot_MinAllowedLot | 0.01 | Minimum lot size allowed by auto calculation |
| InpOrderType | ORDER_TYPE_BUY_SELL | Order type |
| InpUseHardSL | true | Enable Hard Stop Loss |
| InpHardSL_Points | 50 | Fixed Stop Loss in points (0 to disable) |
| InpUseTrailingStop | true | Enable Trailing Stop |
| InpTrailingStop_Points | 20 | Trailing Stop activation in points of profit |
| InpTrailingStep_Points | 5 | Trailing Stop step in points |
| InpUseATRStop | false | Use ATR-based stop loss (Placeholder for indicator logic) |
| InpATR_SL_Period | 14 | ATR period for SL calculation |
| InpATR_SL_Multiplier | 2.0 | ATR multiplier for SL |
| InpMoveSLToBreakEven | true | Move SL to breakeven after X points |
| InpBreakEvenTriggerPoints | 30 | Points in profit to trigger breakeven move |
| InpBreakEvenLockPoints | 2 | Lock X points profit at breakeven (e.g., entry + 2 points) |
| InpUseTimeBasedSL | false | Close trade after X minutes |
| InpTimeBasedSLMinutes | 120 | Minutes before time-based SL triggers |
| InpFixedTP_Points | 100 | Fixed Take Profit in points (0 to disable) |
| InpUseProfitLock | false | Enable dynamic profit locking |
| InpProfitLockTriggerPoints | 50 | Start locking profit after this many points in profit |
| InpProfitLockStepPoints | 20 | Move SL every X points further in profit (after trigger) |
| InpProfitLockSecurePoints | 10 | How many points behind current price to lock (e.g., if price moves 20, SL moves to current - 10) |
| InpProfitLockOnlyAfterBE | true | Only start profit lock after breakeven is reached |
| InpEnableSessionControl | false | Enable sessions control |
| InpEnableSession1 | true | Enable session 1 |
| InpSession1Start | "08:00" | Session 1 start time (HH:MM server time) |
| InpSession1End | "16:00" | Session 1 end time (HH:MM server time) |
| InpEnableSession2 | false | Enable session 2 |
| InpSession2Start | "18:00" | Session 2 start time (HH:MM server time) |
| InpSession2End | "22:00" | Session 2 end time (HH:MM server time) |
| InpEnableSession3 | false | Enable session 3 |
| InpSession3Start | "00:00" | Session 3 start time (HH:MM server time) |
| InpSession3End | "00:00" | Session 3 end time (HH:MM server time) |
| InpPauseBeforeEndOfSession | true | Stop opening new trades before end of active session |
| InpPauseMinutesBeforeEndOfSession | 30 | Minutes before end of session to pause new trades |
| InpForceCloseAllTradesAtSessionEnd | false | Force close all trades at the end of an active session |
| InpForceCloseMinutesBeforeSessionEnd | 5 | Minutes before session end to force close |
| InpCloseAllTradesAtEndOfDay | false | Close all trades at specific EOD time |
| InpEndOfDayCloseTime | "23:50" | EOD time to close all trades (HH:MM server time) |
| InpEnableSmartExitManagement | false | Enable Smart Exit Management (currently simplified) |
| InpSmartExitStartMinutesBeforeSessionEnd | 60 | When to start "smartly" managing (e.g., no new trades, check for early profitable close) |
| InpEnableAlerts | true | Enable Terminal Alerts for important events |
| InpEnableEmailNotify | false | Enable Email Notifications |
| InpEnablePushNotify | false | Enable Push Notifications |
| InpLogTradeEvents | true | Log trade open/close/modify events |
| InpLogTickEvents | false | Log detailed tick processing (for debugging, can be verbose) |
| InpTradingDays | TRADING_DAYS_MON_TO_FRI | Days to allow trading |
| InpTradeMonday | true | Trade on Monday |
| InpTradeTuesday | true | Trade on Tuesday |
| InpTradeWednesday | true | Trade on Wednesday |
| InpTradeThursday | true | Trade on Thursday |
| InpTradeFriday | true | Trade on Friday |
| InpTradeSaturday | false | Trade on Saturday |
| InpTradeSunday | false | Trade on Sunday |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX02020 AdvancedDonchianEA_copy — Advanced Donchian breakout with multi-indicator confirmation, full 12-layer stack."
#include <Trade/Trade.mqh>
#include <Trade/AccountInfo.mqh>
#include <Trade/SymbolInfo.mqh>
// --- Global Variables ---
CTrade trade; // Trade object for order execution
CAccountInfo account; // Account info object for balance, equity, etc.
CSymbolInfo mySymbol; // Symbol info object for spread, lot size, etc.
// EA State Variables
long g_last_trade_bar_time = 0; // Time of last trade (for min bars between trades)
int g_consecutive_losses = 0; // Counter for consecutive losing trades
datetime g_pause_until_time = 0; // Time until which trading is paused after loss streak
int g_daily_trades_count = 0; // Number of trades opened today
datetime g_last_daily_trades_reset_time = 0; // Last reset time for daily trades count
//--- Hardening Globals
int g_gmtOffset = 3;
double g_initialBalance = 0.0;
double g_realizedToday = 0.0;
double g_realizedWeek = 0.0;
datetime g_dayStartTime = 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;
string g_cached_news_xml = "";
datetime g_last_news_fetch_time = 0;
int g_news_cache_minutes = 10; // Cache for 10 minutes
// --- Input Parameters ---
//--- Trade Settings
input group "=== Trade Settings ==="
input double InpLotSize = 0.01; // Fixed Lot Size (if LotSizingMethod is LOT_FIXED)
input ulong InpMagicNumber = 22202020; // Magic Number for orders (unique identifier for this EA)
input string InpTradeComment = "Psgrowth.com Expert_02020"; // Trade Comment
input int InpMaxSlippage = 5; // Slippage in points (max allowed price deviation)
input int InpMaxSpreadPoints = 10; // Maximum allowed spread in points (0 for no check)
input bool InpOneTradeOnly = true; // Allow only one trade at a time (per symbol for this EA)
input int InpMaxOpenTrades = 1; // Maximum allowed open trades at the same time
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.