Pipsgrowth EX17003 Volatility
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX17003 Good_after_GPT_comments — adaptive volatility trend scalper with dynamic additions, full 12-layer stack.
Overview
Pipsgrowth EX17003 Volatility is a short-horizon breakout engine designed to capture the first thrust of a move after price has coiled inside an ATR(14) envelope around a fast Gaussian-style EMA. The default setup runs on XAUUSD M5 with a H4 trend filter, but the indicator layer is portable to any FX major or metal and the signal logic itself does not care which symbol sits underneath the chart — only that the broker's tick size and pip factor feed the AutoTuneFilters() helper correctly. The version stamped in the header is 2.00 and the EA carries the magic number 22217003, with the on-screen comment Psgrowth.com Expert_17003.
The core signal uses an EMA of length 10 applied to close prices as a centre line, then draws an upper and lower band by adding and subtracting a multiple of the current 14-period ATR. The default band multiplier is 0.85, so the envelope is intentionally tight — most M5 candles close inside the band, and the EA treats an outside close as the first evidence that volatility is expanding in one direction. To keep the EA from firing on weak, doji-style bars, the OnTick() function checks the most recent candle and only accepts signals when the body of bar[0] is at least 60 percent of the full high–low range. A small body fails the strongCandle gate and the EA sits on its hands until the next bar.
A breakout alone is not enough. The EA also requires that the higher-timeframe EMA confirm the direction. By default the higher timeframe is H4 (TrendFilterTF = 6 in the input, which maps to PERIOD_H4 inside MapTimeframeInt) and the higher EMA period is 50, applied to close. A long entry needs the M5 close to print above the upper band while the M5 EMA itself is sloping up (gaussNow greater than gaussPrev) and the H4 EMA50 sits below current price. The mirror image triggers a short. This dual-layer filter is the reason the EA is classified as a trend scalper rather than a pure breakout system: the M5 break shows initiative, the H4 EMA50 shows the regime is compatible with that initiative.
There are three layers of risk control that fire on every tick before any new order is sent. First, CheckMaxDrawdown() reads account balance and equity and refuses to trade when the floating drawdown exceeds MaxDrawdownPercent, which defaults to 10 percent. Second, the EA reads the current spread and rejects the bar if it exceeds MaxAllowedSpreadPoints (default 25 points on a five-digit quote). Third, AutoTuneFilters() can be turned on, in which case the minimum ATR floor and break distance are recalculated from the live spread: when the spread is below 3 points the EA assumes a 4-decimal pip (pipFactor 0.0001) and sets minATR to three times that, otherwise it switches to a 2-decimal pip and adjusts accordingly. With UseAutoFilter left at its default true, the EA effectively self-tunes for both forex and metals without the user touching inputs.
The risk inputs cluster around a single concept: every position is anchored to ATR(14). ATR_MultiplierSL defaults to 1.2, and that value drives both the initial stop loss and the trailing-stop distance. FixedTP_Points is the take-profit in raw points (160 by default, around 16 pips on a 5-digit XAUUSD feed or 1.6 pips on FX). HardSL_Points is a 120-point safety cap that the trade object honours if ATR were to spike at entry. Position sizing is fixed-lot at 0.10, and the EA allows up to MaxOpenTrades (default 5) positions on the same symbol and magic at the same time. OneTradeOnly is exposed as a switch for traders who want a single-shot mode.
The scaling logic is what gives the EA its 'dynamic additions' label. The EA does not add a position unless every existing position on this symbol and magic is showing at least MinProfitPerTradeToAdd of floating profit (default $5), and the AllowOnlyProfitableAdditions switch (true by default) enforces that gate. In other words, you cannot pyramid into a losing trade — the basket has to be in the green before a new leg opens. After every new entry, a 30-second cooldown stamps lastTradeTimeBuy or lastTradeTimeSell so the EA does not fire again on the same impulse within the same bar.
ManageAllPositions() runs at the end of every tick and walks through the open positions. It applies three independent management passes. The breakeven pass moves the stop to the entry price once unrealised profit exceeds 1.2 ATR, so the trade is at minimum a scratch from that point on. The trailing pass then ratchets the stop every tick by 1.2 ATR behind the current bid (for longs) or above the current ask (for shorts), but only forward — the function only calls TryModify_EX17003() when the new stop is strictly better than the old one. The dynamic lock-profit pass walks the open profit in $2 steps (LockProfitEvery_X_Dollars) and pulls the stop up so that the trade would close at profit minus a $1 buffer (LockMinusBuffer). All three passes use the TryModify_EX17003() helper, which retries the modification up to three times with 100 ms sleeps on requote or timeout, so a noisy connection does not by itself cost you a stop move.
The exit side mirrors that defensive structure. The fixed take-profit at FixedTP_Points is the primary target, but in practice most winners exit either at the trailing stop or at the lock-profit level. There is no separate time-based exit or reversal exit in this build, and the EA does not block news windows or session opens. The default absence of a daily loss cap (no equity-curfew input) is deliberate: the 10 percent floating-drawdown gate inside CheckMaxDrawdown() is the only global kill, and on a $100 minimum-deposit account that gives roughly $10 of breathing room before the EA freezes. For a $1,000 account the same percentage gives $100 of room, so the gate scales with account size rather than absolute dollars.
What to expect in backtest: the M5 / H4 setup responds well when XAUUSD transitions between quiet Asian hours and the London open, because that is when ATR(14) is rising and the H4 EMA50 is still anchored in the prior session's range. Conversely, sustained low-volatility drift on a Monday morning in Asia will produce very few signals because MinATR and UseAutoFilter will both keep the EA out of the market. The strongCandle gate further filters the false breaks, so what you see on a chart is a series of clean M5 breakouts with the stop sitting 1.2 ATR behind and the target 16 points ahead, plus a second or third leg whenever the basket turns green. Run the EA on a five-digit XAUUSD feed with low spread (under 15 points) for the cleanest equity curve; on a wider feed the MaxAllowedSpreadPoints filter will start refusing a meaningful fraction of bars and reduce frequency. If you want a higher-trade-frequency build, drop Timeframe to 2 (M1) in the input and keep TrendFilterTF at 6 — the H4 filter is the only thing that prevents the M1 version from chopping itself to death.
Strategy Deep Dive
Pulls ATR(14) and a length-10 EMA into upper and lower bands at 0.85 × ATR distance, then watches each closed M5 bar for a 60 percent-body candle that pierces one of those bands in the direction of the H4 EMA50. The entry block is gated by CheckMaxDrawdown() (10 percent floating DD cap), a 25-point MaxAllowedSpreadPoints ceiling, and AutoTuneFilters() which rescales the ATR floor and band multiplier from the live spread when UseAutoFilter is on. ManageAllPositions() runs every tick after the entry decision, applying breakeven, ATR trailing, and a $2-step dynamic lock-profit in parallel, with all modifications routed through a three-retry TryModify_EX17003 helper.
A long triggers when the M5 candle closes above the upper Gaussian EMA band (current EMA10 + 0.85 × ATR(14)), with at least 60 percent body-to-range ratio, the EMA10 sloping up versus the previous bar, and the H4 EMA50 sitting below price. The mirror image triggers a short. AutoTuneFilters() raises the ATR floor and band multiplier on wider-spread pairs, and CheckMaxDrawdown() blocks the entry if floating drawdown exceeds 10 percent.
Exits are handled by the trailing stop at 1.2 × ATR(14) behind current price, the dynamic lock-profit ratchet that pulls the stop up by $2 increments minus a $1 buffer, and the fixed 160-point take-profit set at entry. ManageAllPositions() applies all three passes every tick, and TryModify_EX17003 retries the modification up to three times on requote.
Initial stop is 1.2 × ATR(14) below entry for longs and above entry for shorts, with a 120-point HardSL_Points cap. After profit exceeds 1.2 ATR, the breakeven pass moves the stop to entry, and the trailing pass ratchets it 1.2 ATR behind price on every subsequent tick.
Take-profit is fixed at 160 points from entry (FixedTP_Points). In practice most winners close at the trailing-stop or lock-profit level rather than at the fixed TP, because ManageAllPositions() tightens the stop every tick once the trade moves into profit.
Designed for XAUUSD on M5 with a H4 trend filter, minimum balance $100. Best on a five-digit low-spread feed (under 15 points) so the 25-point MaxAllowedSpreadPoints gate stays out of the way. The 10 percent floating-drawdown cap scales with account size, so on a $1,000 balance the EA has roughly $100 of headroom before freezing — traders comfortable with mid-frequency trend scalping on metals will get the cleanest equity curve.
Strategy Logic
Pipsgrowth EX17003 Volatility — Strategy Logic Analysis (from .mq5 source)
Family: Volatility
Magic: 22217003
Version: 2.00
BRIEF:
Adaptive volatility trend scalper using Gaussian EMA bands with ATR-based break distance. Enters on strong candle breakouts confirmed by HTF EMA trend filter, with dynamic additions, trailing, breakeven and dynamic lock-profit. Full 12-layer stack. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
GetBuffer()AutoTuneFilters()CheckMaxDrawdown()CountOpenTrades()AllPositionsHaveMinProfit()ManageAllPositions()TryClose_EX17003()TryClosePartial_EX17003()TryModify_EX17003()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (4 total across 2 groups):
- [=== Identity ===]
InpMagicNumber=22217003// MagicNumber(222 + Expert ID) - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_17003" // TradeComment - [=== Signal ===] Timeframe = 0 //
Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) - [=== Signal ===]
TrendFilterTF= 6 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1)
// Pipsgrowth EX17003 Volatility — Execution Flow (from source analysis)
// Family: Volatility
// Adaptive volatility trend scalper using Gaussian EMA bands with ATR-based break distance. Enters on strong candle breakouts confirmed by HTF EMA trend filter, with dynamic additions, trailing, breakeven and dynamic lock-profit. Full 12-layer stack. 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 |
|---|---|---|
| InpMagicNumber | 22217003 | Magic Number (222 + Expert ID) |
| InpTradeComment | "Psgrowth.com Expert_17003" | Trade Comment |
| 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) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX17003 Good_after_GPT_comments — adaptive volatility trend scalper with dynamic additions, full 12-layer stack."
#include <Trade/Trade.mqh>
CTrade trade;
//--- Input Settings
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 ulong InpMagicNumber = 22217003; // Magic Number (222 + Expert ID)
input string InpTradeComment = "Psgrowth.com Expert_17003"; // Trade Comment
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 "=== Capital ==="
input double Lots = 0.1;
input int MaxOpenTrades = 5;
input bool OneTradeOnly = false;
input double MinProfitPerTradeToAdd = 5.0;
input bool AllowOnlyProfitableAdditions = true;
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.