P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX15023 SMC-OrderBlock

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

Pipsgrowth.com EX15023 PipsGrowth SMC Scalper — BOS/CHoCH/OB/FVG scalper with ATR risk management, full 12-layer stack.

Overview

Pipsgrowth EX15023 is an ATR-driven Smart Money Concepts scalper that builds trades out of three ICT primitives — break of structure, order block retest, and fair value gap fill — and lets you pick which one fires entries through a four-position mode selector. The EA drops the multi-confirmation vote used in some of its EX15 cousins; every entry here is a pure structural reaction, and risk is sized off a single ATR(14) handle that all of the management logic shares.

The market structure layer runs two pivots in parallel. The dominant one is the swing pivot, scanned across InpSwingLength = 20 bars: a high is a swing high if it is the strictest high inside a 20-bar window, a low is a swing low if it is the strictest low. When the previous bar closes above a stored swing high that has not yet been crossed, the EA flips g_swingTrend to BULLISH. If the previous trend was BEARISH, that close above the prior swing high is recorded as a Change of Character (g_alertBullCHoCH) and labelled with a CHoCH text marker; if the previous trend was already BULLISH, the same event is a plain BOS and the label reads BOS. The bearish mirror fires on close below the stored swing low. A second, faster internal-structure pass uses InpInternalLength = 5 and only stores the internal bias — it does not label, but it gives the OB engine a faster local direction to anchor against.

Order blocks are generated the moment a structure break registers. CreateOrderBlock walks back up to ten bars from the swing pivot that was just broken, finds the lowest low (for bullish OBs) or the highest high (for bearish OBs), and stores the high–low range as the OB rectangle. Up to InpMaxOBCount = 5 OBs are kept; the oldest is dropped if a sixth is created. Mitigation runs on every new bar inside CheckOBMitigation. By default the EA flags a bullish OB as mitigated the moment the prior bar's low trades below its bottom (or, if InpOBMitigateClose = true, when the prior bar closes below it). A bearish OB is killed when the prior bar's high pierces its top. Mitigated OBs have their rectangle object deleted from the chart.

Fair value gaps use the classic three-bar geometry: DetectFVG reads the high and low of bar 1 and bar 3, declares a bullish FVG when bar 1's low is above bar 3's high, and a bearish FVG when bar 1's high is below bar 3's low. Each candidate has to clear InpFVGMinATR = 0.5 of current ATR before it is stored, which is what stops micro-gaps from cluttering the chart. Up to InpMaxFVGCount = 5 FVGs are kept; a sixth pushes the oldest out. CheckFVGMitigation retires a bullish FVG as soon as the prior bar's low dips into its ceiling, and a bearish FVG the moment the prior bar's high pokes up into its floor.

The four-position ENUM_ENTRY_MODE selector at the top of the input list is what actually decides which structural event becomes a trade. MODE_OB_RETEST (the default) only opens a position when CheckOBRetest reports the bid sitting inside an active order block of the matching bias. MODE_FVG_FILL only opens when CheckFVGEntry finds the price inside an active fair value gap. MODE_BOS_BREAK opens immediately on the BOS/CHoCH candle itself. MODE_ALL will fire on whichever of the three conditions is true on the current bar. BOS/CHoCH entries use a tight stop placed half an ATR beyond the swing pivot (g_swingLow - 0.5*ATR for longs, g_swingHigh + 0.5*ATR for shorts) and a TP at InpTPMultATR * ATR in the direction of the break. OB retest and FVG fill entries use the wider InpSLMultATR = 1.5 stop and the same InpTPMultATR = 2.5 TP, giving roughly a 1.67 risk-to-reward on the two retest modes and tighter risk on the breakout mode. There is also an InpRequireCHoCH toggle: when set to true, the EA refuses to enter unless the most recent structure break was a CHoCH, which is the conservative way to use this EA in chop.

Five no-trade gates run in fixed order on every new bar: IsDrawdownExceeded reads the live equity against g_peakEquity and aborts the bar entirely once drawdown crosses InpMaxDDPercent = 20. After that, InpEnableTrading, IsSpreadOK (current spread ≤ InpMaxSpreadPoints = 50 points), IsWithinSession (server hour between InpSessionStartHour = 8 and InpSessionEndHour = 20, with overnight wraparound handled), and IsCooldownComplete (current time ≥ g_lastTradeTime + InpTradeCooldownMin*60, defaulting to 5 minutes) all have to pass. CountMyPositions then caps the run at InpMaxPositions = 3 open positions on the same magic. The order paths only see a bar after every gate clears.

Position sizing is a toggle. With InpFixedLot = 0.01 the EA sends that lot on every order. Set that input to zero and CalculateLotSize falls back to percent risk: balance * InpRiskPercent / (slDistance / tickSize * tickValue), floored to the broker's lot step and clamped to the symbol's volume min/max. ATR(14) is the single indicator on the chart; SL is always InpSLMultATR * ATR away from entry (except the BOS break mode, which uses 0.5 ATR), TP is always InpTPMultATR * ATR from entry, and there are no pips-based overrides. OpenTrade sends the order via raw OrderSend with request.deviation = 30 and an auto-detected filling mode from GetFillMode (IOC if the broker advertises it, otherwise FOK, otherwise RETURN). The order comment is hardcoded to Psgrowth.com Expert_15023 and the magic to 22215023.

Management runs tick by tick inside ManagePositions. Once price has moved InpBreakevenATR = 1.0 of ATR in favour of the trade and the current stop is still behind entry, the EA ratchets the stop to entry plus 10 points (entry minus 10 points for shorts). Beyond that, if InpTrailATR = 0.5 is non-zero, the stop trails by 0.5 ATR behind price on every tick, but only if the new stop improves on the existing one by at least 10 points — a small friction filter that prevents the EA from spamming the broker with no-op modifications. ModifyPosition ships every SL/TP change through raw OrderSend again. Three retry helpers — TryClose_EX15023, TryClosePartial_EX15023, TryModify_EX15023 — are declared at the bottom of the file using the g_trade_wrappers_EX15023 CTrade instance, with three attempts and a 200 ms backoff on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED retcodes, but the live modify and close paths do not call them. They are present as a safety net that the source currently does not route through.

The on-chart dashboard (InpShowDashboard = true, InpDashX = 20, InpDashY = 30) is built out of OBJ_LABEL rectangles in CreateDashboard and refreshed on every tick from UpdateDashboard. It prints the swing bias with a ▲/▼/― glyph in InpBullColor / InpBearColor / clrGray, the internal bias on the same scheme, the number of active OBs, the number of active FVGs, the current spread (green if within InpMaxSpreadPoints, orange otherwise), the open-position count against the cap, and the live drawdown percentage against the peak equity, with the text turning orange once drawdown passes 70% of InpMaxDDPercent. All chart objects are prefixed SMC_ for OBs, structure labels, and FVG rectangles, and DASH_ for the dashboard, so OnDeinit can wipe them in two ObjectsDeleteAll calls. On init, the EA validates that InpRiskPercent is between 0 and 10, builds the ATR handle, sizes the OB and FVG arrays to their maximum counts, resets the four pivots, captures the current equity into g_peakEquity, and fails the init with INIT_PARAMETERS_INCORRECT if the risk input is out of range.

Strategy Deep Dive

Each new bar, UpdateSwingStructure walks 20 bars around the current pivot to confirm a swing high and swing low; if the previous bar's close pierces a stored swing that has not yet been crossed, the EA flips g_swingTrend, records a BOS or CHoCH depending on the prior bias, and calls CreateOrderBlock to spawn a fresh OB rectangle from the impulse candles. In parallel, UpdateInternalStructure runs the same 5-bar pivot scan and only stores a faster internal bias. DetectFVG then checks the 3-bar geometry between bar 1 and bar 3 and stores any imbalance that clears InpFVGMinATR of ATR. CheckOBMitigation and CheckFVGMitigation retire the primitives that have been traded through. ProcessEntrySignals then calls whichever of CheckOBRetest, CheckFVGEntry, or the BOS/CHoCH flag the active InpEntryMode enables, sizes the position through CalculateLotSize, and ships the order via raw OrderSend with a 30-point deviation. Tick by tick, ManagePositions ratchets the stop to breakeven after 1 ATR and trails it by 0.5 ATR afterwards, sending every modification back through raw OrderSend. The 5-minute cooldown, the 50-point spread cap, the 8-20 server-hour session, the 3-position cap, and the 20% peak-equity drawdown brake all run as early-out gates before ProcessEntrySignals is even reached.

Entry Signal

Entries are gated by the swing structure flip and the chosen InpEntryMode. A bullish swing flip (close above the 20-bar pivot) creates a bullish order block, then MODE_OB_RETEST (default) opens a buy when the bid touches the active OB, MODE_FVG_FILL opens when price re-enters an active bullish FVG, and MODE_BOS_BREAK opens immediately on the BOS/CHoCH candle with a tight half-ATR stop. The mirror logic fires shorts on bearish flips. The optional InpRequireCHoCH toggle restricts entries to change-of-character breaks only.

Exit Signal

There is no signal-based exit. Positions are managed tick by tick in ManagePositions. Once price has moved one ATR in favour of the trade, the stop is moved to entry ± 10 points. Beyond breakeven, the stop trails by 0.5 ATR behind price, but only when the new stop improves the existing one by at least 10 points. Otherwise exits happen on the SL or TP set at entry, and the EA also stops opening new positions if account drawdown exceeds 20% from peak equity.

Stop Loss

The stop is always ATR-based. The default is 1.5 × ATR(14) on order block retest and FVG fill entries, and 0.5 × ATR(14) on BOS breakout entries. There is no fixed-pip stop. The breakeven and trailing logic then ratchets the stop once price moves 1.0 ATR in favour, with the trailing step at 0.5 ATR.

Take Profit

TP is a single ATR multiplier applied to every entry: 2.5 × ATR(14) from entry, regardless of which mode opened the position. That gives roughly a 1.67 risk-to-reward on the two retest modes and a wider 5:1 reward-to-risk on the tight BOS stop. There is no partial-close ladder or basket TP.

Best For

Run EX15023 on XAUUSD or USDJPY M5 with InpEntryMode = MODE_OB_RETEST (the default) and InpRequireCHoCH = true to filter for change-of-character breaks only. Minimum recommended balance is $100 with InpFixedLot = 0.01 or risk-percent sizing. Use a low-spread ECN or RAW account — the EA's 50-point spread gate will reject entries on a typical gold feed the moment spreads widen past 5 pips. The 8-20 server-hour session filter covers London and New York overlap, and the 5-minute cooldown makes the EA more conservative than most SMC EAs. Set InpMaxDDPercent = 20 as your hard equity brake.

Strategy Logic

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

Family: SMC-OrderBlock Magic: 22215023 Version: 2.00

BRIEF: SMC scalper implementing BOS/CHoCH market structure, order block retest entries, fair value gap fills, with ATR-based SL/ TP, breakeven, trailing, session filter and dashboard. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • ATR

KEY FUNCTIONS:

  • UpdateSwingStructure()
  • UpdateInternalStructure()
  • CreateOrderBlock()
  • CheckOBMitigation()
  • DetectFVG()
  • CreateFVG()
  • CheckFVGMitigation()
  • ProcessEntrySignals()
  • CheckOBRetest()
  • CheckFVGEntry()
  • OpenTrade()
  • CalculateLotSize()
  • ...and 20 more

INTERNAL CONSTANTS (1 total):

  • NEUTRAL = 0 // +------------------------------------------------------------------+

INPUT PARAMETERS (36 total across 8 groups):

  • [=== TRADING SETTINGS ===] InpEnableTrading = true // Enable Trading
  • [=== TRADING SETTINGS ===] InpRiskPercent = 1.0 // Risk % per Trade
  • [=== TRADING SETTINGS ===] InpFixedLot = 0.01 // Fixed Lot (0=Auto)
  • [=== TRADING SETTINGS ===] InpMagicNumber = 22215023 // Magic Number
  • [=== TRADING SETTINGS ===] InpTradeComment = "Psgrowth.com Expert_15023" // Trade Comment
  • [=== TRADING SETTINGS ===] InpMaxPositions = 3 // Max Positions
  • [=== TRADING SETTINGS ===] InpMaxSpreadPoints = 50 // Max Spread (Points)
  • [=== TRADING SETTINGS ===] InpTradeCooldownMin = 5 // Cooldown Between Trades (min)
  • [=== SESSION FILTER ===] InpUseSessionFilter = true // Use Session Filter
  • [=== SESSION FILTER ===] InpSessionStartHour = 8 // Session Start Hour (Server)
  • [=== SESSION FILTER ===] InpSessionEndHour = 20 // Session End Hour (Server)
  • [=== MARKET STRUCTURE ===] InpSwingLength = 20 // Swing Detection Bars
  • [=== MARKET STRUCTURE ===] InpInternalLength = 5 // Internal Structure Bars
  • [=== MARKET STRUCTURE ===] InpShowStructure = true // Show Structure Labels
  • [=== MARKET STRUCTURE ===] InpBullColor = clrLime // Bullish Color
  • [=== MARKET STRUCTURE ===] InpBearColor = clrRed // Bearish Color
  • [=== ORDER BLOCKS ===] InpEnableOB = true // Enable Order Blocks
  • [=== ORDER BLOCKS ===] InpMaxOBCount = 5 // Max OBs to Track
  • [=== ORDER BLOCKS ===] InpOBMitigateClose = false // Mitigate on Close (else H/L)
  • [=== ORDER BLOCKS ===] InpBullOBColor = clrDodgerBlue // Bullish OB Color
  • [=== ORDER BLOCKS ===] InpBearOBColor = clrCoral // Bearish OB Color
  • [=== FAIR VALUE GAPS ===] InpEnableFVG = true // Enable FVG Detection
  • [=== FAIR VALUE GAPS ===] InpMaxFVGCount = 5 // Max FVGs to Track
  • [=== FAIR VALUE GAPS ===] InpFVGMinATR = 0.5 // Min FVG Size (ATR mult)
  • [=== FAIR VALUE GAPS ===] InpBullFVGColor = clrSpringGreen // Bullish FVG Color
  • [=== FAIR VALUE GAPS ===] InpBearFVGColor = clrTomato // Bearish FVG Color
  • [=== ENTRY CONDITIONS ===] InpEntryMode = MODE_OB_RETEST // Entry Mode
  • [=== ENTRY CONDITIONS ===] InpMinATRPoints = 100 // Min ATR for Entry
  • [=== ENTRY CONDITIONS ===] InpRequireCHoCH = false // Require CHoCH for Entry
  • [=== RISK MANAGEMENT ===] InpTPMultATR = 2.5 // TP ATR Multiplier
  • [=== RISK MANAGEMENT ===] InpBreakevenATR = 1.0 // Breakeven Trigger (ATR)
  • [=== RISK MANAGEMENT ===] InpTrailATR = 0.5 // Trailing Step (ATR, 0=Off)
  • [=== RISK MANAGEMENT ===] InpMaxDDPercent = 20.0 // Max Drawdown %
  • [=== DASHBOARD ===] InpShowDashboard = true // Show Dashboard
  • [=== DASHBOARD ===] InpDashX = 20 // Dashboard X
  • [=== DASHBOARD ===] InpDashY = 30 // Dashboard Y
Pseudocode
// Pipsgrowth EX15023 SMC-OrderBlock — Execution Flow (from source analysis)
// Family: SMC-OrderBlock
// SMC scalper implementing BOS/CHoCH market structure, order block retest entries, fair value gap fills, with ATR-based SL/ TP, breakeven, trailing, session filter and dashboard. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

ON_INIT:
    Create indicator handles: ATR
    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:
XAUUSDUSDJPY
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
InpEnableTradingtrueEnable Trading
InpRiskPercent1.0Risk % per Trade
InpFixedLot0.01Fixed Lot (0=Auto)
InpMagicNumber22215023Magic Number
InpTradeComment"Psgrowth.com Expert_15023"Trade Comment
InpMaxPositions3Max Positions
InpMaxSpreadPoints50Max Spread (Points)
InpTradeCooldownMin5Cooldown Between Trades (min)
InpUseSessionFiltertrueUse Session Filter
InpSessionStartHour8Session Start Hour (Server)
InpSessionEndHour20Session End Hour (Server)
InpSwingLength20Swing Detection Bars
InpInternalLength5Internal Structure Bars
InpShowStructuretrueShow Structure Labels
InpBullColorclrLimeBullish Color
InpBearColorclrRedBearish Color
InpEnableOBtrueEnable Order Blocks
InpMaxOBCount5Max OBs to Track
InpOBMitigateClosefalseMitigate on Close (else H/L)
InpBullOBColorclrDodgerBlueBullish OB Color
InpBearOBColorclrCoralBearish OB Color
InpEnableFVGtrueEnable FVG Detection
InpMaxFVGCount5Max FVGs to Track
InpFVGMinATR0.5Min FVG Size (ATR mult)
InpBullFVGColorclrSpringGreenBullish FVG Color
InpBearFVGColorclrTomatoBearish FVG Color
InpEntryModeMODE_OB_RETESTEntry Mode
InpMinATRPoints100Min ATR for Entry
InpRequireCHoCHfalseRequire CHoCH for Entry
InpTPMultATR2.5TP ATR Multiplier
InpBreakevenATR1.0Breakeven Trigger (ATR)
InpTrailATR0.5Trailing Step (ATR, 0=Off)
InpMaxDDPercent20.0Max Drawdown %
InpShowDashboardtrueShow Dashboard
InpDashX20Dashboard X
InpDashY30Dashboard Y
Source Code (.mq5)Open Source
Pipsgrowth_com_EX15023.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX15023 PipsGrowth SMC Scalper — BOS/CHoCH/OB/FVG scalper with ATR risk management, full 12-layer stack."
#include <Trade\Trade.mqh>

//+------------------------------------------------------------------+
//| CONSTANTS                                                         |
//+------------------------------------------------------------------+
#define BULLISH 1
#define BEARISH -1
#define NEUTRAL 0

//+------------------------------------------------------------------+
//| ENUMERATIONS                                                      |
//+------------------------------------------------------------------+
enum ENUM_ENTRY_MODE {
  MODE_OB_RETEST, // Order Block Retest
  MODE_FVG_FILL,  // FVG Fill
  MODE_BOS_BREAK, // BOS Breakout
  MODE_ALL        // All Signals
};

//+------------------------------------------------------------------+
//| INPUT PARAMETERS                                                  |
//+------------------------------------------------------------------+
input group "=== TRADING SETTINGS ==="
input bool InpEnableTrading =
    true;                          // Enable Trading
input double InpRiskPercent = 1.0; // Risk % per Trade
input double InpFixedLot = 0.01;   // Fixed Lot (0=Auto)
input int InpMagicNumber = 22215023; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_15023"; // Trade Comment
input int InpMaxPositions = 3;     // Max Positions
input int InpMaxSpreadPoints = 50; // Max Spread (Points)
input int InpTradeCooldownMin = 5; // Cooldown Between Trades (min)

input group "=== SESSION FILTER ==="
input bool InpUseSessionFilter =
    true;                          // Use Session Filter
input int InpSessionStartHour = 8; // Session Start Hour (Server)
input int InpSessionEndHour = 20;  // Session End Hour (Server)

input group "=== MARKET STRUCTURE ==="
input int InpSwingLength =
    20;                             // Swing Detection Bars
input int InpInternalLength = 5;    // Internal Structure Bars
input bool InpShowStructure = true; // Show Structure Labels
input color InpBullColor = clrLime; // Bullish Color
input color InpBearColor = clrRed;  // Bearish Color

input group "=== ORDER BLOCKS ==="
input bool InpEnableOB =
    true;                                   // Enable Order Blocks
input int InpMaxOBCount = 5;                // Max OBs to Track
input bool InpOBMitigateClose = false;      // Mitigate on Close (else H/L)
input color InpBullOBColor = clrDodgerBlue; // Bullish OB Color
input color InpBearOBColor = clrCoral;      // Bearish OB Color

Full source code available on download

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

Tags:ex15023smc-orderblockpipsgrowthfreemt5xauusdusdjpy

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_EX15023.mq5
File Size40.5 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyOther
Risk LevelMedium Risk
Timeframes
M5
Currency Pairs
XAUUSDUSDJPY
Min. Deposit$100