Pipsgrowth EX17004 Volatility
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX17004 10.5_334 — adaptive volatility trend scalper with dynamic additions, full 12-layer stack.
Overview
Pipsgrowth EX17004 is a lightweight adaptive volatility scalper whose signal is a single, repeatable rule: was the last bar on the chosen timeframe bullish or bearish. With zero external indicator handles attached at OnInit — the EA is unusual in this respect within the PipsGrowth family — every entry decision reduces to whether iClose is above or below iOpen on the main timeframe. The strategy compensates for that minimalism with a comparatively rich position-management layer: a per-direction trade cap, a hard per-trade stop, a breakeven ratchet, a fixed-distance trailing stop, a multi-tier dynamic profit lock, and a 20 percent account drawdown circuit breaker. The header advertises a 12-layer architecture (REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester) and in this implementation the heavy lifting lives in the MANAGE and EXIT bands rather than in SIGNAL.
The signal path is short. On every tick, OnTick calls ManageAllPositions first, then AreGlobalTradingConditionsMet to validate session, drawdown and spread, then reads iOpen and iClose for the bar at shift 0 of g_Main_Timeframe (default H1, configurable via Main_Timeframe to M1, M5, M15, M30, H4, or D1). It then counts current BUY and SELL tickets with CountOpenBuyTrades and CountOpenSellTrades, runs the base condition check in CheckBaseConditionsForNewTrade (which enforces OneTradeOnly, MaxOpenTradesInBothDirections, and AllowOnlyProfitableAdditions), and finally calls TryOpenBuy and TryOpenSell in the same tick. The primary trigger in IsPrimaryBuyTrigger returns true when c0_close > c0_open; the mirror in IsPrimarySellTrigger returns true when c0_close < c0_open. Those two checks are the only signal in the EA.
Confirmation is wired in but currently minimal. IsInitialBuyConfirmMet and IsInitialSellConfirmMet branch on the ConfirmationLogicType input. In CONFIRM_ALL_ACTIVE_AGREE mode the EA calls AllActiveBuyConfirmations, which in turn calls only CandleDirection_BuyConfirm — itself a re-check of close > open. In CONFIRM_WEIGHTED_SCORE mode the EA accumulates a 0/1 score and demands 70 percent agreement via WeightedBuyConfirmation. Because only one confirmation source is wired up, both modes are effectively equivalent in current operation: the trigger and the confirmation collapse to the same candle check. The // Extend: Add more indicator logic here as needed comments next to each confirmation function make the intended extension path explicit. If a future build adds MACD or RSI passes to those confirm functions, the same scaffolding will weight them into the score.
The capital-cap layer is where EX17004 differs from a typical single-shot scalper. The EA exposes three independent limits: MaxBuyTrades = 3, MaxSellTrades = 3, and MaxOpenTradesInBothDirections = 5. The combination means a basket can hold up to three longs and three shorts simultaneously, but no more than five tickets in total, and OneTradeOnly collapses the basket to a single position when set true. The addition path is conditional: when AllowOnlyProfitableAdditions = true (the default), AllPositionsHaveMinProfitInPoints runs across every open position and requires each one to be at least MinProfitPerTradeToAdd_Points = 180 in profit before a new ticket in any direction is allowed. A MinTimeBetweenTrades_Seconds = 30 throttle further prevents the EA from stacking orders within half a minute of one another in the same direction. Together those rules mean a trade in the same direction as a losing basket is blocked — the EA only scales into a direction whose existing tickets are at least 180 points in the green.
The risk layer is anchored on a single number. HardSL_Points = 120 is reused as the per-trade stop, the breakeven trigger distance, and the trailing stop distance. The breakeven in ManageBreakeven waits for price to reach openPrice + 120 * _Point, then moves the stop to openPrice + 1 * _Point (one point above entry). The trailing in ManageTrailingStop keeps a constant 120-point distance behind the current bid or ask and only ratchets forward, never back. MaxDrawdownPercent = 20.0 acts as the circuit breaker: when the equity falls more than 20 percent below the recorded balance, CheckMaxDrawdown returns false and no new entries are taken. A MaxAllowedSpreadPoints = 25 filter rejects entries when the spread on the active symbol exceeds 25 points, and MaxSlippagePoints = 5 is forwarded to the CTrade object for market orders.
The exit layer adds the dynamic profit lock. When EnableDynamicLockProfit = true, ManageDynamicLockProfit divides the current profit in points by LockProfitEvery_X_Points = 150, and for every complete multiple moves the stop to openPrice ± (multiple * 150 - 20) * _Point. The LockMinus_Y_Points_Buffer = 20 keeps a 20-point cushion so the lock sits a little below the locked-in profit, leaving room for spread on the way out. The lock is monotone: it only ever raises the stop on a long, only ever lowers it on a short. With the defaults, a 200-point profit locks 130 points, a 300-point profit locks 280, a 450-point profit locks 430, and so on, in 150-point steps.
The no-trade layer is a four-session filter. EnableSessionFilter is off by default, but when enabled IsTradingSessionActive walks Asian (00:00-08:00 server), London (08:00-16:00), New York (13:00-21:00), and a custom block through CheckSingleSession, which supports overnight windows that cross midnight. All four are configurable to the minute. A trader who wants to restrict EX17004 to a specific kill zone can disable the three built-in sessions and rely solely on the custom slot.
The retry scaffold at the bottom of the file — TryClose_EX17004, TryClosePartial_EX17004, and TryModify_EX17004 — wraps the CTrade API in a three-attempt loop with 200 ms (or 100 ms for modify) back-off after TRADE_RETCODE_REQUOTE, TRADE_RETCODE_TIMEOUT, TRADE_RETCODE_PRICE_OFF, or TRADE_RETCODE_PRICE_CHANGED. These helpers are present for completeness even though the current signal path doesn't invoke partial closes; they protect any future exit-and-replace logic against requotes. The trade comment is set to Psgrowth.com Expert_17004 and the magic is the standard 222 + expert ID = 22217004.
A practical note on backtesting. Because the entry signal is identical to the confirmation signal, the EA's hit rate tracks the bar-by-bar direction of the chosen timeframe. On H1 XAUUSD the trades are sparse; on M5 they cluster heavily. The dynamic profit lock tends to convert a higher proportion of trades into small scratches on gold, where 150-point swings inside a single 5-minute bar are common. The MaxAllowedSpreadPoints = 25 should be tightened on ECN accounts where typical XAUUSD spread is 10-15 points, since a 25-point ceiling will let almost anything through. The 20 percent drawdown circuit breaker is the dominant risk control and should not be raised without proportional capital backing. Net-net, EX17004 is a transparent, parameter-light scalper that the trader is meant to extend with their own indicator logic into the empty confirmation slots.
Strategy Deep Dive
On every tick ManageAllPositions runs the breakeven, trailing and dynamic-lock passes against every open position, then AreGlobalTradingConditionsMet validates session, drawdown and spread. The signal layer reads iOpen and iClose at shift 0 of g_Main_Timeframe; IsPrimaryBuyTrigger and IsPrimarySellTrigger compare them to produce a long or short vote, which IsInitialBuyConfirmMet / IsInitialSellConfirmMet pass through their active confirmation branch. TryOpenBuy and TryOpenSell then check the per-direction cap, the 30-second throttle, the MinProfitPerTradeToAdd 180-point floor and the trade-object slippage setting before sending the market order with the fixed SL and TP. The retry helpers TryClose_EX17004, TryClosePartial_EX17004 and TryModify_EX17004 handle requotes and price-change rejections with three attempts at 200 ms (100 ms for modify) back-off.
Long entries fire on a bullish candle (close > open) on the configured main timeframe via IsPrimaryBuyTrigger, then pass through the confirmation branch in IsInitialBuyConfirmMet (currently a duplicate candle-direction check). Short entries mirror on bearish candles. New entries are blocked when the basket is at the per-direction cap (MaxBuyTrades=3, MaxSellTrades=3) or at the total MaxOpenTradesInBothDirections=5 ceiling, and gated by a 30-second same-direction cooldown plus a 180-point per-trade profit requirement on existing positions when AllowOnlyProfitableAdditions is on.
Exits are managed by ManageAllPositions on every tick. The fixed TP at 160 points closes the position, the breakeven ratchet moves the stop to entry+1pt once price has advanced 120 points, the trailing stop holds a fixed 120-point distance and only steps forward, and the dynamic lock in ManageDynamicLockProfit ratchets the stop up every 150 points of additional profit with a 20-point buffer. The 20% account drawdown circuit breaker stops any new entries but does not actively close existing positions.
HardSL_Points = 120 points serves as the per-trade stop loss and is reused as the breakeven trigger distance and trailing distance. A 20% account drawdown circuit breaker in CheckMaxDrawdown halts all new entries when equity falls more than 20% below recorded balance. MaxAllowedSpreadPoints = 25 prevents entries on quotes with spreads wider than 25 points.
FixedTP_Points = 160 points (1.33:1 R:R against the 120-point stop). The TP is set at order entry and not modified afterward. Partial closes are scaffolded via TryClosePartial_EX17004 but not invoked by the current signal path; the dynamic lock in ManageDynamicLockProfit provides the de facto scaling exit by ratcheting the stop every 150 points of profit.
EX17004 is best for traders running XAUUSD on M5 or H1 with a low-spread ECN broker (the default 25-point spread ceiling should be tightened to 10-15 on ECN). Minimum recommended balance is $100 (MEDIUM risk), since the EA's per-trade lot is fixed at 0.01 and the per-direction cap of 3 buy + 3 sell is sized for retail micro-lot accounts. The session filter is off by default; turning it on with London 08:00-16:00 and New York 13:00-21:00 enabled and Asian disabled gives a London-NY overlap profile, the natural fit for XAUUSD volatility bursts. The 30-second same-direction throttle and 180-point addition profit requirement suit swing-continuation entries more than rapid-fire scalps.
Strategy Logic
Pipsgrowth EX17004 Volatility — Strategy Logic Analysis (from .mq5 source)
Family: Volatility
Magic: 22217004
Version: 2.00
BRIEF:
Adaptive volatility trend scalper with separate max buy/sell trade counts and total direction cap. Uses simplified SL/TP, dynamic profit locking, session filter and confirmation logic. 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:
CheckSingleSession()IsTradingSessionActive()GetBuffer()CheckMaxDrawdown()CountOpenTrades()CountOpenBuyTrades()CountOpenSellTrades()AllPositionsHaveMinProfitInPoints()ManageAllPositions()ManageDynamicLockProfit()ManageBreakeven()ManageTrailingStop()- ...and 17 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (43 total across 8 groups):
- [=== Identity ===]
InpMagicNumber=22217004// MagicNumber(222 + Expert ID) - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_17004" // TradeComment - [=== Capital ===] Lots =
0.01// Fixed Lot Size - [=== Capital ===]
MaxBuyTrades= 3 // Maximum simultaneous openBUYtrades - [=== Capital ===]
MaxSellTrades= 3 // Maximum simultaneous openSELLtrades - [=== Capital ===]
MaxOpenTradesInBothDirections= 5 // Maximum total open trades (buy + sell) - [=== Capital ===]
OneTradeOnly=false// Allow only one trade at a time - [=== Capital ===]
MinProfitPerTradeToAdd_Points= 180 // Minimum profit (Points) on existing trades to add a new one - [=== Capital ===]
AllowOnlyProfitableAdditions=true// Add new trades only if existing ones are in profit - [=== Capital ===]
MinTimeBetweenTrades_Seconds= 30 // Minimum time (seconds) between trades in the same direction - [=== Confirm ===]
ConfirmationLogicType=CONFIRM_ALL_ACTIVE_AGREE// Confirmation signals - [=== Risk ===]
FixedTP_Points= 160 // Fixed Take Profit in Points - [=== Risk ===]
HardSL_Points= 120 // Hard Stop Loss in Points - [=== Risk ===]
MaxDrawdownPercent=20.0// Maximum allowed account drawdown % - [=== Risk ===]
MaxAllowedSpreadPoints=25.0// Maximum allowed spread in Points - [=== Risk ===]
MaxSlippagePoints= 5 // Max allowed slippage in points for market orders - [=== Manage ===]
UseTrailingStop=true// Enable Trailing Stop - [=== Manage ===]
UseBreakeven=true// Enable Breakeven - [=== Exit ===]
EnableDynamicLockProfit=true// Enable Dynamic Profit Lock - [=== Exit ===]
LockProfitEvery_X_Points= 150 // Lock profit every X points gained - [=== Exit ===]
LockMinus_Y_Points_Buffer= 20 //Buffer(Points) to subtract when locking profit - [=== Signal ===] Main_Timeframe = 0 //
Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Main chart timeframe for signals - [=== No-Trade ===]
EnableSessionFilter=false// Enable Trading Session Filter - [=== No-Trade ===]
EnableAsianSession=true// Enable Asian Session - [=== No-Trade ===]
AsianSessionStartHour= 0 // Asian Session StartHour(0-23) - [=== No-Trade ===]
AsianSessionStartMinute= 0 // Asian Session StartMinute(0-59) - [=== No-Trade ===]
AsianSessionEndHour= 8 // Asian Session EndHour(0-23) - [=== No-Trade ===]
AsianSessionEndMinute= 0 // Asian Session EndMinute(0-59) - [=== No-Trade ===]
EnableLondonSession=true// Enable London Session - [=== No-Trade ===]
LondonSessionStartHour= 8 // London Session StartHour(0-23) - [=== No-Trade ===]
LondonSessionStartMinute= 0 // London Session StartMinute(0-59) - [=== No-Trade ===]
LondonSessionEndHour= 16 // London Session EndHour(0-23) - [=== No-Trade ===]
LondonSessionEndMinute= 0 // London Session EndMinute(0-59) - [=== No-Trade ===]
EnableNewYorkSession=true// Enable New York Session - [=== No-Trade ===]
NewYorkSessionStartHour= 13 // New York Session StartHour(0-23) - [=== No-Trade ===]
NewYorkSessionStartMinute= 0 // New York Session StartMinute(0-59) - [=== No-Trade ===]
NewYorkSessionEndHour= 21 // New York Session EndHour(0-23) - [=== No-Trade ===]
NewYorkSessionEndMinute= 0 // New York Session EndMinute(0-59) - [=== No-Trade ===]
EnableCustomSession=false// Enable Custom Session - [=== No-Trade ===]
CustomSessionStartHour= 0 // Custom Session StartHour(0-23) - [=== No-Trade ===]
CustomSessionStartMinute= 0 // Custom Session StartMinute(0-59) - [=== No-Trade ===]
CustomSessionEndHour= 0 // Custom Session EndHour(0-23) - [=== No-Trade ===]
CustomSessionEndMinute= 0 // Custom Session EndMinute(0-59)
// Pipsgrowth EX17004 Volatility — Execution Flow (from source analysis)
// Family: Volatility
// Adaptive volatility trend scalper with separate max buy/sell trade counts and total direction cap. Uses simplified SL/TP, dynamic profit locking, session filter and confirmation logic. 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 | 22217004 | Magic Number (222 + Expert ID) |
| InpTradeComment | "Psgrowth.com Expert_17004" | Trade Comment |
| Lots | 0.01 | Fixed Lot Size |
| MaxBuyTrades | 3 | Maximum simultaneous open BUY trades |
| MaxSellTrades | 3 | Maximum simultaneous open SELL trades |
| MaxOpenTradesInBothDirections | 5 | Maximum total open trades (buy + sell) |
| OneTradeOnly | false | Allow only one trade at a time |
| MinProfitPerTradeToAdd_Points | 180 | Minimum profit (Points) on existing trades to add a new one |
| AllowOnlyProfitableAdditions | true | Add new trades only if existing ones are in profit |
| MinTimeBetweenTrades_Seconds | 30 | Minimum time (seconds) between trades in the same direction |
| ConfirmationLogicType | CONFIRM_ALL_ACTIVE_AGREE | Confirmation signals |
| FixedTP_Points | 160 | Fixed Take Profit in Points |
| HardSL_Points | 120 | Hard Stop Loss in Points |
| MaxDrawdownPercent | 20.0 | Maximum allowed account drawdown % |
| MaxAllowedSpreadPoints | 25.0 | Maximum allowed spread in Points |
| MaxSlippagePoints | 5 | Max allowed slippage in points for market orders |
| UseTrailingStop | true | Enable Trailing Stop |
| UseBreakeven | true | Enable Breakeven |
| EnableDynamicLockProfit | true | Enable Dynamic Profit Lock |
| LockProfitEvery_X_Points | 150 | Lock profit every X points gained |
| LockMinus_Y_Points_Buffer | 20 | Buffer (Points) to subtract when locking profit |
| Main_Timeframe | 0 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Main chart timeframe for signals |
| EnableSessionFilter | false | Enable Trading Session Filter |
| EnableAsianSession | true | Enable Asian Session |
| AsianSessionStartHour | 0 | Asian Session Start Hour (0-23) |
| AsianSessionStartMinute | 0 | Asian Session Start Minute (0-59) |
| AsianSessionEndHour | 8 | Asian Session End Hour (0-23) |
| AsianSessionEndMinute | 0 | Asian Session End Minute (0-59) |
| EnableLondonSession | true | Enable London Session |
| LondonSessionStartHour | 8 | London Session Start Hour (0-23) |
| LondonSessionStartMinute | 0 | London Session Start Minute (0-59) |
| LondonSessionEndHour | 16 | London Session End Hour (0-23) |
| LondonSessionEndMinute | 0 | London Session End Minute (0-59) |
| EnableNewYorkSession | true | Enable New York Session |
| NewYorkSessionStartHour | 13 | New York Session Start Hour (0-23) |
| NewYorkSessionStartMinute | 0 | New York Session Start Minute (0-59) |
| NewYorkSessionEndHour | 21 | New York Session End Hour (0-23) |
| NewYorkSessionEndMinute | 0 | New York Session End Minute (0-59) |
| EnableCustomSession | false | Enable Custom Session |
| CustomSessionStartHour | 0 | Custom Session Start Hour (0-23) |
| CustomSessionStartMinute | 0 | Custom Session Start Minute (0-59) |
| CustomSessionEndHour | 0 | Custom Session End Hour (0-23) |
| CustomSessionEndMinute | 0 | Custom Session End Minute (0-59) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX17004 10.5_334 — adaptive volatility trend scalper with dynamic additions, full 12-layer stack."
#include <Trade/Trade.mqh>
// #include <ChartObjects/ChartObjectsTxtControls.mqh>
CTrade trade;
// CChartObjectLabel ExtPanel;
//--- General 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_Main_Timeframe = PERIOD_H1;
input group "=== Identity ==="
input ulong InpMagicNumber = 22217004; // Magic Number (222 + Expert ID)
input string InpTradeComment = "Psgrowth.com Expert_17004"; // 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_Main_Timeframe = PERIOD_H1;
input group "=== Capital ==="
input double Lots = 0.01; // Fixed Lot Size
input int MaxBuyTrades = 3; // Maximum simultaneous open BUY trades
input int MaxSellTrades = 3; // Maximum simultaneous open SELL trades
input int MaxOpenTradesInBothDirections = 5; // Maximum total open trades (buy + sell)
input bool OneTradeOnly = false; // Allow only one trade at a time
input int MinProfitPerTradeToAdd_Points = 180; // Minimum profit (Points) on existing trades to add a new one
input bool AllowOnlyProfitableAdditions = true; // Add new trades only if existing ones are in profit
input int MinTimeBetweenTrades_Seconds = 30; // Minimum time (seconds) between trades in the same direction
//+------------------------------------------------------------------+
//| Confirmation Logic Strategy |
//+------------------------------------------------------------------+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.