Pipsgrowth EX01018 Adaptive
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX01018 AdaptiveVol XAUUSD 5M — adaptive volatility breakout, full 12-layer stack.
Overview
Pipsgrowth EX01018 is a single-rule volatility breakout EA built for XAUUSD on the M5 timeframe. The whole entry decision collapses to one condition: read the 14-period Average True Range, convert it to broker points, and if the result exceeds 200 points, open a buy. That is the entirety of the signal logic. There are no oscillators, no moving averages, no Bollinger Bands, no pattern recognition — just ATR as a regime filter, then a single long entry. The EA is long-only by design; there is no symmetric short path. Once a position is open, no additional orders are layered in: OnTick() returns immediately when PositionsTotal() > 0, so the EA is strictly one-position-at-a-time and lets the fixed 400-point stop and 800-point target do the work.
The ATR breakout is the adaptive part of the name. XAUUSD on a five-minute bar spends most of its life in a 50–120 point ATR regime. The 200-point threshold is the EA's "something is happening" trigger — typically a news spike, a London open sweep, or a New York impulse. By waiting for ATR to inflate before buying, the EA deliberately skips the chop. The cost is that it will miss the first few points of any move and pay the spread on the breakout candle; the upside is that the moves that do trigger it tend to continue rather than reverse mid-bar.
Risk is the only part of the EA that scales with capital. InpRiskPercent is set to 1.0 by default; at that value OpenBuy() computes the lot from balance × 1% / (SL distance in points × point value) using SYMBOL_TRADE_TICK_VALUE and SYMBOL_TRADE_TICK_SIZE to derive the per-point cost in deposit currency. Set InpRiskPercent to 0 and the EA falls back to InpFixedLot = 0.01 — useful for prop-firm challenges where sizing is fixed. The final lot is clamped between SYMBOL_VOLUME_MIN and SYMBOL_VOLUME_MAX, snapped to SYMBOL_VOLUME_STEP, and capped by the InpMaxLot = 100 safety ceiling. Before sending, OpenBuy() also checks OrderCalcMargin() against ACCOUNT_MARGIN_FREE; if the lot would consume the free margin, the order is dropped and nothing is logged beyond a single Print line.
The 12 layers referenced in the header are organized as a strict no-trade gate that runs before every potential entry, not as 12 separate decision branches. IsSafeToTrade() chains capital cap (InpCapAmount, default 0 = off), capital floor (InpCapFloor = 100), MinEquityPercent = 80% of initial balance, daily realized-loss check (MaxDailyLossPercent = 3%), weekly loss cap (InpMaxWeeklyLossPct = 8%), the InpMaxConsecLosses = 3 → 30-minute cooldown, the MaxTradesPerDayGlobal = 50 counter, market-open status, session membership, news-time avoidance, the InpKillSwitch, and finally the InpMaxDDPct = 20% total-drawdown kill switch. If any single check fails, no order is sent and the tick is wasted. The market-open check skips Saturday entirely, blocks Sunday before 22:00 GMT, and refuses entries after 21:00 GMT on Friday (the broker usually widens spreads and many brokers stop processing new orders around then). The DD kill switch prints a one-line "KILL SWITCH: total DD=X% >= Y%. ALL TRADING HALTED." event the first time it trips, and the EA is then inert until the user resets it manually.
Sessions are evaluated in GMT. InpServerGMTOffset is 0 by default, which triggers DetectGMTOffset(): the function walks H1 bars backwards from index 2 to 99 looking for a gap > 2 hours, computes the offset from the post-gap bar's hour relative to 22:00 GMT (the typical Friday close), and clamps the result to ±12. If you know your broker's offset you can hard-code it; the auto-detect is there for users who don't. The trading window is the union of London 7–16 GMT and New York 12–21 GMT, with InpAvoidAsia = true excluding the 0–7 GMT block unless London or NY is also active. The London–NY overlap between 12 and 16 GMT is therefore the only time the EA can be triggered on both sessions simultaneously, which is also when the ATR is most likely to cross 200 points.
News handling is binary. IsNewsTime() returns true whenever the current GMT minute is within 30 minutes of the London or NY session opens, so the blackout window is the half-hour before and after each 7:00 GMT and 12:00 GMT boundary. The flag is InpAvoidNews = true by default; turn it off if you specifically want to trade the spike, but note that the 200-point ATR threshold is calibrated to the size of the impulse news produces, so most news trades will be either filtered or entered exactly at the worst slippage moment.
Trade execution uses the standard CTrade wrapper with the magic 22201018. Filling mode is auto-detected from SYMBOL_FILLING_MODE — FOK if the broker supports it, otherwise IOC, otherwise RETURN — and the order is sent with InpSlippagePoints = 10 tolerance. TryBuy_EX01018() retries up to three times on TRADE_RETCODE_REQUOTE, TRADE_RETCODE_TIMEOUT, TRADE_RETCODE_PRICE_OFF, or TRADE_RETCODE_PRICE_CHANGED with a 200 ms sleep between attempts; any other retcode breaks the loop. Realized P&L for the daily/weekly counters is read in OnTradeTransaction() by listening for DEAL_TRANSACTION_DEAL_ADD with DEAL_ENTRY_OUT and the matching magic, which then adds profit + swap + commission to g_realizedToday, g_realizedWeek, and g_tradesToday. Losses bump g_consecLosses and set g_cooldownUntil to now plus InpCooldownMin × 60 seconds; wins reset the counter.
The optimizer in OnTester() returns profit × clamped profit-factor × drawdown-penalty, where the drawdown penalty is 1 / (1 + DD/10), PF is hard-clamped at 10, and three hard gates make most optimization results 0: maxDD must be ≤ 20% (or InpMaxDDPct if non-zero), trade count must be ≥ 20, and net profit must be positive. Pass all three and the criterion is positive; fail any one and the entire pass is scored zero, which is what the strategy wants for walk-forward discipline.
In practical terms, EX01018 fits a trader who wants a minimal, mechanical, long-only gold EA with a one-rule entry and a full safety net. The 200-point ATR threshold is not user-configurable, so if gold's intraday volatility regime shifts the strategy either fires more or fires less — there is no dial to re-tune it. With MinEquityPercent at 80% and a 3% daily / 8% weekly / 20% total DD ceiling, the EA will simply stop itself out of trouble long before the account is at risk. The minimum deposit field of $100 reflects the cent-friendly sizing via SYMBOL_VOLUME_MIN; on a standard lot broker the same logic still works but you should expect fewer trades and larger per-trade swings.
Strategy Deep Dive
On every tick the EA first runs the no-trade gate — IsSafeToTrade() chains capital cap, capital floor, equity-floor, daily/weekly loss limits, the consec-loss cooldown, the trade-count cap, market hours, session membership, news-time blackout, the kill switch, and the 20% total-DD ceiling; if any check fails, the tick is dropped. With the gate green, the EA reads the previous bar's ATR(14) and divides by mysymbol.Point() to get the value in broker points. When that crosses the 200-point threshold and there are no open positions, OpenBuy() computes the lot from InpRiskPercent of balance (or falls back to InpFixedLot = 0.01), clamps it to symbol volume limits, checks margin, then sends via TryBuy_EX01018() with up to three retries on requote/timeout/price-change. OnTradeTransaction() walks the deal history to attribute every close to g_realizedToday, g_realizedWeek, and g_tradesToday, and trips the consec-loss cooldown on negative net P&L.
OpenBuy fires when the 14-period ATR (in broker points) crosses above 200 on a closed bar — the threshold is hard-coded in the .mq5, not user-configurable. The EA reads only the previous-bar ATR via CopyBuffer and converts to points using mysymbol.Point(). One position at a time: if PositionsTotal() > 0 the entry logic skips. Long-only — there is no symmetric short trigger.
Exits are fixed at the stop and target the broker attaches to the order — 400-point SL and 800-point TP, a 1:2 reward-to-risk ratio. There is no trailing stop, no break-even ratchet, and no time-based exit; the position closes only on SL, TP, or the user closing it manually. The capital-cap/floor and drawdown-kill-switch layers can prevent re-entry but do not force-close an open position.
Fixed 400-point stop-loss attached to every order, adjusted upward to respect the broker's SYMBOL_TRADE_STOPS_LEVEL minimum. The risk-based lot sizing means the dollar risk per trade scales with the SL distance; the SL itself never moves. There is no trailing or break-even ratchet on the live position.
Fixed 800-point take-profit (1:2 RR vs. the 400-point SL). No scaling out, no partial close — the entire position exits at TP or SL.
Minimum recommended balance is $100 — the cent-lot fallback path uses SYMBOL_VOLUME_MIN, but a $500+ balance gives the 1% risk sizing room to breathe. The EA is XAUUSD-only on M5 and trades the London and New York sessions in GMT; the 12:00–16:00 GMT overlap is when the ATR > 200 trigger is most likely to fire. Best deployed on a low-spread, fast-execution broker with sub-50 ms latency, since 10 points of slippage tolerance does not cover wide ECN spreads on a news candle. Risk level is rated MEDIUM because the fixed SL is tight enough to prevent a single trade from doing real damage, but the single-rule entry can cluster multiple entries into one volatility event.
Strategy Logic
Pipsgrowth EX01018 Adaptive — Strategy Logic Analysis (from .mq5 source)
Family: Adaptive
Magic: 22201018
Version: 3.00
BRIEF:
Adaptive volatility EA for XAUUSD M5. Uses ATR to detect volatility regime — enters breakout buy when ATR exceeds 200 points. Risk-based or fixed lot sizing, fixed SL/TP. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
OpenBuy()OnTradeTransaction()DetectGMTOffset()ServerToGMT()IsMarketOpen()InActiveSession()IsNewsTime()IsSafeToTrade()UpdateDailyCounters()TryBuy_EX01018()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (26 total across 5 groups):
- [===
CORE===]InpRiskPercent=1.0// Risk percent for lot sizing - [===
CORE===]InpFixedLot=0.01// Fixed lot (used if risk=0) - [===
CORE===]InpStopLoss= 400 // Stop loss in points - [===
CORE===]InpTakeProfit= 800 // Take profit in points - [===
CORE===]InpSlippagePoints= 10 // Slippage in points - [=== Risk Management ===]
MaxDailyLossPercent=3.0// Maximum daily loss percentage - [=== Risk Management ===]
MaxTradesPerDayGlobal= 50 // Maximum trades per day (global) - [=== Risk Management ===]
MinEquityPercent=80.0// Stop trading if equity falls below this % of initial balance - [=== Risk Management ===]
InpMaxConsecLosses= 3 // Max consecutive losses before cooldown (0=disabled) - [=== Risk Management ===]
InpCooldownMin= 30 // Cooldown minutes after consec losses (0=disabled) - [=== Risk Management ===]
InpMaxWeeklyLossPct=8.0// Max weekly loss % (0=disabled) - [=== Capital Cap ===]
InpCapAmount=0.0// Capital cap amount (stop trading at this equity) - [=== Capital Cap ===]
InpCapFloor=100.0// Capital floor (stop trading below this equity) - [=== Sessions
Management(GMT) ===]InpServerGMTOffset= 0 // ServerGMToffset in hours (0=auto-detect via weekend gap) - [=== Sessions
Management(GMT) ===]InpLondonStartHour= 7 // London session start (GMT) - [=== Sessions
Management(GMT) ===]InpLondonEndHour= 16 // London session end (GMT) - [=== Sessions
Management(GMT) ===]InpNYStartHour= 12 // New York session start (GMT) - [=== Sessions
Management(GMT) ===]InpNYEndHour= 21 // New York session end (GMT) - [=== Sessions
Management(GMT) ===]InpAvoidAsia=true// Avoid Asian session - [=== Sessions
Management(GMT) ===]InpAsiaStartHour= 0 // Asian session start (GMT) - [=== Sessions
Management(GMT) ===]InpAsiaEndHour= 7 // Asian session end (GMT) - [=== Sessions
Management(GMT) ===]AvoidNews=true// Avoid trading during news - [=== Safety Caps ===]
InpMaxDDPct=20.0// Max total drawdown % (0=disabled, triggers kill switch) - [=== Safety Caps ===]
InpKillSwitch=false// Kill switch (stops all trading immediately) - [=== Safety Caps ===]
InpDryRun=false// Dry-run mode: log signals without trading - [=== Safety Caps ===]
InpMaxLot=100.0// Maximum lot size cap
// Pipsgrowth EX01018 Adaptive — Execution Flow (from source analysis)
// Family: Adaptive
// Adaptive volatility EA for XAUUSD M5. Uses ATR to detect volatility regime — enters breakout buy when ATR exceeds 200 points. Risk-based or fixed lot sizing, fixed SL/TP. 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 a chart matching the recommended timeframe
- 7Configure parameters according to the table on this page
- 8Enable Allow Algo Trading and click OK
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| InpRiskPercent | 1.0 | Risk percent for lot sizing |
| InpFixedLot | 0.01 | Fixed lot (used if risk=0) |
| InpStopLoss | 400 | Stop loss in points |
| InpTakeProfit | 800 | Take profit in points |
| InpSlippagePoints | 10 | Slippage in points |
| MaxDailyLossPercent | 3.0 | Maximum daily loss percentage |
| MaxTradesPerDayGlobal | 50 | Maximum trades per day (global) |
| MinEquityPercent | 80.0 | Stop trading if equity falls below this % of initial balance |
| InpMaxConsecLosses | 3 | Max consecutive losses before cooldown (0=disabled) |
| InpCooldownMin | 30 | Cooldown minutes after consec losses (0=disabled) |
| InpMaxWeeklyLossPct | 8.0 | Max weekly loss % (0=disabled) |
| InpCapAmount | 0.0 | Capital cap amount (stop trading at this equity) |
| InpCapFloor | 100.0 | Capital floor (stop trading below this equity) |
| InpServerGMTOffset | 0 | Server GMT offset in hours (0=auto-detect via weekend gap) |
| InpLondonStartHour | 7 | London session start (GMT) |
| InpLondonEndHour | 16 | London session end (GMT) |
| InpNYStartHour | 12 | New York session start (GMT) |
| InpNYEndHour | 21 | New York session end (GMT) |
| InpAvoidAsia | true | Avoid Asian session |
| InpAsiaStartHour | 0 | Asian session start (GMT) |
| InpAsiaEndHour | 7 | Asian session end (GMT) |
| AvoidNews | true | Avoid trading during news |
| InpMaxDDPct | 20.0 | Max total drawdown % (0=disabled, triggers kill switch) |
| InpKillSwitch | false | Kill switch (stops all trading immediately) |
| InpDryRun | false | Dry-run mode: log signals without trading |
| InpMaxLot | 100.0 | Maximum lot size cap |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "3.00"
#property strict
#property description "Pipsgrowth.com EX01018 AdaptiveVol XAUUSD 5M — adaptive volatility breakout, full 12-layer stack."
#include <Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
CTrade trade;
CPositionInfo position;
CSymbolInfo mysymbol;
CAccountInfo account;
input group "=== CORE ==="
input double InpRiskPercent = 1.0; // Risk percent for lot sizing
input double InpFixedLot = 0.01; // Fixed lot (used if risk=0)
input int InpStopLoss = 400; // Stop loss in points
input int InpTakeProfit = 800; // Take profit in points
input int InpMagicNumber = 22201018;
input string InpTradeComment = "Psgrowth.com Expert_01018";
input int InpSlippagePoints = 10; // Slippage in points
input group "=== Risk Management ==="
input double MaxDailyLossPercent = 3.0; // Maximum daily loss percentage
input int MaxTradesPerDayGlobal = 50; // Maximum trades per day (global)
input double MinEquityPercent = 80.0; // Stop trading if equity falls below this % of initial balance
input int InpMaxConsecLosses = 3; // Max consecutive losses before cooldown (0=disabled)
input int InpCooldownMin = 30; // Cooldown minutes after consec losses (0=disabled)
input double InpMaxWeeklyLossPct = 8.0; // Max weekly loss % (0=disabled)
input group "=== Capital Cap ==="
// InpCapEnabled removed — use InpCapAmount=0 to disable // Enable capital cap (stop trading above cap)
input double InpCapAmount = 0.0; // Capital cap amount (stop trading at this equity)
input double InpCapFloor = 100.0; // Capital floor (stop trading below this equity)
input group "=== Sessions Management (GMT) ==="
input int InpServerGMTOffset = 0; // Server GMT offset in hours (0=auto-detect via weekend gap)
input int InpLondonStartHour = 7; // London session start (GMT)
input int InpLondonEndHour = 16; // London session end (GMT)
input int InpNYStartHour = 12; // New York session start (GMT)
input int InpNYEndHour = 21; // New York session end (GMT)
input bool InpAvoidAsia = true; // Avoid Asian session
input int InpAsiaStartHour = 0; // Asian session start (GMT)
input int InpAsiaEndHour = 7; // Asian session end (GMT)
input bool AvoidNews = true; // Avoid trading during news
input group "=== Safety Caps ==="
input double InpMaxDDPct = 20.0; // Max total drawdown % (0=disabled, triggers kill switch)
input bool InpKillSwitch = false; // Kill switch (stops all trading immediately)
input bool InpDryRun = false; // Dry-run mode: log signals without trading
input double InpMaxLot = 100.0; // Maximum lot size cap
int hATR;
double bufATR[];
//--- Hardening globals
double initialBalance = 0.0;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 Other strategy EAs from our library
Pipsgrowth EX01007 Adaptive
Pipsgrowth.com EX01007 Adaptive XAUUSD 5M — multi-indicator signal scorer with regime filter, full 12-layer stack, configurable timeframe, trailing/BE/profit-lock toggles, pyramid gate, spread filter, new-bar gate, filling mode detection.
Pipsgrowth EX01019 Adaptive
Pipsgrowth.com EX01019 Self-Adaptive Market EA Fixed — multi-regime adaptive EA, full 12-layer stack.
Pipsgrowth EX15029 SMC-OrderBlock
Pipsgrowth.com EX15029 SMCBreakoutEA — SMC breakout CHOCH/liquidity sweep EA, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.