P
PipsGrowth
BreakoutOpen Source – Free

Pipsgrowth EX02013 Breakout

MT5 Expert Advisor (Open Source) · XAUUSD, XAGUSD, EURUSD, USDJPY · H1

Pipsgrowth.com EX02013 dochin_is_complete  JMA + Donchian Breakout with pyramiding and profit lock, full 12-layer stack.

Overview

EX02013 is a dual-confirmation breakout engine designed for the H1 chart of XAUUSD, XAGUSD, EURUSD, and USDJPY. The EA does not chase a single indicator — it requires two independent structural breaks to agree before it will commit capital. The first gate is a classic Donchian channel on a user-selectable timeframe (InpDonchianTF=4 maps to H1, period 20, shift 1): a long only fires when the previous bar's close prints above the channel upper boundary, and a short only fires when the previous close prints below the lower boundary. The second gate is a Jurik Moving Average, computed inline via the CalcJMA() loop using length 14, phase 0, and power 0.45; the GetJMASignal() helper compares the current JMA value against the prior bar's JMA and turns bullish when the curve is rising, bearish when it is falling. Both gates must point in the same direction on the same evaluation tick before GetCombinedSignal() returns a non-zero direction — if Donchian says long but JMA is flat or falling, no trade. The shift-1 anchor on both signals means EX02013 only reacts to completed bars, not to in-progress candle spikes, which removes a large class of false-break entries that plague lower-timeframe breakout bots.

What sets EX02013 apart from a textbook Donchian bot is its post-entry management stack. The position opens with a hard stop at InpHardSL_Points=1000 (1,000 points, i.e. 10 pips on a 5-digit broker or 100 pips on a 3-digit XAUUSD quote) and a take-profit at InpFixedTP_Points=2000, giving a default 1:2 reward-to-risk. From there, two trailing regimes take over. The first is ManageProfitLock(): once profit reaches InpLock_StartDistance=500 points, the EA ratchets the stop loss to price minus InpLock_BreathDistance=300 points, but only when the new stop is at least InpLock_Step=50 points further into profit than the previous one — this prevents the broker's stops_level from causing constant rejected modify requests. The second is ManageTightening(): when profit climbs past InpTighten_TriggerProfit=1500 points, the EA switches to a tighter mode with InpTighten_BreathDistance=150 points and InpTighten_Step=20 points, hugging the price much more closely. Tightening is the de-facto partial-exit substitute: instead of closing half the position, it locks most of the unrealized gain and lets the runner continue.

Pyramiding is enabled by default (InpEnablePyramiding=true) with a cap of InpPyramid_MaxLevels=3 entries per direction. Two preconditions gate every pyramid add: AreAllPositionsSecured() verifies that every existing position in the direction already has its stop above break-even by at least InpPyramid_SecureProfit=200 points, and IsDistanceEnough() requires the new entry to sit at least InpPyramid_MinDistPoints=500 points away from the most recent open price. This combination prevents the EA from adding into a losing cluster or stacking orders on top of each other when price is choppy. The position sizing is risk-based through InpLots(): with InpRiskPercent=0.5 the EA risks 0.5% of account balance per trade, then walks the lot down to the symbol's volume step, enforces the minimum, and caps the result at both the symbol's max volume and InpMaxLot=5.0. Setting InpFixedLots to any value above zero overrides the risk calculation and trades a flat size, useful for prop-firm accounts that prefer fixed-notion sizing.

The no-trade gate is the largest in EX02013. The EA trades inside two user-defined GMT windows: London 7-16 and New York 12-21 (InpUseGMTSessions=true), and blocks weekends via the day_of_week check in InActiveSession_EX02013(). Server time is normalized to GMT through DetectGMTOffset_EX02013(), which scans offsets from -12 to +12 and picks the one that yields a weekday hour between 7 and 21, providing automatic broker alignment without manual configuration. The spread filter rejects entries when the current (ask-bid)/_Point exceeds InpMaxSpreadPoints=200, a loose setting chosen for XAUUSD's variable liquidity. Daily loss (InpDailyLossLimit), weekly loss (InpWeeklyLossLimit), equity floor (InpEquityFloor), equity-percent-of-initial floor (InpMinEquityPct=70), and a global InpMaxDDPct=20 kill switch all default to off or to lenient values — the user enables the strict variants per their broker and risk tolerance. The InpMaxTradesPerDay=20 ceiling caps the EA's daily activity, and the OnTradeTransaction handler tracks consecutive losses to fire a configurable cooldown (InpCooldownMinutes) once the user-defined threshold (InpMaxConsecLosses) is reached.

Order execution is hardened against requote storms: TryBuy_EX02013() and TrySell_EX02013() each retry up to three times at 200ms intervals on TRADE_RETCODE_REQUOTE, TRADE_RETCODE_TIMEOUT, TRADE_RETCODE_PRICE_OFF, or TRADE_RETCODE_PRICE_CHANGED, and they pre-check margin via OrderCalcMargin() before sending. The fills happen at the live ask/bid inside the retry loop, so even after a price-changed rejection the EA re-quotes against the fresh quote. Position modifications go through TryModify_EX02013(), which quantizes the new stop to the symbol's tick size before sending and also retries three times. The OnTester() fitness function combines recovery factor with profit factor (rf × pf) and gates on trade count ≥ 10, drawdown ≤ InpMaxDDPct, and net profit > 0, which prevents the optimiser from selecting parameter sets that look sharp in-sample but blow up the account out-of-sample.

EX02013 in practice behaves like a trend-respecting breakout hunter that refuses to enter until two independent measures agree, and once in, aggressively locks gains through the two-stage trailing system. It is not a tick-scalper, not a martingale, and not a grid — it is a H1 breakout EA with explicit pyramid rules and an unusually disciplined trailing framework. The InpDryRun input lets the user dry-log every signal without sending orders, which is the recommended first step on a new symbol to confirm the Donchian and JMA timeframes produce aligned signals at the trader's preferred session overlap. The InpKillSwitch input is a panic button that immediately flattens every position with magic 22202013 and stops further entries. Both default to false, and the EA ships ready to trade on XAUUSD H1 out of the box with the default 1:2 risk-reward geometry and the London/New York session windows active.

Strategy Deep Dive

EX02013 runs an inlined Donchian channel and an inlined JMA in parallel, requiring both to agree on direction on a completed bar (shift=1) before it opens. The Donchian gate compares the previous bar's close against the highest high of the prior 20 bars on the InpDonchianTF timeframe; the JMA gate compares the current smoothed value against the prior bar's value, rising vs. falling. Once a position is open, the EA overlays two trailing regimes — ManageProfitLock kicks in at 500 points of profit, then ManageTightening takes over at 1,500 points — both of which quantize the new stop to the symbol's tick size and push it forward in fixed steps. Pyramiding is on by default up to 3 levels, but only fires when every existing position in the direction is already break-even-plus and the new entry sits at least 500 points away from the last open. Every order passes through a 3-retry wrapper that re-quotes on requote/timeout/price-changed and pre-checks margin via OrderCalcMargin, and the safety gate enforces London+NY session windows, max 20 trades per day, a 70% equity floor, and a 20% drawdown kill switch.

Entry Signal

Long entry requires the previous bar's close to print above the Donchian upper channel AND the JMA(14) curve to slope upward (jma[0] > jma[1]) on the same evaluation. Short entry is the mirror — close below the lower Donchian band with JMA sloping down. Both signals are evaluated on shift 1, so only completed bars count.

Exit Signal

Exits via the fixed TP at 2,000 points (default 1:2 RR), or via the two-stage trailing stop: ManageProfitLock ratchets the SL behind price once profit exceeds 500 points, then ManageTightening takes over at 1,500 points of profit with a tighter 150-point breath.

Stop Loss

Hard stop loss set at InpHardSL_Points=1000 (10 pips on 5-digit FX or 100 pips on 3-digit XAUUSD) at entry. After entry the SL is only ever moved forward by ManageProfitLock or ManageTightening — never backwards.

Take Profit

Fixed take-profit at InpFixedTP_Points=2000 by default (1:2 reward-to-risk vs. the 1000-point SL). Set to 0 to disable the hard TP and let the trailing system manage the exit purely.

Best For

Best on H1 XAUUSD with the default 0.5% risk per trade; also fits XAGUSD, EURUSD, and USDJPY traders who want a H1 breakout with built-in trailing. Minimum recommended balance: $100. The EA needs the London 7-16 GMT and New York 12-21 GMT session windows for the default config, and benefits from a low-spread ECN/RAW broker — InpMaxSpreadPoints=200 is loose but a clean feed helps the 1:2 geometry breathe.

Strategy Logic

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

Family: Breakout Magic: 22202013 Version: 2.00

BRIEF: Professional Trend/Reversal EA using JMA + Donchian Breakout entry with pyramiding, profit lock trailing, and tightening management. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • CloseAllPositions_EX02013()
  • ManageProfitLock()
  • ManageTightening()
  • ManagePyramiding()
  • AreAllPositionsSecured()
  • IsDistanceEnough()
  • OpenTrade()
  • InpLots()
  • CountTrades()
  • GetDonchian()
  • CalcJMA()
  • UpdateDashboard()
  • ...and 9 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (35 total across 8 groups):

  • [=== Hardening Capital Protection ===] InpEquityFloor = 0.0 // Stop trading if equity drops below this
  • [=== Hardening Capital Protection ===] InpDailyLossLimit = 0.0 // Max daily loss in account currency (0=off)
  • [=== Hardening Capital Protection ===] InpWeeklyLossLimit = 0.0 // Max weekly loss in account currency (0=off)
  • [=== Hardening Capital Protection ===] InpCapitalCap = 0.0 // Stop trading if balance exceeds this (0=off)
  • [=== Hardening Trade Safety ===] InpMaxTradesPerDay = 20 // Max trades per day
  • [=== Hardening Trade Safety ===] InpCooldownMinutes = 0 // Cooldown after consecutive losses (minutes)
  • [=== Hardening Trade Safety ===] InpMaxConsecLosses = 0 // Stop trading after N consecutive losses (0=off)
  • [=== Hardening Trade Safety ===] InpSlippagePoints = 20.0 // Max slippage (points)
  • [=== Hardening Trade Safety ===] InpLog = false // Enable verbose logging
  • [=== Hardening Trade Safety ===] InpMinEquityPct = 70.0 // Min equity as % of initial balance to trade [0-100, step 1]
  • [=== Hardening Trade Safety ===] InpDryRun = false // Dry-run: log signals without executing trades
  • [=== Hardening Trade Safety ===] InpKillSwitch = false // Kill switch: close all positions and stop trading
  • [=== Hardening Trade Safety ===] InpMaxDDPct = 20.0 // Max drawdown % — stop trading if exceeded [1-50, step 0.5]
  • [=== Hardening Trade Safety ===] InpMaxLot = 5.0 // Max lot size cap [0.01-100, step 0.01]
  • [=== Signal Settings ===] InpDonchianTF = 4 // Donchian timeframe (1=M1,2=M5,3=M15,4=H1,5=H4,6=D1,7=W1,8=MN1)
  • [=== Signal Settings ===] InpJMA_TF = 4 // JMA timeframe (1=M1,2=M5,3=M15,4=H1,5=H4,6=D1,7=W1,8=MN1)
  • [=== Signal Settings ===] InpJMA_Power = 0.45 // 0.3-0.7 recommended
  • [=== Signal Settings ===] InpRSI_Upper = 70.0 // Filter: RSI max for Buy
  • [=== Signal Settings ===] InpRSI_Lower = 30.0 // Filter: RSI min for Sell
  • [=== Money Management ===] InpRiskPercent = 0.5 // Risk % per trade
  • [=== Money Management ===] InpFixedLots = 0.0 // If > 0, uses fixed lots instead of risk %
  • [=== Money Management ===] InpHardSL_Points = 1000 // Stop Loss in Points
  • [=== Money Management ===] InpFixedTP_Points = 2000 // Take Profit in Points (0 = None)
  • [=== Money Management ===] InpMagicNumber = 22202013 // Magic Number (222 + Expert ID)
  • [=== Money Management ===] InpTradeComment = "Psgrowth.com Expert_02013" // --- Trade Management ---
  • [=== Trade Management - Profit Lock ===] InpLock_StartDistance = 500 // Points profit to start locking
  • [=== Trade Management - Profit Lock ===] InpLock_BreathDistance = 300 // Distance (Points) to keep SL from Price
  • [=== Trade Management - Profit Lock ===] InpLock_Step = 50 // Move SL only if improved by this step
  • [=== Trade Management - Tightening ===] InpTighten_TriggerProfit = 1500 // Pionts profit to switch to tight mode
  • [=== Trade Management - Tightening ===] InpTighten_BreathDistance = 150 // Tighter Distance (Points) from Price
  • [=== Trade Management - Tightening ===] InpTighten_Step = 20 // Tighter Step
  • [=== Pyramid / Scaling ===] InpPyramid_MaxLevels = 3 // Max positions per direction
  • [=== Pyramid / Scaling ===] InpPyramid_MinDistPoints = 500 // Min distance from last entry
  • [=== Pyramid / Scaling ===] InpPyramid_SecureProfit = 200 // Existing trades must have SL > BreakEven + this
  • [=== Filters ===] InpMaxSpreadPoints = 200 // Max Spread allowed (Points)
Pseudocode
// Pipsgrowth EX02013 Breakout — Execution Flow (from source analysis)
// Family: Breakout
// Professional Trend/Reversal EA using JMA + Donchian Breakout entry with pyramiding, profit lock trailing, and tightening management. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

ON_INIT:
    Create indicator handles: standard set
    Initialize state variables
    Detect broker GMT offset

ON_TICK:
    1. Refresh indicator buffers (closed-bar shift=1)
    2. Manage existing positions:
       - Break-even check
       - ATR trailing stop
       - Profit lock ratchet
       - Time-based exit
       - Opposite-signal exit
    3. If new bar:
       a. ClassifyRegime() — ADX/ATR/BB regime detection
       b. NoTradeGate() checks:
          - Market open + session filter
          - Spread limit
          - Cooldown after loss
          - Consecutive loss limit
          - Kill switch
          - Max drawdown
          - Max concurrent positions
          - Daily/weekly loss limits
       c. GenerateSignal() — strategy-specific entry logic
       d. CheckConfirm() — HTF alignment + R:R + ADX minimum
       e. Calculate position size from risk %
       f. Execute with retry logic
       g. Mark bar to prevent duplicates

ON_TESTER:
    Custom fitness = weighted(RecoveryFactor, ROI, ProfitFactor, TradeCount, Sharpe, Drawdown)

Optimization Profile

Optimized Brokers:
ExnessIC Markets
Optimized Symbols:
XAUUSDXAGUSDEURUSDUSDJPY
Optimized Timeframes:
H1

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
InpEquityFloor0.0Stop trading if equity drops below this
InpDailyLossLimit0.0Max daily loss in account currency (0=off)
InpWeeklyLossLimit0.0Max weekly loss in account currency (0=off)
InpCapitalCap0.0Stop trading if balance exceeds this (0=off)
InpMaxTradesPerDay20Max trades per day
InpCooldownMinutes0Cooldown after consecutive losses (minutes)
InpMaxConsecLosses0Stop trading after N consecutive losses (0=off)
InpSlippagePoints20.0Max slippage (points)
InpLogfalseEnable verbose logging
InpMinEquityPct70.0Min equity as % of initial balance to trade [0-100, step 1]
InpDryRunfalseDry-run: log signals without executing trades
InpKillSwitchfalseKill switch: close all positions and stop trading
InpMaxDDPct20.0Max drawdown % — stop trading if exceeded [1-50, step 0.5]
InpMaxLot5.0Max lot size cap [0.01-100, step 0.01]
InpDonchianTF4Donchian timeframe (1=M1,2=M5,3=M15,4=H1,5=H4,6=D1,7=W1,8=MN1)
InpJMA_TF4JMA timeframe (1=M1,2=M5,3=M15,4=H1,5=H4,6=D1,7=W1,8=MN1)
InpJMA_Power0.450.3-0.7 recommended
InpRSI_Upper70.0Filter: RSI max for Buy
InpRSI_Lower30.0Filter: RSI min for Sell
InpRiskPercent0.5Risk % per trade
InpFixedLots0.0If > 0, uses fixed lots instead of risk %
InpHardSL_Points1000Stop Loss in Points
InpFixedTP_Points2000Take Profit in Points (0 = None)
InpMagicNumber22202013Magic Number (222 + Expert ID)
InpTradeComment"Psgrowth.com Expert_02013"--- Trade Management ---
InpLock_StartDistance500Points profit to start locking
InpLock_BreathDistance300Distance (Points) to keep SL from Price
InpLock_Step50Move SL only if improved by this step
InpTighten_TriggerProfit1500Pionts profit to switch to tight mode
InpTighten_BreathDistance150Tighter Distance (Points) from Price
InpTighten_Step20Tighter Step
InpPyramid_MaxLevels3Max positions per direction
InpPyramid_MinDistPoints500Min distance from last entry
InpPyramid_SecureProfit200Existing trades must have SL > BreakEven + this
InpMaxSpreadPoints200Max Spread allowed (Points)
Source Code (.mq5)Open Source
Pipsgrowth_com_EX02013.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX02013 dochin_is_complete   JMA + Donchian Breakout with pyramiding and profit lock, full 12-layer stack."

#include <Trade/Trade.mqh>

//+------------------------------------------------------------------+
//| Global Objects                                                   |
//+------------------------------------------------------------------+
CTrade trade;
ulong  g_magicNumber = 123456; // Will be set from input

//+------------------------------------------------------------------+
//| Hardening Globals                                                |
//+------------------------------------------------------------------+
double g_initialBalance = 0;
double g_realizedToday  = 0;
double g_realizedWeek   = 0;
datetime g_dayStartTime  = 0;
datetime g_weekStartTime = 0;
int    g_gmtOffset      = 3;
int    g_dailyTrades    = 0;
int    g_consecutiveLosses = 0;
datetime g_cooldownUntil = 0;

//+------------------------------------------------------------------+
//| Hardening Inputs                                                 |
//+------------------------------------------------------------------+
input group "=== Hardening GMT Sessions ===";
input bool   InpUseGMTSessions  = true;
input int    InpLondonStartGMT  = 7;
input int    InpLondonEndGMT    = 16;
input int    InpNewYorkStartGMT = 12;
input int    InpNewYorkEndGMT   = 21;

input group "=== Hardening Capital Protection ===";
input double InpEquityFloor     = 0.0;    // Stop trading if equity drops below this
input double InpDailyLossLimit  = 0.0;    // Max daily loss in account currency (0=off)
input double InpWeeklyLossLimit = 0.0;    // Max weekly loss in account currency (0=off)
input double InpCapitalCap      = 0.0;    // Stop trading if balance exceeds this (0=off)

input group "=== Hardening Trade Safety ===";
input int    InpMaxTradesPerDay = 20;     // Max trades per day
input int    InpCooldownMinutes = 0;      // Cooldown after consecutive losses (minutes)
input int    InpMaxConsecLosses = 0;      // Stop trading after N consecutive losses (0=off)
input double InpSlippagePoints  = 20.0;   // Max slippage (points)
input bool   InpLog             = false;  // Enable verbose logging
input double InpMinEquityPct    = 70.0;   // Min equity as % of initial balance to trade [0-100, step 1]
input bool   InpDryRun          = false;  // Dry-run: log signals without executing trades
input bool   InpKillSwitch      = false;  // Kill switch: close all positions and stop trading
input double InpMaxDDPct        = 20.0;   // Max drawdown % — stop trading if exceeded [1-50, step 0.5]
input double InpMaxLot          = 5.0;    // Max lot size cap [0.01-100, step 0.01]

//+------------------------------------------------------------------+
//| Input Parameters                                                 |
//+------------------------------------------------------------------+

// --- Signal Settings ---

Full source code available on download

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

Tags:ex02013breakoutpipsgrowthfreemt5xauusdxagusdeurusdusdjpy

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_EX02013.mq5
File Size38.2 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyBreakout
Risk LevelMedium Risk
Timeframes
H1
Currency Pairs
XAUUSDXAGUSDEURUSDUSDJPY
Min. Deposit$100