Pipsgrowth EX17023 Volatility
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX17023 GB10_5_2_OPTIMIZED — Memory-optimized Gaussian Band breakout, full 12-layer stack.
Overview
EX17023 is a memory-optimized Gaussian-band breakout Expert Advisor distilled from a longer-bodied Gaussian-Band template. The defining design choice sits in the indicator handle count: where most breakout EAs in the same family open four or five MT5 indicator handles at OnInit, EX17023 opens exactly three — a single EMA used as the Gaussian midline, an ATR(14) for envelope width and stop distance, and a higher-timeframe EMA used solely for trend direction. Every entry, every trailing-stop ratchet, every breakeven shove, and every profit-lock step is computed from those three handles. The payoff is lighter terminal-state memory and faster restart on chart-switch, but the strategy stack is identical to the heavier version: a two-bar-inside-then-outside breakout with slope, candle-strength, and HTF-trend alignment gates, an ATR-multiplied trailing stop, a breakeven, and a stepped dynamic profit-lock.
The Gaussian midline is a period-10 EMA of close (the Length input, default 10) sourced through GaussianFilter(0) and GaussianFilter(1). The band envelope is built as gaussNow ± DistanceMultiplier × ATR(14), where DistanceMultiplier defaults to 0.85. The 0.85 figure is itself the subject of an auto-tune routine: AutoTuneFilters() runs once per tick when UseAutoFilter is on, measures the live spread, decides whether to treat the symbol as 4-decimal or 2-decimal (pipFactor = 0.0001 if spread < 3, else 0.01), and clamps the minimum ATR to roughly 3 pips of the relevant unit. For XAUUSD, where the spread reads in cents on a 2-decimal price, that branch picks the 0.01 pip factor and sets minATR near 0.03 — which is the default MinATR value in the input group. If the live ATR falls under that floor, OnTick returns immediately and no setup is built.
The breakout condition is the same two-bar-inside-then-outside pattern the rest of the GB family uses. A long setup needs the current bar to close above the upper band while the previous two bars both closed below it; the previous two bars are read from iClose(_Symbol, g_Timeframe, 1) and iClose(_Symbol, g_Timeframe, 2). A short setup mirrors the rule on the lower band. The 60%-body candle-strength gate from the heavier EX17009 is preserved: a strong candle is one whose body (MathAbs(price - open)) is at least 60% of the full candle range (high - low). The slope gate requires the current Gaussian value to be above the previous one for longs and below for shorts. The break-distance gate requires price - gaussNow > breakDistance × ATR for longs, with MinBreakDistance defaulting to 0.3 — so price must stretch at least 0.3×ATR beyond the midline before the band break is treated as meaningful. Finally, the trend gate is a single line: price must be on the correct side of the H4 EMA(50) (emaHandle = iMA(_Symbol, PERIOD_H4, 50, 0, MODE_EMA, PRICE_CLOSE)) for the direction of the trade.
If the gate stack passes, the EA closes any opposite position through CloseOpposite() and fires a new market order via the CTrade wrapper. The default lot is 0.1, with no money-management scaling — Lots is a fixed input. Position caps come from two controls: MaxOpenTrades (default 5) counts the EA's open tickets on the symbol, and AllowOnlyProfitableAdditions (default true) refuses to add a new ticket until every open position has at least MinProfitPerTradeToAdd dollars of profit (default $5). If OneTradeOnly is flipped on, the EA holds at most one position at a time and PositionExists() becomes the sole gate. The 3-retry wrappers TryClose_EX17023, TryClosePartial_EX17023, and TryModify_EX17023 all use 200 ms sleeps for closes and 100 ms for modifies, retrying on requote, timeout, or price-changed/price-off return codes.
Position management runs every tick while a position is open. The exit signal is the simplest one in the codebase: if the close price crosses back through the Gaussian midline in the wrong direction, the EA closes the trade. There is no time-decay, no partial close, no profit-target function — exits are either the midline cross, the fixed TP, or the protective ratchets. The midline-cross exit fires before any of the ratchets move the stop, so a position that swings through the band and back through the midline is taken out at the cross rather than at the trailing stop.
The protective stack has three layers, applied in order. First is the trailing stop, gated by UseTrailingStop = true. The new stop is bid - ATR_MultiplierSL × ATR for longs, and it only replaces the existing stop if it is higher. ATR_MultiplierSL defaults to 1.2, so the stop sits roughly 1.2×ATR below current price after each favourable tick. Second is breakeven, gated by UseBreakeven = true. The EA pushes the stop to entry price once the trade is more than ATR_MultiplierSL × ATR in profit and the current stop is still below entry (or, for shorts, still above entry). Third is the dynamic profit lock, gated by EnableDynamicLockProfit = true. This is the most distinctive piece of EX17023's exit machinery. The function reads current profit, divides it by LockProfitEvery_X_Dollars (default 2.0), floors the result to a step count, and computes a target locked profit of stepCount × 2.0 - LockMinusBuffer (default buffer 1.0). It then converts that dollar figure into a price offset using tickValue and tickSize, and moves the stop to entry + priceDiff for longs (or entry - priceDiff for shorts). The stop only ever moves forward — there is no ratchet-back logic — so once a profit is locked, it stays locked at that step or better.
The risk ceiling is a single equity-drawdown gate. CheckMaxDrawdown() computes 100 × (balance - equity) / balance and returns false if it exceeds MaxDrawdownPercent (default 10.0). When the gate fails, OnTick returns immediately — no entries, no exit checks, no ratchets — until the equity draw recovers. The 10% ceiling is intentionally loose compared to typical scalper profiles; the EA is built around a single trade holding a 160-point TP target with a 120-point hard SL floor under the ATR-derived stop, so the per-trade risk is bounded by whichever is larger: ATR × 1.2 or 120 points.
Practically, EX17023 is intended for XAUUSD on M5–H1 (the parser maps the default Timeframe = 0 input to PERIOD_H1; DB rows flag M5 as the tested timeframe). The H4 trend filter means the EA is sensitive to the structure of the higher timeframe and may skip valid intraday breakouts when the H4 trend is misaligned — that is by design. The dynamic profit-lock, the 60%-body candle filter, and the midline-cross exit together produce a system that prefers fewer, more deliberate trades over the high-frequency breakout bursts that simpler GB templates deliver. Backtests on lower spreads (under 20 points on XAUUSD) will see the auto-tuned band contract tighter; on wider spreads, the band widens and fewer setups qualify. If a trader finds the EA too quiet, dropping DistanceMultiplier toward 0.7 produces more frequent signals at the cost of more false breaks. If too noisy, raising it to 1.0 or higher waits for cleaner extensions beyond the midline.
Strategy Deep Dive
Pulls the indicator stack down to a single EMA(10) midline, an ATR(14) envelope, and an H4 EMA(50) trend filter — three MT5 handles in total — and uses them to drive a two-bar-inside-then-outside band breakout. Each tick, the EA rebuilds the band as midline ± 0.85×ATR, auto-tunes the floor based on live spread, and checks the slope, body strength, break distance, and H4-trend alignment before the CTrade wrapper fires. The protective stack layers a 1.2×ATR trailing stop, a breakeven at +1.2×ATR, and a stepped dynamic profit-lock that walks the stop forward in $2 increments minus a $1 buffer, with a 10% equity-drawdown gate that disables all activity if breached.
Long entries fire when the current bar closes above the upper Gaussian band (EMA(10) + 0.85×ATR(14)) while the previous two bars closed below it, price is above the H4 EMA(50) trend filter, the Gaussian slope is rising, the candle body is at least 60% of the full range, and price extends at least 0.3×ATR beyond the midline. Short entries mirror the rule on the lower band. Before the new order fires, any opposite position is closed via CloseOpposite(). The minimum-ATR gate (default 0.03) blocks entries during flat conditions.
Exits fire on a single primary signal: price closing back through the Gaussian midline in the direction opposite to the trade. The fixed 160-point TP and the protective stop ratchets handle the rest. There is no time-decay, no partial close, and no opposite-signal close beyond the midline-cross test. OnTick aborts entirely when the equity drawdown exceeds MaxDrawdownPercent.
Stop loss is computed as ATR_MultiplierSL × ATR(14) (default 1.2×ATR), with a HardSL_Points floor of 120 points so the stop never gets pinned too close. The stop is then ratcheted by the trailing stop, by the breakeven at +1.2×ATR, and by the dynamic profit-lock at every $2 step (minus $1 buffer). The stop only ever moves forward; there is no ratchet-back.
Take profit is a fixed 160-point target (FixedTP_Points = 160, applied via _Point to the entry price), independent of the ATR-derived stop. The TP is set on order placement and is not adjusted by the trailing or breakeven logic; it is replaced only when the dynamic profit-lock ratchets the stop.
Best suited to traders running XAUUSD on M5–H1 with a $100 minimum balance and tolerance for the longer holding periods of a 160-point fixed TP. The 0.85 multiplier and the 10% drawdown gate are tuned for low-to-medium spreads (under 20 points on gold), so a low-spread ECN or raw-spread account is preferred. The H4 trend filter makes this a higher-timeframe-aware breakout system, so traders should expect 3–6 trades per day per symbol at most, not high-frequency scalping behaviour. The AllowOnlyProfitableAdditions check requires $5 of profit across all open positions before a new entry, which fits traders who prefer measured pyramiding over rapid re-entries.
Strategy Logic
Pipsgrowth EX17023 Volatility — Strategy Logic Analysis (from .mq5 source)
Family: Volatility
Magic: 22217023
Version: 2.00
BRIEF:
Memory-optimized Gaussian Band breakout EA preserving all original logic with only 3 indicator handles. Uses auto-tuning filters, ATR-based SL, fixed TP, trailing stop, breakeven, dynamic lock profit, and drawdown control. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
GetBuffer()GaussianFilter()GetATR()GetEMA_HTF()PositionExists()CloseOpposite()AutoTuneFilters()CheckMaxDrawdown()CountOpenTrades()AllPositionsHaveMinProfit()IsNewBar()TryClose_EX17023()- ...and 2 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (5 total across 3 groups):
- [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_17023" // TradeComment - [=== Identity ===]
InpMagicNumber=22217023// Magic Number - [===
STRATEGYSETTINGS===] Timeframe = 0 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) - [===
STRATEGYSETTINGS===]TrendFilterTF= 6 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) - [===
PROFITLOCKSYSTEM===]LockMinusBuffer=1.0// --- GlobalVariables(Memory Optimized - ONLY 3HANDLES!)
// Pipsgrowth EX17023 Volatility — Execution Flow (from source analysis)
// Family: Volatility
// Memory-optimized Gaussian Band breakout EA preserving all original logic with only 3 indicator handles. Uses auto-tuning filters, ATR-based SL, fixed TP, trailing stop, breakeven, dynamic lock profit, and drawdown control. 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 |
|---|---|---|
| InpTradeComment | "Psgrowth.com Expert_17023" | Trade Comment |
| InpMagicNumber | 22217023 | Magic Number |
| Timeframe | 0 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) |
| TrendFilterTF | 6 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) |
| LockMinusBuffer | 1.0 | --- Global Variables (Memory Optimized - ONLY 3 HANDLES!) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX17023 GB10_5_2_OPTIMIZED — Memory-optimized Gaussian Band breakout, full 12-layer stack."
#include <Trade\Trade.mqh>
CTrade trade;
//--- Input Parameters (Better organized but SAME values)
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M5;
case 3: return PERIOD_M15;
case 4: return PERIOD_M30;
case 5: return PERIOD_H1;
case 6: return PERIOD_H4;
case 7: return PERIOD_D1;
default: return PERIOD_H1;
}
}
ENUM_TIMEFRAMES g_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_TrendFilterTF = PERIOD_H1;
input group "=== Identity ==="
input string InpTradeComment = "Psgrowth.com Expert_17023"; // Trade Comment
input ulong InpMagicNumber = 22217023; // Magic Number
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M5;
case 3: return PERIOD_M15;
case 4: return PERIOD_M30;
case 5: return PERIOD_H1;
case 6: return PERIOD_H4;
case 7: return PERIOD_D1;
default: return PERIOD_H1;
}
}
ENUM_TIMEFRAMES g_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_TrendFilterTF = PERIOD_H1;
input group "=== STRATEGY SETTINGS ==="
input bool UseAutoFilter = true;
input int Length = 10;
input double DistanceMultiplier = 0.85;
input int Timeframe = 0; // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1)
input int TrendFilterTF = 6; // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1)
input int TrendEMA = 50;
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M5;
case 3: return PERIOD_M15;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.