Pipsgrowth EX15010 SMC-OrderBlock
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX15010 XAUUSD Liquidity Trap EA v2.1 — SMC liquidity zone scalper with improved indicator handling, full 12-layer stack.
Overview
EX15010 is a swing-pivot liquidity-trap reverser for XAUUSD, built around a single mechanical idea: where the market previously carved a swing high or swing low, that extreme price often contains resting stop orders — liquidity — and price tends to revisit those levels to grab that liquidity before reversing. The EA maps those levels as zones, then fires a counter-trend market order the moment price walks back into the zone with enough speed to qualify as a sweep. The structure is deliberately lean: four moving-average handles (two for the main timeframe, two extra created only when the higher-timeframe filter is enabled), a single 1% wide zone buffer, a 0.1% price-move threshold, and a fixed-lot sizing template. No indicator is wasted; no exit logic runs after the order is sent.
The detection engine lives in IdentifySwingPoints and its helpers FindSwingHigh and FindSwingLow. With the default SwingBarCount = 1 the engine looks for the simplest possible pivot — a bar whose high is higher than the bar before and after it, or whose low is lower than its neighbours. Each newly discovered pivot is stored in swingHighPrice / swingLowPrice and then converted into a horizontal liquidity zone in AddLiquidityZone. The zone is a 1% wide price band centred on the pivot (zoneLower = lowerLiquidityZone[i] and zoneUpper = zoneLower * 1.01 for buys, or the inverse for sells), which the EA draws on the chart as a dashed OBJ_HLINE — crimson above, dodger blue below. A 0.3% de-duplication check rejects new zones that crowd existing ones, so a tight consolidation that prints several pivots within 30 points does not flood the watch list. Zones expire after MaxZoneAge = 24 hours, and CleanupInactiveZones runs every four hours (TimeCurrent() % (3600*4) < 60) to strip dead entries from the arrays and delete the corresponding chart objects.
Signal generation happens once per closed bar inside GenerateSignals. The buy path, CheckBuySignals, walks the lower-zone array looking for a zone where SymbolInfo.Ask() is currently inside the 1% band. If price is inside, the engine calls CheckPriceSurge(true), which uses the larger of two metrics: the absolute percentage change from the open of the current bar to the live ask, and the percentage range of the last five bars (highest high minus lowest low, divided by the lowest low). Whichever is bigger has to clear PriceSurgePercent = 0.001 — i.e. 0.1% — for the surge gate to flip green. IsVolumeSurge then samples 21 tick volumes, averages bars one through twenty, and asks whether the live bar's tick volume exceeds the average by VolumeSurgeMultiplier = 1.5 times; that gate is only consulted when RequireVolumeSurge = true, which is the default. The third gate, IsZoneConfirmedByHigherTimeframe, is also off by default; with UseHigherTimeframeConfirmation = false it returns true immediately, but when armed it calls DetermineTrend on g_ConfirmationTimeframe and checks the MA20 vs MA50 cross — a +1 reading (MA20 above MA50) must confirm a buy off a lower zone, a -1 reading must confirm a sell off an upper zone, and a 0 reading (perfectly flat cross) is treated as permissive. When all three gates are green, the EA computes a stop loss 0.5% beyond the zone (stopLoss = zoneLower * 0.995 for buys, zoneUpper * 1.005 for sells) and a take profit at RewardToRiskRatio = 2.0 times the distance — a fixed 1:2 reward-to-risk geometry — then calls ExecuteBuyOrder or ExecuteSellOrder. After a fill, the zone is marked inactive so the same level cannot fire twice.
There is no post-entry logic. ManageOpenPositions is essentially a bookkeeping routine: it counts buys and sells, compares the current POSITION_TICKET array against the last tick's array to detect closed trades, and hands the result to UpdateTradeStatistics which updates win/loss counters, gross profit, gross loss, and the equity-curve drawdown. When consecutiveLosses reaches MaxConsecutiveLosses = 3, pauseUntilTime is set to TimeCurrent() + 60 * 60, and the next 60 minutes of ticks return immediately from OnTick after refreshing the dashboard. Three helper functions — TryClose_EX15010, TryClosePartial_EX15010, TryModify_EX15010 — are declared at the bottom of the file with a 3-attempt retry loop on REQUOTE/TIMEOUT/PRICE_OFF/PRICE_CHANGED codes, but they are not wired into the live order flow; the EA's Trade.Buy and Trade.Sell calls go through a separate CTrade Trade; object that does not reference these helpers, so the retry layer is dormant defensive code. The EnableTrailingStop = false default and the explicit // TODO: Add trailing stops and dynamic take profit in v3.0 comments in ManageOpenPositions make it clear that exits are intended to be handled entirely by the broker-side SL and TP attached at order time.
The risk scaffolding is thin but explicit. FixedLotSize = 0.01 is the only sizing input; CalculatePositionSize reads it and hands it to NormalizeLotSize, which clamps to SYMBOL_VOLUME_MIN/MAX and rounds to the symbol's lot step. MaxPositions = 5 caps total open positions across both directions, and the position counter is checked in both CheckBuySignals and CheckSellSignals before each fill. MaxSpreadPoints = 30 filters out wide-spread conditions at the top of OnTick — anything wider than 30 points returns immediately without generating signals. EnableTimeFilter = false by default means the 08:00–20:00 TradingHoursStart/End window is parsed but not enforced; turning it on makes IsWithinTradingHours gate the tradingAllowed flag. AvoidHighImpactNews = true and the two 30-minute buffer inputs are present in the parameter block, but no CalendarValueHistory or news-fetching call exists in the source — the flag is currently a no-op. The four global MA handles (g_ma20HandleMain, g_ma50HandleMain, and the two HTF twins) are released in OnDeinit and chart objects are wiped with ObjectsDeleteAll(0, "EA_"), but UpdateDashboard re-creates its labels on every tick so removing the EA cleanly clears the visible footprint.
Backtest this with realistic tick data and a commission per lot that matches the broker you intend to run live on. XAUUSD on M30 with SwingBarCount = 1 produces a high frequency of zones (almost every meaningful pivot counts), and the 0.1% price-surge threshold is low enough that the EA will trigger often; tightening the threshold to 0.005 or raising SwingBarCount to 2 or 3 will trade far less but with cleaner setups. The RewardToRiskRatio = 2.0 means the EA needs a win rate above ~34% to be net positive at 1:2, which is achievable on gold's reversal behaviour but unforgiving on the spread component — a 30-point ceiling on the spread filter is appropriate for accounts where the average spread sits around 10–20 points. The fixed 0.01 lot size and 5-position cap mean the worst-case portfolio heat is bounded but small; traders who want to scale this EA should pre-multiply the lot or run multiple instances on different magic numbers rather than relying on the EA's internal scaling, because there is no equity-based lot escalation, no martingale, and no recovery multiplier in this build.
Strategy Deep Dive
On every new bar OnTick calls AnalyzeMarketState to recompute a 20-bar average range as currentVolatility, then UpdateLiquidityZones invokes IdentifySwingPoints which scans the price series for 3-bar pivots via FindSwingHigh / FindSwingLow and stores each new pivot as a 1% wide horizontal zone in upperLiquidityZone[] / lowerLiquidityZone[], drawing dashed OBJ_HLINE lines on the chart. GenerateSignals then walks those zones: a buy needs price inside a lower zone with CheckPriceSurge returning true (open-to-current % or 5-bar range, whichever is bigger, exceeding 0.1%) and either RequireVolumeSurge off or IsVolumeSurge confirming a 1.5× tick-volume spike; an optional MA20/MA50 cross on g_ConfirmationTimeframe from DetermineTrend adds trend agreement when UseHigherTimeframeConfirmation = true. When all gates are green, ExecuteBuyOrder or ExecuteSellOrder sends a market order with a 0.5% buffer SL and a RewardToRiskRatio-based TP via the Trade object, marks the zone inactive, and a 3-consecutive-loss counter triggers a 60-minute pause in OnTick. The dashboard panel updates each tick and the four MA handles are released cleanly in OnDeinit.
Identifies a 3-bar swing high or low via FindSwingHigh / FindSwingLow (1 bar on each side by default), registers it as a 1% wide horizontal liquidity zone, then on each new bar fires a market order when the live ask/bid re-enters that zone while CheckPriceSurge confirms a price move ≥ 0.1% (open-to-current or 5-bar range, whichever is larger). Optional gates layer on top: IsVolumeSurge requires current tick volume ≥ 1.5× the 20-bar average when RequireVolumeSurge = true, and IsZoneConfirmedByHigherTimeframe requires MA20 vs MA50 to agree with the trade direction on the higher timeframe when UseHigherTimeframeConfirmation = true.
No post-entry management is wired — ManageOpenPositions is a bookkeeping routine that only updates win/loss counters, gross profit, gross loss, and tracks equity drawdown. Positions close exclusively at the broker-side stop loss or take profit that were attached at order time, or via the 3-consecutive-loss safety that flips pauseUntilTime forward by PauseMinutes = 60 and stops new entries without closing existing ones. The three retry helpers (TryClose_EX15010, TryClosePartial_EX15010, TryModify_EX15010) are defined at the bottom of the file but not called by the live order flow.
Stop loss is set 0.5% beyond the liquidity zone — stopLoss = zoneLower * 0.995 for buys and stopLoss = zoneUpper * 1.005 for sells — placed as a hard broker-side stop at order time. A spread filter of 30 points (configurable via MaxSpreadPoints) gates entries at the top of OnTick and prevents opening when the spread is too wide for the SL/TP geometry to remain meaningful.
Take profit is calculated as currentPrice ± (entry-to-SL distance) × RewardToRiskRatio, with the default ratio of 2.0 producing a fixed 1:2 reward-to-risk geometry from every entry. The TP value is normalised to the symbol's digits and submitted to the broker alongside the SL at order time, so positions are managed by the broker's price engine and not by the EA after the fill.
Best suited to XAUUSD on a single timeframe — the default Timeframe input is 4 (M30) per the source, although the catalogue lists M5 — with a minimum recommended balance of $100 given the fixed 0.01 lot sizing and 5-position cap. Run on an ECN or low-spread broker so the 30-point spread filter does not block valid M30 setups; Exness, IC Markets, and Pepperstone RAW are typical fits. The 08:00–20:00 time filter, 3-consecutive-loss / 60-minute pause, and avoidance of high-impact news windows should be left at their defaults for live deployment, with UseHigherTimeframeConfirmation = true enabled on accounts that already understand the MA20/MA50 cross logic. The 1:2 reward-to-risk geometry demands a broker with reliable SL/TP execution — VPS co-located near the broker server is recommended for sub-50ms round-trips.
Strategy Logic
Pipsgrowth EX15010 SMC-OrderBlock — Strategy Logic Analysis (from .mq5 source)
Family: SMC-OrderBlock
Magic: 22215010
Version: 2.00
BRIEF:
XAUUSD liquidity trap scalping EA v2.1 with improved indicator handling. Detects swing liquidity zones and trades reversals with volume/HTF confirmation. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
CheckIndicatorHandle()ReleaseIndicatorHandles()AnalyzeMarketState()ManageOpenPositions()NormalizeLotSize()CalculatePositionSize()UpdateTradeStatistics()UpdateLiquidityZones()IdentifySwingPoints()FindSwingHigh()FindSwingLow()AddLiquidityZone()- ...and 19 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (26 total across 5 groups):
- [=== General Settings ===]
MagicNumber=22215010// Magic Number - [=== General Settings ===]
InpTradeComment= "Psgrowth.com Expert_15010" // TradeComment - [=== General Settings ===]
EnableDebug=true// Enable Debug Messages - [=== General Settings ===] Timeframe = 4 //
Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Trading Timeframe - [=== Liquidity Trap Settings ===]
SwingBarCount= 1 // Number of bars for swing detection (smaller value = more swings) - [=== Liquidity Trap Settings ===]
MaxZoneAge= 24 // Maximum zone age in hours - [=== Liquidity Trap Settings ===]
PriceSurgePercent=0.001// Percent of price movement to consider as surge (0.001-0.2recommended) - [=== Liquidity Trap Settings ===]
RequireVolumeSurge=false// Require volume surge with price movement - [=== Liquidity Trap Settings ===]
VolumeSurgeMultiplier=1.5// Volume threshold as multiplier of average - [=== Entry Confirmation ===]
UseHigherTimeframeConfirmation=false// Use higherg_Timeframefor trend confirmation - [=== Entry Confirmation ===]
ConfirmationTimeframe= 6 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher timeframe for confirmation - [=== Entry Confirmation ===]
RequireVolumeConfirmation=false// Require volume confirmation for entry - [=== Risk Management ===]
FixedLotSize=0.01// Fixed lot size for all trades - [=== Risk Management ===]
RewardToRiskRatio=2.0// Reward to risk ratio - [=== Risk Management ===]
EnableTrailingStop=false// Enable trailing stop - [=== Risk Management ===]
TrailingStopPercent=50.0// Trailing stop as percentage of profit - [=== Risk Management ===]
MaxSpreadPoints= 30 // Maximum spread in points - [=== Risk Management ===]
MaxConsecutiveLosses= 3 // Max consecutive losses before pausing - [=== Risk Management ===]
PauseMinutes= 60 // Minutes to pause after max losses - [=== Risk Management ===]
MaxPositions= 5 // Maximum open positions - [=== Trade Filters ===]
EnableTimeFilter=false// Enable trading hours filter - [=== Trade Filters ===]
TradingHoursStart= "08:00" // Trading hours start (broker time) - [=== Trade Filters ===]
TradingHoursEnd= "20:00" // Trading hours end (broker time) - [=== Trade Filters ===]
AvoidHighImpactNews=true// Avoid trading during high impact news - [=== Trade Filters ===]
NewsBufferMinutesBefore= 30 // Minutes to avoid trading before news - [=== Trade Filters ===]
NewsBufferMinutesAfter= 30 // Minutes to avoid trading after news
// Pipsgrowth EX15010 SMC-OrderBlock — Execution Flow (from source analysis)
// Family: SMC-OrderBlock
// XAUUSD liquidity trap scalping EA v2.1 with improved indicator handling. Detects swing liquidity zones and trades reversals with volume/HTF confirmation. 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 |
|---|---|---|
| MagicNumber | 22215010 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_15010" | Trade Comment |
| EnableDebug | true | Enable Debug Messages |
| Timeframe | 4 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Trading Timeframe |
| SwingBarCount | 1 | Number of bars for swing detection (smaller value = more swings) |
| MaxZoneAge | 24 | Maximum zone age in hours |
| PriceSurgePercent | 0.001 | Percent of price movement to consider as surge (0.001-0.2 recommended) |
| RequireVolumeSurge | false | Require volume surge with price movement |
| VolumeSurgeMultiplier | 1.5 | Volume threshold as multiplier of average |
| UseHigherTimeframeConfirmation | false | Use higher g_Timeframe for trend confirmation |
| ConfirmationTimeframe | 6 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher timeframe for confirmation |
| RequireVolumeConfirmation | false | Require volume confirmation for entry |
| FixedLotSize | 0.01 | Fixed lot size for all trades |
| RewardToRiskRatio | 2.0 | Reward to risk ratio |
| EnableTrailingStop | false | Enable trailing stop |
| TrailingStopPercent | 50.0 | Trailing stop as percentage of profit |
| MaxSpreadPoints | 30 | Maximum spread in points |
| MaxConsecutiveLosses | 3 | Max consecutive losses before pausing |
| PauseMinutes | 60 | Minutes to pause after max losses |
| MaxPositions | 5 | Maximum open positions |
| EnableTimeFilter | false | Enable trading hours filter |
| TradingHoursStart | "08:00" | Trading hours start (broker time) |
| TradingHoursEnd | "20:00" | Trading hours end (broker time) |
| AvoidHighImpactNews | true | Avoid trading during high impact news |
| NewsBufferMinutesBefore | 30 | Minutes to avoid trading before news |
| NewsBufferMinutesAfter | 30 | Minutes to avoid trading after news |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX15010 XAUUSD Liquidity Trap EA v2.1 — SMC liquidity zone scalper with improved indicator handling, full 12-layer stack."
#include <Trade/Trade.mqh>
#include <Trade/SymbolInfo.mqh>
// Input parameters: 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_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_ConfirmationTimeframe = PERIOD_H1;
input group "=== General Settings ==="
input int MagicNumber = 22215010; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_15010"; // Trade Comment
input bool EnableDebug = true; // Enable Debug Messages
input int Timeframe = 4; // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Trading Timeframe
// Input parameters: Liquidity Trap 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_ConfirmationTimeframe = PERIOD_H1;
input group "=== Liquidity Trap Settings ==="
input int SwingBarCount = 1; // Number of bars for swing detection (smaller value = more swings)
input int MaxZoneAge = 24; // Maximum zone age in hours
input double PriceSurgePercent = 0.001; // Percent of price movement to consider as surge (0.001-0.2 recommended)
input bool RequireVolumeSurge = false; // Require volume surge with price movement
input double VolumeSurgeMultiplier = 1.5; // Volume threshold as multiplier of average
// Input parameters: Entry Confirmation
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)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.