Pipsgrowth EX17026 Volatility
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX17026 GB111 — Production Gaussian Band breakout with robust execution, full 12-layer stack.
Overview
This EA trades a single Gaussian-style envelope around an EMA(14) midline, with the goal of catching the first thrust that follows a period of compression on XAUUSD M5. The midline is built from a 14-period EMA of close prices; the upper and lower bands are placed 1.2×ATR(14) on either side. Each new bar, the EA checks whether the close has just crossed from inside the envelope to outside it (a two-bar break: previous bar inside, current bar outside), whether the 14-EMA slope agrees with the trade direction, whether the higher-timeframe EMA(50) on the chart's HTF (H4 by default) is also on the right side of price, and whether the break distance exceeds MinBreakDistance × ATR (0.20 by default). When all of those conditions line up and the current bar's body makes up at least 45% of its total range, the EA opens a position in the direction of the break and closes any opposite-direction position held by the same magic number.
The position management layer is the part of the code that does most of the practical work. InitialSL_Points places the stop 80 points from the entry (80 cents on a 5-digit XAUUSD quote), and FixedTP_Points sets the take-profit at 200 points, giving a fixed 1:2.5 risk-to-reward ratio. The EA also has a Gaussian cross exit: with ExitBufferATRMultiplier set to 0.20, a long position is closed if price closes more than 0.20×ATR below the EMA(14) midline, and a short is closed on a close that far above it. Either the fixed TP or the cross exit, whichever comes first, takes the trade off. After the position is open, the EnableDynamicLockProfit block does the heavy lifting of protecting accrued gains. Each time floating profit crosses another LockProfitEvery_X_Dollars boundary ($2 by default), the EA recalculates where the new stop should be, then moves the existing stop forward by LockProfitEvery_X_Dollars minus LockMinusBuffer ($2 − $1 = $1) per step. The stop only ever moves in the favorable direction, and it never sets itself inside the broker's stops or freeze level, both of which are checked with the InsideStopsLevelForSLTP and InsideFreezeLevelForSLTP helpers before the modify is sent.
Sizing is controlled by two parallel paths. With UseRiskPercent enabled (off by default), ComputeRiskBasedLots reads AccountInfoDouble(ACCOUNT_EQUITY), multiplies it by RiskPercent (1.0%), divides by the per-lot dollar loss at the planned stop distance, and normalizes the result against the symbol's volume min/max/step. With UseRiskPercent disabled, the EA uses the static Lots input (0.10) directly. Both paths pass through NormalizeVolume, which clamps to the broker's volume envelope and rounds down to the nearest step before sending. The risk-side gates run before sizing is committed: CheckMaxDrawdown compares live equity to balance and refuses new entries once drawdown hits MaxDrawdownPercent (10%), TradingAllowedOnSymbol checks the symbol's trade mode (FULL / LONGONLY / SHORTONLY / CLOSEONLY), and SpreadTooWide refuses any tick where the live spread is above MaxSpreadPoints (40 points on XAUUSD by default). InsideStopsLevelForSLTP and InsideFreezeLevelForSLTP run after the SL/TP prices are computed and silently skip the entry if those prices would land inside the broker's protective band.
The 'no new entry until the basket is healthy' gate is a distinctive design choice in this EA. OneTradeOnly is true by default, so a fresh trade can only open if no position currently exists for the magic. If OneTradeOnly is off, MaxOpenTrades (5) caps the basket. If AllowOnlyProfitableAdditions is also on (default), AllPositionsHaveMinProfitByMagic walks the basket and refuses the new entry unless every existing position is showing at least MinProfitPerTradeToAdd ($5) of floating profit. That is the practical implementation of 'wait for the basket to breathe before adding' — it is not a martingale, but it is also not a free-for-all. OnlyNewBarEntries is true by default, so the signal logic is only re-evaluated on the open of a new M5 bar; intra-bar ticks do not open new positions, but they do continue to manage any open position via the management loop at the bottom of OnTick.
The trade engine itself is hardened against broker quirks. ResolveFillingMode reads SYMBOL_FILLING_MODE and prefers FOK, falls back to IOC, and only uses RETURN if neither is available. TradeBuy and TradeSell set the chosen filling mode before each order; on a TRADE_RETCODE_INVALID_FILL response, they cycle to the next available mode and retry. Once a ticket is in hand, TryClose_EX17026 and TryModify_EX17026 each loop up to three times on transient retcodes (REQUOTE, TIMEOUT, PRICE_OFF, PRICE_CHANGED) with a 200ms or 100ms Sleep between attempts. The three handle initializations in OnInit (maHandle, atrHandle, emaHandle) all fail the EA at startup if any of them returns INVALID_HANDLE.
The optional UseAutoFilter path is intentionally narrow. AutoTuneFilters only adjusts the MinATR threshold — bumping it to 0.5× the current spread if that exceeds the static MinATR — and it leaves the band's DistanceMultiplier and the break distance at their input values. UseAutoFilter is off by default; the source comment notes this is for 'more predictable behavior.' The Gaussian exit, dynamic lock profit, and the AllowOnlyProfitableAdditions gate are all on by default; turning them off essentially reduces the EA to a flat breakout trader with a fixed stop and a fixed take-profit.
What you should expect in backtest: with the default H1-coded Timeframe input (input 0 → H1 by MapTimeframeInt) and a TrendFilterTF of 6 (H4), the EA will look for breakouts on whatever chart period the user attaches it to, while the higher-timeframe side filter always comes from H4 EMA(50). On a quiet, range-bound XAUUSD day, the spread filter, the MinATR floor, and the 2-bar break requirement are what keep the EA out of chop. On a strong trend day, the dynamic lock profit is what turns a winner into a meaningful contributor by stair-stepping the stop up every $2 of profit and giving the position room to run toward the 200-point TP. The hard 10% drawdown cap and the spread gate are the safety net underneath the strategy itself.
Strategy Deep Dive
The OnInit block creates three indicator handles — an iMA(14, MODE_EMA, PRICE_CLOSE) for the Gaussian midline, an iATR(14) for the bands and the cross-exit buffer, and a higher-timeframe iMA(TrendEMA=50) on g_TrendFilterTF (H4 by default) for the side filter — and the EA refuses to start if any of the three fails. On each new M5 bar the EA recomputes the upper and lower bands as gauss ± DistanceMultiplier × ATR, requires a 2-bar break with slope agreement, HTF-side agreement, minimum break distance, and an optional 0.45 body-ratio, then closes the opposite and opens the new position via TradeBuy/TradeSell with filling-mode auto-resolution. The same tick walks the open-position loop, which checks the Gaussian cross exit (price vs. midline ± ExitBufferATRMultiplier × ATR) and the dynamic lock-profit stair-step (every $2 → +$1 SL step), both gated by the broker's stops and freeze levels before the modify is sent. The risk layer runs before the entry: CheckMaxDrawdown caps live DD at 10%, TradingAllowedOnSymbol and SpreadTooWide (40 points) refuse the tick, MinATR and MinBreakDistance gate volatility, and the AddProfit gate (every position must be at +$5 of floating profit) refuses new entries into a sick basket. Order execution goes through TryClose_EX17026 / TryModify_EX17026 with 3-retry loops on requote/timeout/price-off/price-changed (200ms/100ms Sleep), and TradeBuy/TradeSell cycle FOK → IOC → RETURN on TRADE_RETCODE_INVALID_FILL.
A long entry fires when the M5 close crosses above the EMA(14) midline + 1.2×ATR(14) upper band, with the previous bar's close still inside the band, the close above the H4 EMA(50) side filter, the EMA(14) slope pointing up, the close-band distance exceeding 0.20×ATR, and the current bar's body at least 45% of its full range. The short mirror requires the cross below the lower band, the slope pointing down, and the same body/HTF/break-distance conditions. Opposite-direction positions held under magic 22217026 are closed before the new trade is sent, and intra-bar ticks never open positions — only the open of a new M5 bar qualifies.
A trade exits when the live close crosses back through the EMA(14) midline by more than 0.20×ATR (0.20 is the ExitBufferATRMultiplier default) in the direction opposite to the position, or when price reaches the 200-point FixedTP_Points target, whichever happens first. The stop-out path uses the static 80-point InitialSL_Points unless the dynamic lock-profit mechanism has ratcheted the stop forward — in which case the ratcheted stop is what gets hit. There is no separate time-based exit and no partial-close path; the basket is managed as a whole through the AllowOnlyProfitableAdditions gate rather than per-position scaling.
Initial stop is 80 points (XAUUSD 5-digit quote, 80 cents) below the entry for longs and 80 points above for shorts. The stop is then ratcheted forward by the EnableDynamicLockProfit block — every $2 of floating profit moves the stop $1 in the favorable direction — and the ratchet-only-favorable logic plus the InsideStopsLevelForSLTP guard keep the moved stop from being set inside the broker's minimum-stops band. A 10% MaxDrawdownPercent hard gate refuses new entries before any SL is placed.
FixedTP_Points is 200 points on a 5-digit XAUUSD quote, giving a static 1:2.5 risk-to-reward against the 80-point initial stop. The TP price is sent with the order and held on the server; the only in-EA override is the Gaussian cross exit, which can take the trade off earlier if price closes back through the EMA(14) midline by 0.20×ATR. There is no partial TP, no trailing TP, and no time-decay TP — the take-profit line is fixed once the order is placed.
XAUUSD M5 with a minimum recommended balance of $100, MEDIUM risk tolerance, and an ECN or RAW-spread broker — the EA's 40-point MaxSpreadPoints filter assumes spreads under 4 cents typical, and the 10% MaxDrawdownPercent cap is sized for accounts that can absorb a single bad session. The default H4 EMA(50) trend filter and the EMA(14) bands are both tuned for the M5/M15/H1 progression on gold, and the 80-point stop / 200-point TP pair (1:2.5 RR) needs at least the 0.01-lot minimum and the broker's standard gold stops level to fire cleanly. Trading hours are unrestricted (no session filter input), so the EA is suitable for brokers with 24/5 gold availability and for traders who want round-the-clock M5 breakouts without a manual schedule.
Strategy Logic
Pipsgrowth EX17026 Volatility — Strategy Logic Analysis (from .mq5 source)
Family: Volatility
Magic: 22217026
Version: 2.00
BRIEF:
Production Gaussian Band breakout EA with robust execution and drawdown control. Uses configurable risk percent, initial SL, fixed TP, spread filter, new-bar entries, Gaussian cross exit, dynamic lock profit, and filling mode auto-resolution. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
GetTick()GetBuffer()GaussianFilter()GetATR()GetEMA_HTF()IsNewBar()CheckMaxDrawdown()TradingAllowedOnSymbol()NormalizeVolume()InsideStopsLevelForSLTP()InsideFreezeLevelForSLTP()SpreadTooWide()- ...and 12 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (16 total across 5 groups):
- [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_17026" // TradeComment - [=== Strategy Settings ===]
UseAutoFilter=false// Disabled by default for more predictable behavior - [=== Strategy Settings ===] Length = 14 // Increased for smoother signals
- [=== Strategy Settings ===]
DistanceMultiplier=1.2// Increased for wider bands - [=== Strategy Settings ===] Timeframe = 0 //
Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) - [=== Strategy Settings ===]
TrendFilterTF= 6 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) - [=== Position Sizing ===]
RiskPercent=1.0// percent of equity risked per trade - [=== Position Sizing ===] Lots =
0.10// used ifUseRiskPercent=false - [=== SL/TP and Trade Filters ===]
InitialSL_Points=80.0// initial SL in points (reduced) - [=== SL/TP and Trade Filters ===]
FixedTP_Points=200.0// fixed TP in points (increased for better R:R) - [=== SL/TP and Trade Filters ===]
MinATR=0.02// reduced minimumATR - [=== SL/TP and Trade Filters ===]
MinBreakDistance=0.20// reduced break distance requirement - [=== SL/TP and Trade Filters ===]
StrongCandleBodyRatio=0.45// reduced from0.60to allow more trades - [=== SL/TP and Trade Filters ===]
MaxSpreadPoints=40.0// don't trade above this spread - [=== Trade Engine Controls ===]
DeviationInPoints= 10 // slippage - [=== Trade Engine Controls ===]
AutoResolveFillingMode=true// ==================== Handles & State ====================//
// Pipsgrowth EX17026 Volatility — Execution Flow (from source analysis)
// Family: Volatility
// Production Gaussian Band breakout EA with robust execution and drawdown control. Uses configurable risk percent, initial SL, fixed TP, spread filter, new-bar entries, Gaussian cross exit, dynamic lock profit, and filling mode auto-resolution. 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_17026" | Trade Comment |
| UseAutoFilter | false | Disabled by default for more predictable behavior |
| Length | 14 | Increased for smoother signals |
| DistanceMultiplier | 1.2 | Increased for wider bands |
| 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) |
| RiskPercent | 1.0 | percent of equity risked per trade |
| Lots | 0.10 | used if UseRiskPercent=false |
| InitialSL_Points | 80.0 | initial SL in points (reduced) |
| FixedTP_Points | 200.0 | fixed TP in points (increased for better R:R) |
| MinATR | 0.02 | reduced minimum ATR |
| MinBreakDistance | 0.20 | reduced break distance requirement |
| StrongCandleBodyRatio | 0.45 | reduced from 0.60 to allow more trades |
| MaxSpreadPoints | 40.0 | don't trade above this spread |
| DeviationInPoints | 10 | slippage |
| AutoResolveFillingMode | true | ==================== Handles & State ====================// |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX17026 GB111 — Production Gaussian Band breakout with robust execution, full 12-layer stack."
#include <Trade/Trade.mqh>
CTrade trade;
//==================== Inputs ====================//
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_17026"; // Trade Comment
input ulong MagicNumber = 22217026;
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 = false; // Disabled by default for more predictable behavior
input int Length = 14; // Increased for smoother signals
input double DistanceMultiplier = 1.2; // Increased for wider bands
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;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.