P
PipsGrowth
BreakoutOpen Source – Free

Pipsgrowth EX02008 Breakout

MT5 Expert Advisor (Open Source) · XAUUSD · M5

Pipsgrowth.com EX02008 GB10 Donchian XAUUSD 5M — inline Donchian channel breakout, full 12-layer stack.

Overview

Pipsgrowth EX02008 Breakout is a Donchian-channel breakout system for XAUUSD on the 5-minute chart, built around a self-contained channel rather than a built-in indicator. The EA rebuilds the upper and lower Donchian band on every evaluation by reading price history through CopyHigh() and CopyLow() over a configurable lookback (default InpLength = 20 bars), then it trades when a closed 5-minute candle breaks outside that channel. Magic number 22202008, version 2.00, 59 input parameters, 34 custom functions. The full source is provided as Pipsgrowth_com_EX02008.mq5 and has no DLL dependencies.

The Donchian signal is the heart of the strategy. DonchianSignal() reads the upper band, lower band, and midpoint of the most recent closed bar (shift 1) and compares them to the same measures one bar earlier (shift 2). A long setup requires close > upper band, an upward-sloping midpoint (if InpUseSlopeFilter is on), a body/range ratio of at least InpStrongCandleRatio = 0.6 on the breakout bar, and a close that is at least InpBreakoutATR = 0.3 × ATR(14) beyond the channel midline. A short setup mirrors those conditions. The returned signal also carries a confidence score computed as 50 + 50 × (body / range) of the breakout candle, capped at 100. Confidence is logged in the entry print but does not gate the trade — it exists for your own monitoring and post-hoc analysis.

The regime classifier overlays a permission layer on top of the signal. ClassifyRegime() reads ADX(14), ATR(14), and Bollinger Bands(20, 2.0) to label the market as one of seven states: STRONG_TREND, WEAK_TREND, RANGE, BREAKOUT, COMPRESS, EXPAND, or CHOPPY. The strongest conditions (ADX ≥ 25 and ATR percentile ≥ 60) are tagged STRONG_TREND. The breakout-eligible case fires when ADXInpADXMinBreakout = 18 and the current ATR sits in the upper half of the last 100 bars (InpATRPctMinBreakout = 50). Compression (low Bollinger-band width) and choppiness (low ADX) are explicit no-trade states. The classifier feeds NoTradeReason(), which short-circuits new entries when the regime is CHOPPY or RANGE, when the daily loss cap (InpMaxDailyLossPct = 3%) is breached, when the weekly cap (InpMaxWeeklyLossPct = 9%) is breached, or when the equity-floor is below InpCapitalCapFloor = 50.

Higher-timeframe agreement is enforced when InpRequireHTFAgree is on (default true). HTFTrend() looks at the close and open of the H1 bar (the InpHTF = 7 setting maps to H1 via MapTimeframe_EX02008) and only approves a long signal when the close is above the open five bars back, and vice versa. The default timeframe is H1, but it is one input away from M15, M30, or H4 if your backtest wants a different bias.

Risk and trade management are tightly written. Stop-loss is ATR(14) × InpATRStopMult (default 2, so 2× ATR = 1R) and take-profit is ATR(14) × InpATRTPMult (default 4, so 4× ATR = 2R). MinRROK() enforces a minimum reward:risk in tenths via InpMinRR = 12 (1.2R) before the order is sent. Lot size is computed from InpRiskPercent = 0.5% of the effective capital divided by the per-lot stop distance, then normalized to the broker's lot step and capped at InpMaxLot = 10.0. Effective capital itself is min(account_equity, InpCapitalCapAmount) — the capital cap defaults to $500, so a $5,000 account trades as if it were $500 until you raise that input. This is a deliberate design choice to keep micro-account behaviour consistent across account sizes.

In-trade management runs on every tick inside ManageOpenPositions(). At +1R the stop moves to break-even (InpUseBreakEven = true). At the same +1R milestone, half the position is closed if the remaining volume is still at least twice the broker minimum (InpUsePartialTP = true). After the trade is in profit and past open price, an ATR-based trailing stop of 2 × ATR(14) only ratchets forward, never backward. Three additional exit conditions sit on top: an opposite Donchian signal closes the trade (InpExitOppositeSignal), a regime flip to CHOPPY or RANGE closes the trade (InpExitRegimeChange), and a time exit at InpMaxBarsInTrade = 240 bars (20 hours on M5) closes any position that has not resolved. Pyramid scaling is implemented but disabled by default; when InpUsePyramid is flipped on, PyramidAllowed() allows up to InpPyramidMaxLevels = 3 adds separated by at least 1.5 × ATR of favourable movement.

The safety stack sits behind every entry attempt. IsSafeToTrade_EX02008() checks: GMT hours (London 7–16, New York 12–21), weekend closure (no Sat, no Sun), high-impact news window (InpUseNewsWindow = true, 15 minutes before and after), maximum spread (InpMaxSpreadPoints = 35 points), minimum equity (InpMinEquityPct = 70% of initial balance), maximum daily trade count (InpMaxTradesPerDay = 10), and a global drawdown circuit breaker (InpMaxDDPct = 20% of initial balance). Consecutive losses are tracked in OnTradeTransaction: at 3 losses the EA applies a 60-minute cooldown (InpCooldownLosses, InpCooldownMinutes), and at 5 losses a 4-hour cooldown kicks in (InpMaxConsecLosses, InpCooldownHours). The dry-run flag InpDryRun defaults to true — set it to false before attaching to a live or demo account with order routing.

Execution and broker notes. Order send retries up to three times on requote, timeout, price-changed, and price-off responses, with a 150 ms back-off between attempts. Close, partial close, and modify operations also have a 3-attempt loop with 100–200 ms back-off. Stop levels are read from the broker's SYMBOL_TRADE_STOPS_LEVEL and respected even if the user-defined SL would violate them; if that happens the SL is widened to the minimum distance. OrderCalcMargin() is called before the send to reject orders the account cannot afford. XAUUSD on a 5-minute chart is a spread-sensitive strategy, so the EA expects a low-spread ECN or RAW account. Standard cent or high-spread accounts will trigger the spread guard on most breakouts and produce very few fills. The Strategy Tester fitness function is (netProfit × profitFactor) / (1 + maxBalanceDrawdown), with hard gates on at least 30 trades, positive net profit, and equity drawdown ≤ InpMaxDDPct.

What to expect in a backtest. With InpCapitalCapAmount = 500 the strategy is sized for micro accounts and prop-firm challenges. The default parameters assume XAUUSD price action that moves 1–3× ATR(14) per hour during London and the London–New York overlap; quiet Asian-session breakouts will be filtered out by both the regime classifier and the session guard. If you see the backtest produce very few trades, lower InpADXMinBreakout or widen the session hours; if you see it overtrade, tighten the ADX threshold and reduce InpMaxTradesPerDay.

Strategy Deep Dive

Each tick the EA re-reads the upper and lower Donchian band by walking the most recent 20 M5 bars through CopyHigh() and CopyLow(), then evaluates the most recent closed bar against the prior bar: close must be outside the band, the body/range must be at least 0.6, the midpoint must be sloping in the breakout direction, and the close must sit at least 0.3×ATR(14) beyond the midline. The result runs through NoTradeReason(), which checks the regime classifier (only STRONG_TREND, WEAK_TREND, BREAKOUT, EXPAND survive; CHOPPY and RANGE block), the H1 close-vs-open trend agreement, the 35-point spread ceiling, the 3%/9% daily/weekly loss caps, the $50 equity floor, and a one-bar dedup so the EA cannot fire twice on the same candle. Order send retries up to 3 times on requote or price-changed responses; in-trade management runs every tick and chains break-even, partial close, ATR trail, opposite-signal exit, regime-flip exit, and a 240-bar time stop.

Entry Signal

Long entry when the closed M5 bar closes above the upper Donchian band (InpLength=20) with the Donchian midpoint sloping up, a body/range ratio of at least 0.6, and a close that is at least 0.3×ATR(14) beyond the channel midline — and only when the regime classifier is not CHOPPY/RANGE, the spread is below 35 points, the H1 close sits above its open 5 bars back, and effective capital is above the $50 floor. Short entry mirrors the same conditions downward.

Exit Signal

Primary exit is the take-profit at 4×ATR(14) above entry (2R). At +1R the position is half-closed if volume allows, the stop is moved to break-even, and an ATR-based trailing stop of 2×ATR(14) begins to ratchet forward. Three additional exits: an opposite Donchian breakout signal, a regime flip to CHOPPY or RANGE, and a time stop at 240 bars (20 hours on M5).

Stop Loss

Stop-loss is 2×ATR(14) below the entry on a long (1R reference), widened automatically to the broker's SYMBOL_TRADE_STOPS_LEVEL if the broker minimum is larger. The stop moves to break-even at +1R, and the ATR trail ratchets it forward only — it never widens.

Take Profit

Take-profit is 4×ATR(14) above the entry on a long (2R). A 50% partial close is taken at +1R when remaining volume is still at least 2× the broker minimum. The minimum R:R is hard-gated at 1.2R before the order is sent, so a tight spread and a healthy ATR are required to get any entry past the gate.

Best For

Minimum recommended balance $100, but the EA caps effective capital at $500 by default so a larger account is sized as if it were $500 — raise InpCapitalCapAmount to unlock more. Best on XAUUSD M5 with a low-spread ECN/RAW broker. Run during the London 7–16 GMT window and the London–New York 12–21 GMT overlap; the Asian session is filtered out by default. Set InpDryRun to false before attaching to a live account.

Strategy Logic

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

Family: Breakout Magic: 22202008 Version: 2.00

BRIEF: Self-contained Donchian breakout. Channel built inline from CopyHigh/CopyLow over lookback window. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester. BE, partial TP, ATR trail

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • AskP()
  • BidP()
  • Pt()
  • Digits_()
  • StopsLvl()
  • FreezeLvl()
  • NormPrice()
  • NormLot()
  • SpreadPts()
  • Donchian()
  • TodayStart()
  • MagicRealizedPnL()
  • ...and 26 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (59 total across 11 groups):

  • [=== Identity ===] InpMagic = 22202008 // Magic number (unique per EA) [1-999999999, step 1]
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_02008" // Trade comment
  • [=== Identity ===] InpEnableLogging = true // Enable non-critical logging
  • [=== Identity ===] InpDryRun = true // Dry-run (signal+log only, no orders)
  • [=== Identity ===] InpKillSwitch = false // KILL: halt all new entries
  • [=== Donchian Core ===] InpLength = 20 // Donchian period (bars) [2-200, step 1]
  • [=== Donchian Core ===] InpBreakoutATR = 0.3 // Min excursion beyond band (x ATR) [0.0-2.0, step 0.05]
  • [=== Donchian Core ===] InpUseSlopeFilter = true // Filter on Donchian middle slope
  • [=== Donchian Core ===] InpStrongCandleRatio = 0.6 // Min body/range ratio of breakout bar [0.0-1.0, step 0.05]
  • [=== Donchian Core ===] InpHTFBarShift = 1 // HTF bar shift for trend (1 = last closed) [1-10, step 1]
  • [=== Regime Filter ===] InpADXPeriod = 14 // ADX period [2-100, step 1]
  • [=== Regime Filter ===] InpADXMinBreakout = 18.0 // Min ADX for Breakout/StrongTrend [5-50, step 0.5]
  • [=== Regime Filter ===] InpATRPeriod = 14 // ATR period [2-100, step 1]
  • [=== Regime Filter ===] InpATRPctLookback = 100 // ATR percentile lookback (bars) [20-500, step 10]
  • [=== Regime Filter ===] InpATRPctMinBreakout = 50.0 // Min ATR percentile for Breakout [0-100, step 5]
  • [=== Regime Filter ===] InpBBPeriod = 20 // Bollinger period [2-100, step 1]
  • [=== Regime Filter ===] InpBBDev = 2.0 // Bollinger deviation [0.5-5.0, step 0.1]
  • [=== Regime Filter ===] InpBBWCompressRatio = 0.6 // BBW < avg*ratio => Compress [0.1-1.0, step 0.05]
  • [=== Entry & Triggers ===] InpMaxEntriesPerBar = 1 // Max entries per bar (dedup) [1-10, step 1]
  • [=== Entry & Triggers ===] InpRequireHTFAgree = true // Require HTF trend agreement
  • [=== Entry & Triggers ===] InpHTF = 7 // HTF timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1 [1-9, step 1]
  • [=== Entry & Triggers ===] InpMinRR = 12 // Min reward:risk in tenths (12 = 1.2) [5-50, step 1]
  • [=== Risk & Sizing ===] InpRiskPercent = 0.5 // Risk % per trade [0.1-10.0, step 0.1]
  • [=== Risk & Sizing ===] InpATRStopMult = 2 // SL = ATR x mult [1-10, step 1]
  • [=== Risk & Sizing ===] InpATRTPMult = 4 // TP = ATR x mult [1-20, step 1]
  • [=== Risk & Sizing ===] InpMaxLot = 10.0 // Hard cap on lot size [0.01-100, step 0.01]
  • [=== Risk & Sizing ===] InpMaxDDPct = 20.0 // Max total drawdown % (0=disabled, triggers kill switch)
  • [=== Risk & Sizing ===] InpMaxOpenTrades = 5 // Max concurrent trades [1-20, step 1]
  • [=== Risk & Sizing ===] InpMaxSymbolExposure = 3 // Max positions on this symbol [1-20, step 1]
  • [=== Risk & Sizing ===] InpMaxDailyLossPct = 3 // Daily loss limit % of effective cap [1-20, step 1]
  • [=== Risk & Sizing ===] InpMaxWeeklyLossPct = 9 // Weekly loss limit % of effective cap [1-50, step 1]
  • [=== Risk & Sizing ===] InpCooldownLosses = 3 // Cooldown after N consecutive losses [0-20, step 1]
  • [=== Risk & Sizing ===] InpCooldownMinutes = 60 // Cooldown duration (min) [0-720, step 10]
  • [=== Capital Allocation Cap ===] InpCapitalCapAmount = 500.0 // Capital cap amount ($ equity, 0 = disabled) [0-100000, step 100]
  • [=== Capital Allocation Cap ===] InpCapitalCapFloor = 50.0 // Floor below which no new entries ($) [0-10000, step 10]
  • [=== In-Trade Management ===] InpUseBreakEven = true // Move SL to break-even at +1R
  • [=== In-Trade Management ===] InpUsePartialTP = true // Take 50% off at TP1 (+1R)
  • [=== In-Trade Management ===] InpUseATRTrail = true // ATR-based trailing stop
  • [=== In-Trade Management ===] InpTrailATRMult = 2 // Trail distance = ATR x mult [1-10, step 1]
  • [=== In-Trade Management ===] InpMaxBarsInTrade = 240 // Time-based exit (bars) [10-2000, step 10]
  • [=== In-Trade Management ===] InpExitOppositeSignal = true // Exit on opposite breakout
  • [=== In-Trade Management ===] InpExitRegimeChange = true // Exit if regime turns Choppy/Range
  • [=== Scaling ===] InpUsePyramid = false // Pyramid (default OFF)
  • [=== Scaling ===] InpPyramidMaxLevels = 3 // Max pyramid levels (<=5) [1-5, step 1]
  • [=== Scaling ===] InpPyramidATRSpacing = 1.5 // Spacing between adds (x ATR) [0.5-5.0, step 0.1]
  • [=== Execution ===] InpMaxSpreadPoints = 35 // Max spread (points) [1-200, step 1]
  • [=== Execution ===] InpSlippagePoints = 20 // Max deviation (points) [0-100, step 1]
  • [=== News & Misc ===] InpUseNewsWindow = true // Block trades near high-impact news
  • [=== News & Misc ===] InpNewsBeforeMin = 15 // Block N min before [5-120, step 5]
  • [=== News & Misc ===] InpNewsAfterMin = 15 // Block N min after [5-120, step 5]
  • [=== Hardening: GMT Sessions & Safety ===] InpMaxTradesPerDay = 10 // Max trades per calendar day (0=unlimited) [0-100, step 1]
  • [=== Hardening: GMT Sessions & Safety ===] InpMinEquityPct = 70.0 // Min equity as % of initial balance to trade [0-100, step 1]
  • [=== Hardening: GMT Sessions & Safety ===] InpMaxConsecLosses = 5 // Max consecutive losses before cooldown [0-20, step 1]
  • [=== Hardening: GMT Sessions & Safety ===] InpCooldownHours = 4 // Cooldown duration after max consec losses (hours) [0-72, step 1]
  • [=== Hardening: GMT Sessions & Safety ===] InpUseGMTSessions = true // Use GMT-based session filtering
  • [=== Hardening: GMT Sessions & Safety ===] InpLondonStartGMT = 7 // London session start (GMT hour) [0-23, step 1]
  • [=== Hardening: GMT Sessions & Safety ===] InpLondonEndGMT = 16 // London session end (GMT hour) [0-23, step 1]
  • [=== Hardening: GMT Sessions & Safety ===] InpNewYorkStartGMT = 12 // New York session start (GMT hour) [0-23, step 1]
  • [=== Hardening: GMT Sessions & Safety ===] InpNewYorkEndGMT = 21 // New York session end (GMT hour) [0-23, step 1]
Pseudocode
// Pipsgrowth EX02008 Breakout — Execution Flow (from source analysis)
// Family: Breakout
// Self-contained Donchian breakout. Channel built inline from CopyHigh/CopyLow over lookback window. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester. BE, partial TP, ATR trail

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:
M5

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
InpMagic22202008Magic number (unique per EA) [1-999999999, step 1]
InpTradeComment"Psgrowth.com Expert_02008"Trade comment
InpEnableLoggingtrueEnable non-critical logging
InpDryRuntrueDry-run (signal+log only, no orders)
InpKillSwitchfalseKILL: halt all new entries
InpLength20Donchian period (bars) [2-200, step 1]
InpBreakoutATR0.3Min excursion beyond band (x ATR) [0.0-2.0, step 0.05]
InpUseSlopeFiltertrueFilter on Donchian middle slope
InpStrongCandleRatio0.6Min body/range ratio of breakout bar [0.0-1.0, step 0.05]
InpHTFBarShift1HTF bar shift for trend (1 = last closed) [1-10, step 1]
InpADXPeriod14ADX period [2-100, step 1]
InpADXMinBreakout18.0Min ADX for Breakout/StrongTrend [5-50, step 0.5]
InpATRPeriod14ATR period [2-100, step 1]
InpATRPctLookback100ATR percentile lookback (bars) [20-500, step 10]
InpATRPctMinBreakout50.0Min ATR percentile for Breakout [0-100, step 5]
InpBBPeriod20Bollinger period [2-100, step 1]
InpBBDev2.0Bollinger deviation [0.5-5.0, step 0.1]
InpBBWCompressRatio0.6BBW < avg*ratio => Compress [0.1-1.0, step 0.05]
InpMaxEntriesPerBar1Max entries per bar (dedup) [1-10, step 1]
InpRequireHTFAgreetrueRequire HTF trend agreement
InpHTF7HTF timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1 [1-9, step 1]
InpMinRR12Min reward:risk in tenths (12 = 1.2) [5-50, step 1]
InpRiskPercent0.5Risk % per trade [0.1-10.0, step 0.1]
InpATRStopMult2SL = ATR x mult [1-10, step 1]
InpATRTPMult4TP = ATR x mult [1-20, step 1]
InpMaxLot10.0Hard cap on lot size [0.01-100, step 0.01]
InpMaxDDPct20.0Max total drawdown % (0=disabled, triggers kill switch)
InpMaxOpenTrades5Max concurrent trades [1-20, step 1]
InpMaxSymbolExposure3Max positions on this symbol [1-20, step 1]
InpMaxDailyLossPct3Daily loss limit % of effective cap [1-20, step 1]
InpMaxWeeklyLossPct9Weekly loss limit % of effective cap [1-50, step 1]
InpCooldownLosses3Cooldown after N consecutive losses [0-20, step 1]
InpCooldownMinutes60Cooldown duration (min) [0-720, step 10]
InpCapitalCapAmount500.0Capital cap amount ($ equity, 0 = disabled) [0-100000, step 100]
InpCapitalCapFloor50.0Floor below which no new entries ($) [0-10000, step 10]
InpUseBreakEventrueMove SL to break-even at +1R
InpUsePartialTPtrueTake 50% off at TP1 (+1R)
InpUseATRTrailtrueATR-based trailing stop
InpTrailATRMult2Trail distance = ATR x mult [1-10, step 1]
InpMaxBarsInTrade240Time-based exit (bars) [10-2000, step 10]
InpExitOppositeSignaltrueExit on opposite breakout
InpExitRegimeChangetrueExit if regime turns Choppy/Range
InpUsePyramidfalsePyramid (default OFF)
InpPyramidMaxLevels3Max pyramid levels (<=5) [1-5, step 1]
InpPyramidATRSpacing1.5Spacing between adds (x ATR) [0.5-5.0, step 0.1]
InpMaxSpreadPoints35Max spread (points) [1-200, step 1]
InpSlippagePoints20Max deviation (points) [0-100, step 1]
InpUseNewsWindowtrueBlock trades near high-impact news
InpNewsBeforeMin15Block N min before [5-120, step 5]
InpNewsAfterMin15Block N min after [5-120, step 5]
InpMaxTradesPerDay10Max trades per calendar day (0=unlimited) [0-100, step 1]
InpMinEquityPct70.0Min equity as % of initial balance to trade [0-100, step 1]
InpMaxConsecLosses5Max consecutive losses before cooldown [0-20, step 1]
InpCooldownHours4Cooldown duration after max consec losses (hours) [0-72, step 1]
InpUseGMTSessionstrueUse GMT-based session filtering
InpLondonStartGMT7London session start (GMT hour) [0-23, step 1]
InpLondonEndGMT16London session end (GMT hour) [0-23, step 1]
InpNewYorkStartGMT12New York session start (GMT hour) [0-23, step 1]
InpNewYorkEndGMT21New York session end (GMT hour) [0-23, step 1]
Source Code (.mq5)Open Source
Pipsgrowth_com_EX02008.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX02008 GB10 Donchian XAUUSD 5M — inline Donchian channel breakout, 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>

//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
input group "=== Identity ==="
input long   InpMagic                = 22202008; // Magic number (unique per EA) [1-999999999, step 1]
input string InpTradeComment         = "Psgrowth.com Expert_02008"; // Trade comment
input bool   InpEnableLogging        = true;     // Enable non-critical logging
input bool   InpDryRun               = true;     // Dry-run (signal+log only, no orders)
input bool   InpKillSwitch           = false;    // KILL: halt all new entries

input group "=== Donchian Core ==="
input int    InpLength               = 20;       // Donchian period (bars) [2-200, step 1]
input double InpBreakoutATR          = 0.3;      // Min excursion beyond band (x ATR) [0.0-2.0, step 0.05]
input bool   InpUseSlopeFilter       = true;     // Filter on Donchian middle slope
input double InpStrongCandleRatio    = 0.6;      // Min body/range ratio of breakout bar [0.0-1.0, step 0.05]
input int    InpHTFBarShift          = 1;        // HTF bar shift for trend (1 = last closed) [1-10, step 1]

input group "=== Regime Filter ==="
input int    InpADXPeriod            = 14;       // ADX period [2-100, step 1]
input double InpADXMinBreakout       = 18.0;     // Min ADX for Breakout/StrongTrend [5-50, step 0.5]
input int    InpATRPeriod            = 14;       // ATR period [2-100, step 1]
input int    InpATRPctLookback       = 100;      // ATR percentile lookback (bars) [20-500, step 10]
input double InpATRPctMinBreakout    = 50.0;     // Min ATR percentile for Breakout [0-100, step 5]
input int    InpBBPeriod             = 20;       // Bollinger period [2-100, step 1]
input double InpBBDev                = 2.0;      // Bollinger deviation [0.5-5.0, step 0.1]
input double InpBBWCompressRatio     = 0.6;      // BBW < avg*ratio => Compress [0.1-1.0, step 0.05]

input group "=== Entry & Triggers ==="
input int    InpMaxEntriesPerBar     = 1;        // Max entries per bar (dedup) [1-10, step 1]
input bool   InpRequireHTFAgree      = true;     // Require HTF trend agreement
input int    InpHTF                  = 7;        // HTF timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1 [1-9, step 1]
input int    InpMinRR                = 12;       // Min reward:risk in tenths (12 = 1.2) [5-50, step 1]

input group "=== Risk & Sizing ==="
input double InpRiskPercent          = 0.5;      // Risk % per trade [0.1-10.0, step 0.1]
input int    InpATRStopMult          = 2;        // SL = ATR x mult [1-10, step 1]
input int    InpATRTPMult            = 4;        // TP = ATR x mult [1-20, step 1]
input double InpMaxLot               = 10.0;     // Hard cap on lot size [0.01-100, step 0.01]
input double InpMaxDDPct             = 20.0;     // Max total drawdown % (0=disabled, triggers kill switch)
input int    InpMaxOpenTrades        = 5;        // Max concurrent trades [1-20, step 1]
input int    InpMaxSymbolExposure    = 3;        // Max positions on this symbol [1-20, step 1]
input int    InpMaxDailyLossPct      = 3;        // Daily loss limit % of effective cap [1-20, step 1]
input int    InpMaxWeeklyLossPct     = 9;        // Weekly loss limit % of effective cap [1-50, step 1]
input int    InpCooldownLosses       = 3;        // Cooldown after N consecutive losses [0-20, step 1]
input int    InpCooldownMinutes      = 60;       // Cooldown duration (min) [0-720, step 10]

input group "=== Capital Allocation Cap ==="

Full source code available on download

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

Tags:ex02008breakoutpipsgrowthfreemt5xauusd

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