P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX15008 SMC-OrderBlock

MT5 Expert Advisor (Open Source) · XAUUSD · M5, M15

Pipsgrowth.com EX15008 ICT3_SMC_v2 — ICT BOS/CHoCH + liquidity sweep + FVG + OB + killzones, full 12-layer stack.

Overview

Pipsgrowth EX15008 is an ICT-stack M5 scalper on XAUUSD that scores the inner-bar structural footprint (BOS + liquidity sweep + FVG + order-block tap) into a single 0-100 confidence value, then gates the result behind an H1 trend filter, a 7-state market-regime classifier, and an explicit London / New-York killzone window. The default InpMinScore = 50 is intentionally moderate: a long signal is admitted as soon as the bull-side score crosses fifty, which in this code means roughly two of the four sub-detectors firing (BOS contributes 30 points, sweep 25, order-block 25, and the FVG gap adds a further 20). The EA is shipped with InpDryRun = true, so a fresh install logs every would-be order to the Strategy Tester journal but never places a ticket; flipping that input to false is the only switch required to go from paper-trading to live.

Inside each new closed bar, OnTick calls IctSignal() first. IctSignal walks a SWING_LOOKBACK = 12 bar window to find the most recent swing high and swing low, then checks four things on the last three closed bars: (a) whether bar[1] closed through that swing (BOS), (b) whether the wick of bar[1] pierced the swing and the body closed back inside (liquidity sweep), (c) whether bar[2]'s low sits above bar[3]'s high, or bar[2]'s high sits below bar[3]'s low (FVG), and (d) whether bar[2] is an opposite-color candle whose open-close range contains the bar[1] close (order-block tap). Each component that fires adds its weight to a running bull- and bear-score, and whichever side clears InpMinScore with the higher total wins. The two attempts never tie because a single bar can only satisfy bullish conditions or bearish conditions for any given detector.

A winning signal is then run through ConfirmEntry(), which reads the H1 EMA(50) handle (g_h_emaH) and rejects a long whose M5 close is below the HTF EMA, a short whose M5 close is above it, then applies a directional RSI band — longs need RSI(14) ≥ 45, shorts need RSI(14) ≤ 55 — and finally checks that the current tick volume exceeds 80 % of the 20-bar average. Any one of these failing returns a rejection string that the EA never sends. The Net effect is a triple-filter entry: a structurally-weighted ICT score, a higher-timeframe trend agreement, and a microstructural vol/RSI band. ComputeRegime() runs the same tick to classify the market as StrongTrend, WeakTrend, Range, Breakout, Compress, Expand, or Choppy using ADX(14) ≥ InpAdxTrendMin = 22 plus a 100-bar ATR-percentile and a Bollinger-width band, and a Choppy state hard-blocks the trade via NoTradeBlock().

Position management is a three-stage lock-up. When a position reaches 1R (one times the initial risk, defined as 1.5 × ATR), the EA fires PARTIAL_PCT = 50 of the position through TryClosePartial_EX15008 — provided the remaining volume is at least twice LotsMin. At the same 1R threshold, InpEnableBreakeven moves the stop to the entry price with TryModify_EX15008. From there, the stop is re-anchored every tick to (current price minus 1.5 × ATR for longs, plus 1.5 × ATR for shorts), a simple fixed-ATR trail rather than the more elaborate step-trails some EAs use. The two safety exits are MAX_BARS_IN_TRADE = 120 (10 hours on M5, 30 hours on M15 — far longer than the 60-bar limit of the EX15 cousins) and an opposite-signal exit: every tick, ManageExits re-runs IctSignal against the same magic, and if the score flips sign the position is closed through TryClose_EX15008. All three manage helpers retry up to three times on REQUOTE, TIMEOUT, PRICE_OFF, or PRICE_CHANGED with a 200 ms / 100 ms Sleep between attempts; SendOrder() additionally has its own 2-attempt inner retry on the same retcodes before it gives up and returns false.

Risk control runs on effective capital rather than raw equity. EffectiveCapital() takes MathMin(InpCapitalCapAmount, g_acc.Equity()) when the cap is set, falling back to raw equity when InpCapitalCapAmount is 0. RiskGateOK() then refuses new entries when today's realized PnL has fallen below –3 % of eff_cap, the week is below –9 %, g_effCap has dropped below InpCapitalCapFloor = 50, the master kill switch is on, or the consecutive-loss run has reached InpCooldownLossCount = 3. Position size itself is calculated from the per-bar ATR(14) via CalcLot: lots = (eff_cap × InpRiskPercent / 100) / (slDistance × moneyPerLotPerPrice), floored to InpFixedLot = 0.05 if the calculation breaks, then rounded down to the broker's lot step and clamped to [LotsMin, LotsMax]. TryEntry additionally rejects an order whose effective R-multiple after stops-level clamping falls below MIN_RR = 1.5 — that check is the runtime safety net against brokers that quote gold with a 50- or 100-point stops level that would otherwise eat the SL.

The no-trade stack is short and explicit. NoTradeBlock() requires the live spread to be below InpMaxSpreadPoints = 30, the day to be a weekday, the clock to be inside either InpLondonWindow = "08:00-10:00" or InpNewYorkWindow = "13:30-16:00" (server time after InpTimeZone is applied), the broker's trade flag to be on, and the symbol's trade mode to be FULL, LONG_ONLY, or SHORT_ONLY. Friday after 21:00 and the full weekend are blocked. There is no news-blackout filter in this build — the developer left that to the trader. A duplicate-entry guard (g_lastEntryBar) prevents the EA from opening a second position on the same bar after the first; InpMaxOpenTrades = 2 and InpMaxSymbolTrades = 2 then cap the live exposure.

The pyramid layer is implemented and wired but defaulted off. When InpEnablePyramid = true, TryPyramid() runs after every entry attempt: it counts existing positions for this magic on this symbol, refuses to add if the count is at PYRAMID_MAX_LEVELS = 3 or InpMaxSymbolTrades, then opens another position only when the current price has moved at least PYRAMID_ATR_MULT = 1.5 × ATR beyond the most recent open price in the signal direction. The new leg uses the same SL = 1.5 × ATR, TP = 2.5 × ATR template and the same CalcLot sizing, so each pyramid layer is sized like a fresh entry rather than scaled by layer. With the default off, the EA never pyramids; turning it on is a one-click change in the inputs but it changes the strategy character from single-shot to scaling, and the tester results should be re-run with it on.

The OnTester custom criterion is (net × profitFactor) / (1 + equityDD), and it returns 0 if the test produced fewer than 30 trades. That single formula drives the Strategy Tester's ranking of every optimization pass, so the EA's optimization surface is implicitly biased toward parameter sets that produce a reasonable trade count with positive expectancy and a low drawdown. The five indicator handles — ATR(14), ADX(14), Bollinger(20, 2, 0), RSI(14), and the HTF EMA(50) on H1 — are released in OnDeinit, and g_effCap is recomputed at the top of every tick so the cap never goes stale during a long session.

For installation: minimum recommended balance is $100, InpRiskPercent = 0.5 % means a $100 account risks roughly $0.50 per trade, and a $1,000 account risks $5. The strategy is built for XAUUSD M5 (and M15), so a low-spread, GMT+2 or GMT+3 broker is required to keep spreads below the 30-point gate; high-spread retail books will see the EA sitting in no-trade for most of the day. Set InpCapitalCapAmount to a value lower than your account balance to test the strategy as if it were trading a sub-account (e.g. cap = 200 on a $1,000 broker account means the EA behaves as if it were running on a $200 account), and keep InpDryRun = true for at least one full London + New York session before going live so the journal confirms that signals are firing on the right bars and that the regime classifier is settling on sensible labels.

Strategy Deep Dive

On every new closed M5 bar, OnTick refreshes g_effCap, calls UpdateRealizedPnL and UpdateConsecLosses, then runs ComputeRegime against the ATR(14)/ADX(14)/Bollinger(20,2)/RSI(14)/H1-EMA(50) handle stack to pick one of seven regimes and Choppy-blocks entries. IctSignal then walks 12 bars for swing high/low and scores bar[1]/bar[2]/bar[3] on BOS (30), sweep (25), FVG (20) and order-block (25); whichever side clears InpMinScore=50 with a higher total is the signal direction. TryEntry runs the no-trade gate (spread ≤ 30, weekday, killzone window, broker trade flag), RiskGateOK (3% daily / 9% weekly / floor $50 / 3-loss cooldown), the duplicate-bar guard, the Min-RR-1.5 floor, the H1-EMA confirm, the RSI band and the 80%-of-20-bar-volume check, then sizes the position via CalcLot on 1.5×ATR and routes the order through SendOrder's two-attempt REQUOTE/PRICE_OFF/TIMEOUT retry. ManageExits handles every live position each tick: 50% partial at 1R, break-even at 1R, ATR trail at 1.5×ATR, time exit at 120 bars, and an opposite-signal close that re-evaluates IctSignal against the same magic — all wired through TryClose/TryClosePartial/TryModify_EX15008 with 3-retry backoff on REQUOTE/TIMEOUT/PRICE_OFF/PRICE_CHANGED. InpDryRun is true by default, so the very first install logs every would-be order to the journal without sending a single ticket.

Entry Signal

Long or short signal fires when the directional ICT score (BOS=30, sweep=25, FVG=20, OB=25) crosses InpMinScore=50 against the opposing side, after which the trade must pass an H1-EMA(50) trend agreement, an RSI(14) band (longs ≥ 45 / shorts ≤ 55), a tick-volume check above 80% of the 20-bar average, and a live spread below InpMaxSpreadPoints=30. Entry is additionally gated to the London 08:00-10:00 or New York 13:30-16:00 server-time window, a non-Choppy regime from ComputeRegime, and a per-bar duplicate guard that prevents a second entry on the same closed bar.

Exit Signal

Every tick ManageExits fires the IctSignal stack against the same magic and closes the position via TryClose_EX15008 the moment the score flips against the current direction. A hard time exit at MAX_BARS_IN_TRADE=120 bars (10 hours on M5) closes any position still open, and the partial / break-even / ATR-trail stack — 50% at 1R, BE at 1R, and a 1.5×ATR re-anchored stop — defines the in-trade exit shape while the position is still alive.

Stop Loss

Initial stop is g_atr × InpATR_SL_Mult = 1.5 × ATR(14), with a runtime floor of MIN_RR = 1.5 against the TP distance and ClampSlToStops() pushing the SL further out if the broker's stops level would otherwise compress the trade below that ratio. There is no global drawdown cap; the only portfolio-level safety is the 3% daily / 9% weekly loss limits in RiskGateOK and the InpCooldownLossCount = 3 consecutive-loss pause.

Take Profit

Take profit is g_atr × InpATR_TP_Mult = 2.5 × ATR(14), giving a default R-multiple of 1.67 against the 1.5×ATR stop, with the same ClampTpToStops guard pushing the TP out to respect the broker's stops level. There is no basket TP, no partial TP beyond the 50%-at-1R exit, and no scaling-out beyond that single partial close.

Best For

Minimum recommended balance is $100, and a $1,000 account gives the 0.5% InpRiskPercent meaningful per-trade dollar risk (~$5) on XAUUSD M5; the strategy assumes a low-spread GMT+2 or GMT+3 broker so that the live spread stays under the 30-point gate during the London 08:00-10:00 and New York 13:30-16:00 server-time windows. Set InpCapitalCapAmount below your real balance to paper-test a sub-account allocation (e.g. cap=200 on a $1,000 account), and run InpDryRun=true for at least one full London + New York session before going live. The riskLevel is MEDIUM, the suggested pair is XAUUSD, and the working timeframes are M5 and M15.

Strategy Logic

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

Family: SMC-OrderBlock Magic: 22215008 Version: 2.00

BRIEF: ICT3 SMC v2 scalper — BOS/CHoCH + Liquidity Sweep + FVG + Order Block tap, Killzone-time-gated, scored 0-100. Regime via ADX + ATR-percentile + Bollinger-width. Confirm = HTF-EMA(50) + RSI band + vol-surge. Capital cap, ATR trailing, break-even, partial-close 50%, opposite-signal + time exit. Default DRY-RUN. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • _atr
  • _adx
  • _bb
  • _rsi
  • _emaH

KEY FUNCTIONS:

  • ParseWindow()
  • EffectiveCapital()
  • UpdateRealizedPnL()
  • SetupSymbol()
  • RiskGateOK()
  • ComputeRegime()
  • IctSignal()
  • ConfirmEntry()
  • NoTradeBlock()
  • CalcLot()
  • StopsLevelPrice()
  • NormalizePrice()
  • ...and 10 more

INTERNAL CONSTANTS (7 total):

  • ATR_SLPCTILE_LOOKBACK = 100 // bars for ATR percentile
  • SWING_LOOKBACK = 12 // swing detection lookback
  • BE_R_MULT = 1.0 // break-even after 1R
  • PARTIAL_R_MULT = 1.0 // partial close at 1R
  • PARTIAL_PCT = 50 // close 50%
  • MAX_SL_POINTS = 5000 // sanity cap on SL distance
  • MAGIC_DEFAULT = 2220699 // ===================================================================

INPUT PARAMETERS (28 total across 7 groups):

  • [=== Identity ===] InpMagic = 22215008 // Magic number (unique per EA)
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_15008" // Trade comment string
  • [=== Identity ===] InpTimeZone = 0 // Server-time offset hours vs broker (0=broker time)
  • [=== Identity ===] InpAllowBuy = true // Allow long trades
  • [=== Identity ===] InpAllowSell = true // Allow short trades
  • [=== Risk & Sizing ===] InpRiskPercent = 0.5 // Risk % per trade (of effective_capital)
  • [=== Risk & Sizing ===] InpFixedLot = 0.05 // Fallback fixed lot if risk calc fails
  • [=== Risk & Sizing ===] InpDailyLossLimitPct = 3.0 // Daily loss limit % (of effective_capital)
  • [=== Risk & Sizing ===] InpWeeklyLossLimitPct = 9.0 // Weekly loss limit % (of effective_capital)
  • [=== Risk & Sizing ===] InpMaxOpenTrades = 2 // Max simultaneous open positions
  • [=== Risk & Sizing ===] InpMaxSymbolTrades = 2 // Max positions per symbol
  • [=== Risk & Sizing ===] InpCooldownLossCount = 3 // Pause N entries after this many losses
  • [=== Capital Cap ===] InpCapitalCapAmount = 0.0 // Real-money cap ($)
  • [=== Capital Cap ===] InpCapitalCapFloor = 50.0 // Floor below which no entries ($)
  • [=== Signal (ICT) ===] InpMinScore = 50 // Min ICT signal score 0..100
  • [=== Signal (ICT) ===] InpATR_SL_Mult = 1.5 // ATR multiplier for SL
  • [=== Signal (ICT) ===] InpATR_TP_Mult = 2.5 // ATR multiplier for TP
  • [=== Regime / Confirm ===] InpAdxTrendMin = 22.0 // ADX threshold for trend regime
  • [=== Regime / Confirm ===] InpMaxSpreadPoints = 30.0 // Max allowed spread (points)
  • [=== Regime / Confirm ===] InpRequireHTF = true // Require HTF-EMA agreement
  • [=== Session / Exit / Manage ===] InpLondonWindow = "08:00-10:00" // London killzone (HH:MM-HH:MM)
  • [=== Session / Exit / Manage ===] InpNewYorkWindow = "13:30-16:00" // New York killzone (HH:MM-HH:MM)
  • [=== Session / Exit / Manage ===] InpEnableTrailing = true // Enable ATR trailing stop
  • [=== Session / Exit / Manage ===] InpEnableBreakeven = true // Enable one-shot break-even
  • [=== Session / Exit / Manage ===] InpEnablePartial = true // Enable 50% partial at 1R
  • [=== Scaling / Master ===] InpEnablePyramid = false // Enable pyramid scaling (default OFF)
  • [=== Scaling / Master ===] InpDryRun = true // Dry-run mode (no live orders)
  • [=== Scaling / Master ===] InpKillSwitch = false // Master kill switch
Pseudocode
// Pipsgrowth EX15008 SMC-OrderBlock — Execution Flow (from source analysis)
// Family: SMC-OrderBlock
// ICT3 SMC v2 scalper — BOS/CHoCH + Liquidity Sweep + FVG + Order Block tap, Killzone-time-gated, scored 0-100. Regime via ADX + ATR-percentile + Bollinger-width. Confirm = HTF-EMA(50) + RSI band + vol-surge. Capital cap, ATR trailing, break-even, partial-close 50%, opposite-signal + time exit. Default DRY-RUN. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

ON_INIT:
    Create indicator handles: _atr, _adx, _bb, _rsi, _emaH
    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:
M5M15

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
InpMagic22215008Magic number (unique per EA)
InpTradeComment"Psgrowth.com Expert_15008"Trade comment string
InpTimeZone0Server-time offset hours vs broker (0=broker time)
InpAllowBuytrueAllow long trades
InpAllowSelltrueAllow short trades
InpRiskPercent0.5Risk % per trade (of effective_capital)
InpFixedLot0.05Fallback fixed lot if risk calc fails
InpDailyLossLimitPct3.0Daily loss limit % (of effective_capital)
InpWeeklyLossLimitPct9.0Weekly loss limit % (of effective_capital)
InpMaxOpenTrades2Max simultaneous open positions
InpMaxSymbolTrades2Max positions per symbol
InpCooldownLossCount3Pause N entries after this many losses
InpCapitalCapAmount0.0Real-money cap ($)
InpCapitalCapFloor50.0Floor below which no entries ($)
InpMinScore50Min ICT signal score 0..100
InpATR_SL_Mult1.5ATR multiplier for SL
InpATR_TP_Mult2.5ATR multiplier for TP
InpAdxTrendMin22.0ADX threshold for trend regime
InpMaxSpreadPoints30.0Max allowed spread (points)
InpRequireHTFtrueRequire HTF-EMA agreement
InpLondonWindow"08:00-10:00"London killzone (HH:MM-HH:MM)
InpNewYorkWindow"13:30-16:00"New York killzone (HH:MM-HH:MM)
InpEnableTrailingtrueEnable ATR trailing stop
InpEnableBreakeventrueEnable one-shot break-even
InpEnablePartialtrueEnable 50% partial at 1R
InpEnablePyramidfalseEnable pyramid scaling (default OFF)
InpDryRuntrueDry-run mode (no live orders)
InpKillSwitchfalseMaster kill switch
Source Code (.mq5)Open Source
Pipsgrowth_com_EX15008.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX15008 ICT3_SMC_v2 — ICT BOS/CHoCH + liquidity sweep + FVG + OB + killzones, full 12-layer stack."

#include <Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
#include <Trade\OrderInfo.mqh>
#include <Trade\DealInfo.mqh>

//=========================== CONSTANTS =============================
#define ATR_PERIOD           14
#define ATR_SLPCTILE_LOOKBACK 100   // bars for ATR percentile
#define BB_PERIOD            20
#define BB_DEVIATION         2.0
#define ADX_PERIOD           14
#define RSI_PERIOD           14
#define EMA_FAST             21
#define EMA_SLOW             50
#define HTF_PERIOD           PERIOD_H1
#define HTF_EMA_PERIOD       50
#define SWING_LOOKBACK       12     // swing detection lookback
#define VOL_LOOKBACK         20
#define COOLDOWN_BARS        3
#define MAX_BARS_IN_TRADE    120
#define PYRAMID_MAX_LEVELS   3
#define PYRAMID_ATR_MULT     1.5
#define BE_R_MULT            1.0    // break-even after 1R
#define PARTIAL_R_MULT       1.0    // partial close at 1R
#define PARTIAL_PCT          50     // close 50%
#define MIN_RR               1.5
#define MAX_SL_POINTS        5000   // sanity cap on SL distance
#define ROLLING_SPREAD_BARS  50
#define NEWS_WINDOW_MINUTES  15
#define MAGIC_DEFAULT        2220699

//===================================================================
// ENUMS
//===================================================================
enum ENUM_REGIME
  {
   REGIME_StrongTrend = 0,
   REGIME_WeakTrend   = 1,
   REGIME_Range       = 2,
   REGIME_Breakout    = 3,
   REGIME_Compress    = 4,
   REGIME_Expand      = 5,
   REGIME_Choppy      = 6
  };

enum ENUM_SESSION
  {
   SESS_None     = 0,
   SESS_London   = 1,
   SESS_NewYork  = 2
  };

Full source code available on download

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

Tags:ex15008smc-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_EX15008.mq5
File Size34.9 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyOther
Risk LevelMedium Risk
Timeframes
M5M15
Currency Pairs
XAUUSD
Min. Deposit$100