Pipsgrowth EX17024 Volatility
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX17024 GB10_5_2v1_1_copy — Gaussian Band breakout v1.1 with Gaussian cross exit, full 12-layer stack.
Overview
Pipsgrowth EX17024 is a band-breakout EA that reads a smooth midline from a 10-period EMA on close, lays a ±0.85×ATR(14) envelope around it, and waits for a strong-bodied candle to punch through the envelope on the side that agrees with the slope of the midline and with the trend of a higher-timeframe EMA(50). The midline is labelled in the source as a "Gaussian" but is technically a standard exponential moving average — the label is a brand choice, the math is EMA. The EA runs all of its decisions on a single tick handler; it does not maintain state between bars beyond the cached values pulled from the indicator handles, so the OnTick routine stays tight and predictable.
The trade stack is intentionally narrow: three indicator handles, three working buffers, and a single CTrade object. The first handle is iMA(_Symbol, g_Timeframe, 10, 0, MODE_EMA, PRICE_CLOSE), which feeds the midline and the upper/lower bands. The second handle is iATR(_Symbol, g_Timeframe, 14), which scales the envelope width and gates entries against the AutoTuneFilters() floor. The third handle is iMA(_Symbol, g_TrendFilterTF, 50, 0, MODE_EMA, PRICE_CLOSE), where g_TrendFilterTF defaults to H4 — the higher-timeframe trend filter that the entry logic uses to confirm direction. All three handles are created in OnInit() and validated together; if any returns INVALID_HANDLE, the EA refuses to start with INIT_FAILED.
Entries are gated by a stack of conditions that all have to agree on the same tick. The candle-strength check requires the body of the most recent bar to be at least 60% of its full size (StrongCandleBodyRatio input), filtering out dojis and pin bars that lack conviction. The 2-bar inside-then-outside check requires pricePrev and pricePrev2 to have closed on the inside of the band while the current bar closes outside — a deliberate anti-whipsaw gate that prevents the EA from entering on the first touch. The slope check requires the current midline value to be either above or below the previous bar's midline value, depending on direction. The break-distance check requires the gap between price and the midline to exceed 0.3×ATR, which rules out marginal grazes. The HTF filter requires price to be on the same side of the H4 EMA(50) as the trade direction. Only when all five gates fire together does the EA fire a Buy or Sell through the CTrade object.
Pre-trade risk gates run before any entry is permitted. CheckMaxDrawdown() compares the floating equity against the balance and refuses to trade if the drawdown exceeds MaxDrawdownPercent (10% by default). The ATR floor comes from AutoTuneFilters(), which samples the current spread and decides whether the symbol behaves like a 4-decimal forex pair (pipFactor 0.0001) or a 2-decimal metals pair (pipFactor 0.01), then sets minATR to 3× that factor; the entry is suppressed when current ATR is below the floor. The position-count gate allows up to MaxOpenTrades (5 by default, but OneTradeOnly=true default restricts to a single position). The profitability gate, when AllowOnlyProfitableAdditions is enabled, requires every currently open position on the symbol to be sitting on at least MinProfitPerTradeToAdd ($5) of unrealized profit before a new entry is allowed — a conviction filter that keeps the EA from scaling into a losing basket.
Exits are driven by two mechanisms that work in parallel. The first is a fixed take-profit at FixedTP_Points (160 points by default) and an initial stop-loss at InitialSL_Points (100 points), set on entry. With gold quoted to 2 decimals the defaults map to a 1.6:1 reward-to-risk geometry on the initial brackets. The second is the Gaussian-cross exit, controlled by EnableGaussianExit. When the buffer multiplier ExitBufferATRMultiplier is set to zero, the EA closes the trade the moment price crosses back through the midline. When the buffer is non-zero (0.2×ATR by default), the exit level is shifted by that buffer — buys close only when price dips below midline minus 0.2×ATR, sells close only when price rallies above midline plus 0.2×ATR. The buffer is the practical way to avoid being shaken out by a marginal cross that immediately reverses.
The dynamic lock-profit ratchet is the third exit arm. EnableDynamicLockProfit walks the position's floating profit and computes how many $2 steps (LockProfitEvery_X_Dollars, default $2) of profit have been banked, then translates that dollar count into a price distance using the symbol's tick value, tick size, and current position volume. The new stop is set to entry plus that distance for buys, entry minus that distance for sells, minus a $1 buffer (LockMinusBuffer). The ratchet only ever moves the stop forward, never backward — the comparison newSL > sl for buys and newSL < sl for sells guarantees monotonic protection. The result is that once a trade has earned $2 of profit, the stop jumps to entry + $1; at $4 of profit, it jumps to entry + $3; and so on, with the floor rising in lockstep with the unrealized P&L.
Position-management execution goes through two wrapper functions, TryClose_EX17024 and TryModify_EX17024, both of which retry up to three times on requote, timeout, price-changed, and price-off retcodes, with a 200ms sleep between close attempts and a 100ms sleep between modify attempts. Any retcode outside that list breaks the retry loop and leaves the modification for the next tick. The wrappers are duplicated for symbol-based and ticket-based invocation; both paths are present because some calls in the EA use the symbol string and others use the position ticket.
Risk profile and runtime expectations: with default 0.1-lot entries, the EA can hold up to 5 concurrent positions on a single symbol, although the OneTradeOnly flag collapses that to one. The 10% drawdown cap combined with the 160-point fixed TP and 100-point initial SL means that a worst-case basket of 5 trades against the EA on a single symbol would be approximately 500 points of initial stop, or 0.5% of a 0.01-lot-per-point account. The ratchet then protects any profitable leg. On a $1,000 starting balance with 0.1 lots on gold, one losing basket consumes 1.0% of the account; the 10% drawdown gate triggers after roughly 10 such baskets, which is a generous safety margin for a single-symbol strategy. The EA was built and tested for XAUUSD on M5, but the input group includes a portable Timeframe knob and a TrendFilterTF knob that lets it run on FX majors and on H1 if you prefer a slower cadence. The H4 trend filter is the constant that keeps entries aligned with the dominant higher-timeframe direction regardless of the trading timeframe chosen.
Strategy Deep Dive
Pipsgrowth EX17024 runs its entire decision tree on a single OnTick handler. Three indicator handles are created in OnInit: a 10-period EMA on close (the "Gaussian" midline), an ATR(14) that scales the band width, and an EMA(50) on the H4 trend-filter timeframe. Each tick reads current and prior bar values, draws the upper and lower bands at midline ± 0.85×ATR, and refuses to trade when CheckMaxDrawdown reports a drawdown over 10% or when the current ATR is below the AutoTuneFilters floor. The five-gate entry stack — strong body, two-bar inside-then-outside, slope direction, H4 trend agreement, and 0.3×ATR break distance — must all fire on the same tick for a Buy or Sell to be sent. Open positions are managed by a fixed TP at 160 points, a 160-point ATR-buffered Gaussian cross exit, and a $2-step lock-profit ratchet that walks the stop forward through TryModify_EX17024. Retry wrappers handle requote and price-changed retcodes with three attempts and a 100-200ms backoff.
Buys fire when the current bar closes above the upper Gaussian band (10-EMA + 0.85×ATR) and the two prior bars closed inside the band, with a strong body (≥60% of candle size), a positive midline slope, price above the H4 EMA(50) trend filter, and a break distance exceeding 0.3×ATR. Sells mirror the same five-gate stack in the opposite direction. The entry block is gated further by an ATR floor (AutoTuneFilters), a 10% drawdown cap, a MaxOpenTrades ceiling, and an optional profitability filter that requires every open position to be sitting on ≥$5 of unrealized P&L.
Positions exit by one of three paths: a fixed take-profit at 160 points, a Gaussian-cross exit (direct at the midline, or buffered by 0.2×ATR when the buffer is non-zero), or a dynamic lock-profit ratchet that walks the stop forward in $2 increments with a $1 buffer as unrealized profit grows. The cross exit fires on the same tick the bar prints, so an immediate midline retest is closed before it can reverse the trade. The dynamic lock never ratchets backward; once a step is locked it stays.
Initial stop is fixed at 100 points from entry, set on the order ticket through CTrade. The dynamic lock-profit arm (EnableDynamicLockProfit) moves the stop forward in $2 profit steps with a $1 buffer, recomputed every tick on the open position, ensuring the floor rises monotonically as unrealized P&L grows.
Fixed take-profit is set at 160 points from entry on every order, giving a 1.6:1 reward-to-risk geometry against the 100-point initial stop. The TP is placed on the order ticket at entry and is not modified by the ratchet — only the SL walks forward.
Designed for XAUUSD on M5 with a $100 minimum account, but the Timeframe input (1-7 mapped) and TrendFilterTF input (1-7 mapped) make it portable to FX majors and to M15/H1 cadences. The 0.1-lot default and 100/160 point SL/TP brackets work on a standard gold account with a low-spread ECN or RAW broker, and the H4 trend filter assumes a broker that feeds accurate H4 history so the EMA(50) trend read stays meaningful. The MEDIUM risk label reflects the 5-position basket ceiling, the 10% drawdown cap, and the 1.6:1 reward-to-risk geometry on the initial brackets — the dynamic lock-profit ratchet then protects the runners.
Strategy Logic
Pipsgrowth EX17024 Volatility — Strategy Logic Analysis (from .mq5 source)
Family: Volatility
Magic: 22217024
Version: 2.00
BRIEF:
Gaussian Band breakout EA v1.1 with configurable ATR period, strong candle body ratio, and Gaussian cross exit. Uses auto-tuning filters, initial SL, fixed TP, 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()TryClose_EX17024()TryClosePartial_EX17024()- ...and 1 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (14 total across 5 groups):
- [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_17024" // TradeComment - [=== Identity ===]
InpMagicNumber=22217024// Magic Number - [=== 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) - [=== Trade Management ===]
InitialSL_Points= 100 // Initial Stop Loss in Points - [=== Trade Management ===]
MaxDrawdownPercent=10.0// Max drawdown % allowed - [=== Trade Management ===]
MaxOpenTrades= 5 // Maximum allowed open trades at the same time - [=== Trade Management ===]
AllowOnlyProfitableAdditions=true// Enable filter - [=== Trade Management ===]
MinProfitPerTradeToAdd=5.0// Minimum $ profit required per existing trade - [=== Dynamic Lock Profit ===]
LockProfitEvery_X_Dollars=2.0// Step: every $6 profit - [=== Dynamic Lock Profit ===]
LockMinusBuffer=1.0// Lock profit minus $1 buffer - [=== Exit Settings ===]
StrongCandleBodyRatio=0.6// Minimum body to candle size ratio for a strong candle - [=== Exit Settings ===]
ExitBufferATRMultiplier=0.2//ATRMultiplier for Gaussian ExitBuffer(0 for direct cross) - [=== Exit Settings ===]
EnableGaussianExit=true// Enable/Disable Gaussian Cross Exit
// Pipsgrowth EX17024 Volatility — Execution Flow (from source analysis)
// Family: Volatility
// Gaussian Band breakout EA v1.1 with configurable ATR period, strong candle body ratio, and Gaussian cross exit. Uses auto-tuning filters, initial SL, fixed TP, 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_17024" | Trade Comment |
| InpMagicNumber | 22217024 | 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) |
| InitialSL_Points | 100 | Initial Stop Loss in Points |
| MaxDrawdownPercent | 10.0 | Max drawdown % allowed |
| MaxOpenTrades | 5 | Maximum allowed open trades at the same time |
| AllowOnlyProfitableAdditions | true | Enable filter |
| MinProfitPerTradeToAdd | 5.0 | Minimum $ profit required per existing trade |
| LockProfitEvery_X_Dollars | 2.0 | Step: every $6 profit |
| LockMinusBuffer | 1.0 | Lock profit minus $1 buffer |
| StrongCandleBodyRatio | 0.6 | Minimum body to candle size ratio for a strong candle |
| ExitBufferATRMultiplier | 0.2 | ATR Multiplier for Gaussian Exit Buffer (0 for direct cross) |
| EnableGaussianExit | true | Enable/Disable Gaussian Cross Exit |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX17024 GB10_5_2v1_1_copy — Gaussian Band breakout v1.1 with Gaussian cross exit, full 12-layer stack."
#include <Trade\Trade.mqh>
CTrade trade;
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_17024"; // Trade Comment
input ulong InpMagicNumber = 22217024; // 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;
case 4: return PERIOD_M30;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.