P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX15012 SMC-OrderBlock

MT5 Expert Advisor (Open Source) · XAUUSD · M5

Pipsgrowth.com EX15012 XAUUSD Liquidity Trap EA v3.0 — SMC liquidity zone scalper with confirmation signals, full 12-layer stack.

Overview

Pipsgrowth EX15012 is an XAUUSD liquidity-trap scalper that maps the chart as a sequence of swing-anchored demand and supply pools, then waits for price to return into one of those pools and reject from it. The whole logic is anchored to liquidity zones, not to candles or indicators: the EA keeps an internal list of swing-high prices (upper zones) and swing-low prices (lower zones), drawn on the chart as dashed horizontal lines, and every decision on every new bar starts by asking 'is the current price touching any active zone?' If yes, the four-gate confirmation chain runs. If no, the EA does nothing that bar.

The 3-bar swing detector is implemented by FindSwingHigh and FindSwingLow. With SwingBarCount = 1 (the default), an index i is considered a swing high only if high[i] > high[i-1] and high[i] > high[i+1], and the swing low mirror is the same. The function walks forward from barsEachSide and returns the first qualifying index. Whenever IdentifySwingPoints finds a swing it has not yet recorded, it stamps the price and time into the upperLiquidityZone[] or lowerLiquidityZone[] arrays and calls AddLiquidityZone, which de-duplicates by skipping any new zone within 0.3% of an existing one and then calls MarkLiquidityZone to draw the dashed OBJ_HLINE chart object (crimson for upper, dodger blue for lower). Every 4 hours, CleanupInactiveZones walks the arrays, deletes the chart objects for deactivated zones, and rebuilds the global arrays. Zones also self-expire after MaxZoneAge = 24 hours, computed from zoneCreationTime against the current time.

Entry is gated. When OnTick detects a new bar (or the first tick), GenerateSignals calls CheckBuySignals and CheckSellSignals. For a buy, the EA asks whether the ask price sits inside the lower zone's 1% band — that is, currentPrice >= zoneLower AND currentPrice <= zoneLower * 1.01. For a sell, the mirror is the upper zone's 1% downward band. If the price is in the band, four sub-checks run: CheckPriceSurge (open-to-current percent change over 10 bars, or 5-bar high-low range percent, whichever is larger, must exceed PriceSurgePercent * 100 = 0.1% by default), IsVolumeSurge (current tick volume ≥ 1.5x the 20-bar average — bypassed if RequireVolumeSurge = false, which is the default), IsZoneConfirmedByHigherTimeframe (calls DetermineTrend on the H4 default timeframe, comparing MA20 vs MA50 — bypassed if UseHigherTimeframeConfirmation = false, the default, and permissive when the trend is 0), and IsBullishEngulfingPattern / IsBearishEngulfingPattern (walks back EngulfingLookback = 3 bars looking for a candle whose body engulfs the prior opposite-color candle's body — this is the only one of the four gates that is hard-on by default). All four must pass. After the order fires, zoneActive[i] = false deactivates the zone so it cannot be re-traded.

Sizing and stops are deliberately simple. CalculatePositionSize ignores the stopLossPoints argument and returns the fixed FixedLotSize = 0.01 lots, normalized to the symbol's lot step. For a buy, the stop is zoneLower * (1 - 0.005) — 0.5% below the zone. For a sell, the mirror is 0.5% above. The take-profit is then currentPrice + (currentPrice - stopLoss) * RewardToRiskRatio for buys, with RewardToRiskRatio = 2.0 default producing a clean 1:2 reward-to-risk. The order is sent via Trade.Buy / Trade.Sell with the comment Psgrowth.com Expert_15012 and magic 22215012.

There is no progressive profit lock, no post-entry management that re-runs the swing logic, and no time-based exit. The trailing stop input exists (EnableTrailingStop, TrailingStopPercent = 50%) but the code path that would actually move the stop is not wired into ManageOpenPositions — the only thing that function does is count buys/sells, walk the last 24 hours of HistorySelect to update UpdateTradeStatistics, and log position counts. The high-impact-news input AvoidHighImpactNews = true (with NewsBufferMinutesBefore = 30, NewsBufferMinutesAfter = 30) is similarly a dead switch — there is no news API integration in the file. The three retry helpers at the end of the source — TryClose_EX15012, TryClosePartial_EX15012, TryModify_EX15012 — are defined against a separate CTrade g_trade_wrappers_EX15012 instance, retry up to 3 times on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED, and are not called from OnTick, ManageOpenPositions, ExecuteBuyOrder, or ExecuteSellOrder. They are present as scaffolding for a v3.0 build that the source explicitly TODO-marks: // TODO: Add trailing stops and dynamic take profit in v3.0 and // TODO: Add additional market analysis in v3.0.

Higher-timeframe trend, when used, is read by DetermineTrend which pulls MA(20) SMA and MA(50) SMA from either the main or the higher timeframe handle set. The MA handles — g_ma20HandleMain, g_ma50HandleMain, and the optional g_ma20HandleHTF, g_ma50HandleHTF — are created in OnInit only if the corresponding input is enabled, and they are released by ReleaseIndicatorHandles in OnDeinit. The function uses a progressive-delay retry loop (5 attempts, 100ms × attempt number) for the CopyBuffer call, and resets the handle to INVALID_HANDLE on persistent failure so the next call re-creates it. The MapTimeframeInt helper that maps the integer Timeframe input (1=M1, 2=M5, 3=M15, 4=M30, 5=H1, 6=H4, 7=D1) to an ENUM_TIMEFRAMES constant is defined five separate times in the source — a code-quality issue, not a logic bug.

Risk controls in the EA are intentionally minimal. MaxConsecutiveLosses = 3 triggers pauseUntilTime = TimeCurrent() + PauseMinutes * 60 (60 minutes default). MaxPositions = 5 is the cap. MaxSpreadPoints = 30 blocks any tick whose current spread exceeds 30 points (XAUUSD on a tight broker will run around 10–20 points, so this is mostly a stale-quote and rollover guard). The EnableTimeFilter switch is off by default; when turned on it parses the TradingHoursStart (08:00) and TradingHoursEnd (20:00) strings into minute-of-day and gates signals to that window in broker time. OnInit also runs an ECN detection heuristic: if ask - bid < 3 * point, the EA sets Trade.SetDeviationInPoints(10) for slippage. The UpdateDashboard routine writes a six-line label panel showing title, status, lot+RR, active upper/lower zone count, total trades + win/loss, profit factor (color-coded green ≥ 2.0, yellow ≥ 1.0, red below), and current signal. ObjectsDeleteAll(0, "EA_") cleans both the zone lines and the dashboard on deinit.

The .mq5 ships with the conservative defaults that a conservative trader would want: 0.01 lots, 1:2 reward-to-risk, 3-bar swing detection, 0.3% de-dup between zones, 1% zone-band entry, 24-hour zone lifetime, only the engulfing confirmation hard-on out of the four gates, a 3-loss / 60-minute pause, and a 5-position cap. The progressive profit lock, trailing stop, and news filter that the family name suggests are visible in the input list but not actually wired to the live trade path — that is the single most important operational fact for anyone considering this EA, and it is what the source file's own TODO comments confirm.

Strategy Deep Dive

IdentifySwingPoints runs on every new bar, calls FindSwingHigh and FindSwingLow with SwingBarCount=1 (3-bar pattern, not 5-bar), and when a new swing is detected it triggers AddLiquidityZone, which de-duplicates at a 0.3% threshold and marks the chart with a dashed OBJ_HLINE. CleanupInactiveZones runs every 4 hours and removes any chart objects for zones whose active flag is false or whose 24-hour MaxZoneAge has elapsed. When the next new bar opens, CheckBuySignals walks the lower zone array and tests whether currentPrice sits in the [zoneLower, zoneLower1.01] band; if yes, four gates run in sequence — CheckPriceSurge (open-to-current over 10 bars, or 5-bar high-low range, max of the two, threshold 0.1%), IsVolumeSurge (skipped by default), IsZoneConfirmedByHigherTimeframe (skipped by default, calls DetermineTrend on H4 to compare MA20 vs MA50, permissive at 0), and IsBullishEngulfingPattern (the only default-on gate, walks back 3 bars). All four must pass. ExecuteBuyOrder then sends a fixed 0.01-lot market order with SL=zoneLower0.995 and TP=entry+(entry-SL)*2.0 via Trade.Buy, and sets zoneActive[i]=false. ManageOpenPositions is the only per-tick function that runs on every tick, but it does not trail, lock profit, or apply a time-exit; it only updates the win/loss counters via UpdateTradeStatistics.

Entry Signal

A buy fires when the ask price is inside a lower zone's 1% band (currentPrice >= zoneLower AND currentPrice <= zoneLower * 1.01) AND all four confirmation gates pass: open-to-current or 5-bar-range price surge ≥ PriceSurgePercent * 100 (0.1% default), volume ≥ 1.5× 20-bar average (skipped if RequireVolumeSurge = false, the default), H4 MA20 vs MA50 trend aligned with the zone direction (skipped if UseHigherTimeframeConfirmation = false, the default), and a bullish engulfing pattern within the last 3 bars. A sell is the mirror on the upper zone. After execution, the zone is deactivated.

Exit Signal

Positions close only when the broker-side SL or TP is hit, because the source has no post-entry management that re-runs the signal logic, no time-based exit, and no progressive profit lock. ManageOpenPositions only counts buy/sell totals, walks the last 24 hours of history to update trade statistics, and resets the consecutive-loss counter on a winner.

Stop Loss

Per-trade stop-loss is placed 0.5% past the liquidity zone: for a buy, stopLoss = zoneLower * (1 - 0.005); for a sell, stopLoss = zoneUpper * (1 + 0.005). The level is sent broker-side at entry and is never modified after the order opens — the trailing-stop input is exposed but not wired into ManageOpenPositions.

Take Profit

Take-profit is set at the entry price plus RewardToRiskRatio = 2.0 times the per-trade stop distance, producing a clean 1:2 reward-to-risk from the broker-side SL. The TP is fixed at entry and never trailed — the 50% TrailingStopPercent input is present but not wired to the live trade path.

Best For

Best suited for XAUUSD M5 scalpers with a $100+ account on a low-spread ECN or RAW broker (the EA detects ECN via ask-bid < 3*point and uses 10-point slippage). Default config is conservative — 0.01 lots, 1:2 RR, only the engulfing confirmation hard-on — so traders should expect low trade frequency and accept the dead news-filter and unwired trailing-stop inputs as v3.0 scaffolding. Tighten risk by lowering MaxPositions from 5 to 2, lower MaxSpreadPoints from 30 to 15, and turn on RequireVolumeSurge or UseHigherTimeframeConfirmation only after a manual back-test pass.

Strategy Logic

Pipsgrowth EX15012 SMC-OrderBlock — Strategy Logic Analysis (from .mq5 source)

Family: SMC-OrderBlock Magic: 22215012 Version: 2.00

BRIEF: XAUUSD liquidity trap scalping EA v3.0 with confirmation signals (engulfing patterns, HTF trend, volume surge). 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • CheckIndicatorHandle()
  • ReleaseIndicatorHandles()
  • AnalyzeMarketState()
  • ManageOpenPositions()
  • NormalizeLotSize()
  • CalculatePositionSize()
  • UpdateTradeStatistics()
  • UpdateLiquidityZones()
  • IdentifySwingPoints()
  • FindSwingHigh()
  • FindSwingLow()
  • AddLiquidityZone()
  • ...and 21 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (28 total across 5 groups):

  • [=== General Settings ===] MagicNumber = 22215012 // Magic Number
  • [=== General Settings ===] InpTradeComment = "Psgrowth.com Expert_15012" // Trade Comment
  • [=== 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.2 recommended)
  • [=== 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 higher g_Timeframe for 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
  • [=== Entry Confirmation ===] UseEngulfingPattern = true // Use engulfing pattern as confirmation
  • [=== Entry Confirmation ===] EngulfingLookback = 3 // Number of bars to look back for engulfing pattern
  • [=== 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
Pseudocode
// Pipsgrowth EX15012 SMC-OrderBlock — Execution Flow (from source analysis)
// Family: SMC-OrderBlock
// XAUUSD liquidity trap scalping EA v3.0 with confirmation signals (engulfing patterns, HTF trend, volume surge). 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

Optimized Brokers:
ExnessIC Markets
Optimized Symbols:
XAUUSD
Optimized Timeframes:
M5

How to Install This EA on MT5

  1. 1Download the .mq5 file using the button above
  2. 2Open MetaTrader 5 on your computer
  3. 3Click File → Open Data Folder in the top menu
  4. 4Navigate to MQL5 → Experts and paste the .mq5 file there
  5. 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
  6. 6Drag the EA onto a chart matching the recommended timeframe
  7. 7Configure parameters according to the table on this page
  8. 8Enable Allow Algo Trading and click OK

EA Parameters

ParameterDefaultDescription
MagicNumber22215012Magic Number
InpTradeComment"Psgrowth.com Expert_15012"Trade Comment
EnableDebugtrueEnable Debug Messages
Timeframe4Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Trading Timeframe
SwingBarCount1Number of bars for swing detection (smaller value = more swings)
MaxZoneAge24Maximum zone age in hours
PriceSurgePercent0.001Percent of price movement to consider as surge (0.001-0.2 recommended)
RequireVolumeSurgefalseRequire volume surge with price movement
VolumeSurgeMultiplier1.5Volume threshold as multiplier of average
UseHigherTimeframeConfirmationfalseUse higher g_Timeframe for trend confirmation
ConfirmationTimeframe6Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher timeframe for confirmation
RequireVolumeConfirmationfalseRequire volume confirmation for entry
UseEngulfingPatterntrueUse engulfing pattern as confirmation
EngulfingLookback3Number of bars to look back for engulfing pattern
FixedLotSize0.01Fixed lot size for all trades
RewardToRiskRatio2.0Reward to risk ratio
EnableTrailingStopfalseEnable trailing stop
TrailingStopPercent50.0Trailing stop as percentage of profit
MaxSpreadPoints30Maximum spread in points
MaxConsecutiveLosses3Max consecutive losses before pausing
PauseMinutes60Minutes to pause after max losses
MaxPositions5Maximum open positions
EnableTimeFilterfalseEnable trading hours filter
TradingHoursStart"08:00"Trading hours start (broker time)
TradingHoursEnd"20:00"Trading hours end (broker time)
AvoidHighImpactNewstrueAvoid trading during high impact news
NewsBufferMinutesBefore30Minutes to avoid trading before news
NewsBufferMinutesAfter30Minutes to avoid trading after news
Source Code (.mq5)Open Source
Pipsgrowth_com_EX15012.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX15012 XAUUSD Liquidity Trap EA v3.0 — SMC liquidity zone scalper with confirmation signals, 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 = 22215012;           // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_15012"; // 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.

Tags:ex15012smc-orderblockpipsgrowthfreemt5xauusd

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

Community

Sign in to contributeSign In

Educational purposes only. Do NOT use with real money. Test on demo accounts only.

File NamePipsgrowth_com_EX15012.mq5
File Size72.8 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyOther
Risk LevelMedium Risk
Timeframes
M5
Currency Pairs
XAUUSD
Min. Deposit$100