P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX12056 MultiIndicatorConfluence

MT5 Expert Advisor (Open Source) · XAUUSD · M5

Pipsgrowth.com EX12056 PatternIntegration_XAUUSD_5M — Inside Bar pattern with EMA trend filter, full 12-layer stack.

Overview

EX12056 is a single-position pattern EA built around one specific price-action setup on XAUUSD M5: the inside bar. The pattern-detect logic lives in CheckSignal() and runs once per closed M5 bar. On each new bar the EA reads the prior bar (bar 1) and the bar before it (bar 2), tests whether bar 1's full high-low range sits strictly inside bar 2's range, and only then evaluates a directional bias from a single 50-period exponential moving average. If the inside bar printed and its close is above the EMA, the EA buys. If the inside bar printed and its close is below the EMA, the EA sells. No other confirmation, no breakout trigger, no momentum filter — just inside-bar containment plus a trend read.

The strict containment test is deliberate. The condition isInside = (h1 < h2) && (l1 > l2) requires bar 1's high to be less than bar 2's high AND bar 1's low to be greater than bar 2's low. Bars that tie either boundary are excluded, which keeps the pattern crisp and avoids the ambiguous cases where one of the inside bar's wicks merely tags the mother's high or low. This is meaningfully different from classical inside-bar breakout systems, where the entry is triggered only when a later bar breaks the mother bar's high (long) or low (short). EX12056 fires on the formation bar itself, not on a later breakout, and uses the EMA direction — not the mother bar boundary — to choose the side.

The trend read is a single EMA handle created in OnInit via iMA(_Symbol, _Period, InpTrendEMA, 0, MODE_EMA, PRICE_CLOSE). The default 50-period length can be tuned through InpTrendEMA; the EA reads only the value at shift 1 (the just-closed bar) so the read is stable and never mid-bar. EMA was chosen over SMA because on 5-minute gold the most recent few closes carry the freshest information about whether the consolidation is pausing an uptrend or pausing a downtrend.

Tick flow is disciplined. Inside OnTick() a static datetime lastBar is compared to iTime(_Symbol, _Period, 0); if the bar timestamp is unchanged, the handler returns immediately. A live spread check sits just before that gate: if(mysymbol.Spread() > InpMaxSpread) return with the default InpMaxSpread = 250 points (25 pips in 5-digit-gold quoting). The wide ceiling is intentional — it lets trades through during normal London and New York volatility on gold, while still refusing fills during the wide spreads that occasionally hit the pair at the Asian rollover (around 22:00–23:00 server time).

Position discipline is hard-coded: if(PositionsTotal() > 0) return at the top of CheckSignal(). There is no scaling, no grid, no pyramiding, no averaging. Every trade stands on its own. This single-position behavior is the EA's only exit-side discipline — there is no time-based close, no signal-driven reverse, no partial close, no trailing stop, no break-even logic. The position is closed by exactly one of two events: the protective stop is hit, or the take profit is hit.

Trade construction uses two distance inputs. InpStopLoss = 350 points below the ask (for longs) or above the bid (for shorts) is the protective stop. InpTakeProfit = 700 points in the favorable direction is the profit target. The default 1:2 reward-to-risk ratio is encoded in the inputs, not derived from an indicator. For XAUUSD at a 0.01 lot on a $100 micro account, a stopped trade loses roughly $0.35 and a winning trade captures roughly $0.70; on a 0.10 lot and a $1,000 account, the same pattern gives a $3.50 loss against a $7.00 win. The lot the EA actually uses is computed by CalculateLotSize().

CalculateLotSize() is a two-path function. If InpRiskPercent > 0, it solves for the lot that would risk exactly that percent of the account balance over InpStopLoss points, using the symbol's TickValue(), TickSize(), and Point(). The math is the standard riskMoney / (stopLossPoints * (tickValue / (tickSize / pointVal))), then rounded DOWN to the symbol's LotsStep() (so the result is always a valid tradeable lot), and finally clamped to the broker's LotsMin() and LotsMax(). If InpRiskPercent is 0, the EA returns InpFixedLot directly — the default 0.01. The combination of risk-based and fixed sizing means the EA is usable on a $100 micro account at 0.01 fixed, and on a $1,000+ account at 1% risk where the calculated lot will scale to roughly 0.03 on a 350-point gold stop.

Order routing is the standard CTrade pattern. trade.SetExpertMagicNumber(InpMagicNumber) is called in OnInit so every position carries magic 22212056. trade.SetDeviationInPoints(InpSlippage) caps slippage at 3 points, the default InpSlippage. trade.SetTypeFilling(ORDER_FILLING_FOK) selects fill-or-kill as the primary execution mode, suitable for most ECN venues. Three helper functions — TryClose_EX12056, TryClosePartial_EX12056, TryModify_EX12056 — each attempt their operation up to 3 times with a 200ms sleep on REQUOTE, TIMEOUT, PRICE_OFF, or PRICE_CHANGED retcodes (a 100ms sleep on the modify path). This is a routine 'try, pause, retry' guard for ECN venues that occasionally return transient codes; it is the same wrapper style used across the EX12 family.

What you should expect in a backtest is a relatively low trade frequency — a handful of inside-bar setups per day on M5 gold, depending on volatility regime. Win rates on this style of pattern typically fall in the 40–55% range; the 1:2 reward-to-risk keeps the long-run expectancy positive when the EMA read is correct. The 250-point spread filter will visibly reduce the entry count during quiet hours and during the daily rollover; on a 0.01-lot account the impact is small, on a 1% risk account the same number of refused bars means slightly fewer position-sizing opportunities. If you want to run this EA, use a broker that quotes XAUUSD in 0.01-point increments so the 350/700 default distances translate to the dollar amounts the inputs assume. ECN and standard accounts both work as long as FOK filling is supported.

Strategy Deep Dive

The pattern detector in CheckSignal() runs once per new M5 bar via a static datetime lastBar guard against iTime(_Symbol, _Period, 0). On each new bar it reads bar 1's high, low, and close, plus bar 2's high and low, and tests isInside = (h1 < h2) && (l1 > l2). When that strict containment holds, the close of bar 1 is compared to a 50-period EMA on close prices read from a single iMA handle — long only above the EMA, short only below. The handler short-circuits if PositionsTotal() > 0 (single-position discipline) and if the live spread exceeds InpMaxSpread = 250 points. CalculateLotSize() solves for the lot that risks InpRiskPercent of balance over InpStopLoss points, snapping the result down to the symbol's LotsStep() and clamping to min/max lot. Orders are sent via CTrade with FOK filling, 3-point slippage cap, and 3-attempt retry on transient retcodes through TryClose_EX12056 / TryClosePartial_EX12056 / TryModify_EX12056.

Entry Signal

On a closed M5 bar the EA tests whether the prior bar's full range is strictly inside the bar before it (the inside bar pattern), and reads a 50-period EMA on close. A buy fires when the inside bar closes above the EMA, a sell when it closes below — long bias only above the EMA, short bias only below. Signals are evaluated once per new bar and the EA refuses to enter if any position is already open, enforcing strict single-position discipline.

Exit Signal

Exits are bracket-driven only: the 350-point stop loss and 700-point take profit attached at entry are the sole exit paths. There is no trailing stop, no break-even, no partial close, no time-based close, and no signal-driven reverse — the position is closed when either the protective stop or the profit target is hit. The CTrade wrapper retries closes up to 3 times on transient retcodes (REQUOTE, TIMEOUT, PRICE_OFF, PRICE_CHANGED) with a 200ms sleep between attempts.

Stop Loss

Stop loss is a fixed 350 points attached at order entry, computed as InpStopLoss * _Point from the fill price (ask for buys, bid for sells). The stop is never modified during the trade's life — no break-even, no trailing, no dynamic ratchet — and is only moved by the broker as price moves against the position until it is hit.

Take Profit

Take profit is a fixed 700 points from entry, exactly 2x the stop distance, giving a 1:2 reward-to-risk ratio on every trade. The TP is attached at order entry, never modified, and is the only profit-taking path — there is no partial close, no scaling out, and no signal-driven exit before the target is reached.

Best For

Best for XAUUSD M5 traders who want a low-frequency, single-position pattern system with clear, non-overlapping signals. The minimum recommended balance is $100 with the default 0.01 fixed lot, or $1,000+ to let the 1% risk-percent path compute non-trivial lot sizes. The 250-point spread gate is wide enough for most retail ECN and standard-spread brokers during London and New York hours, but expect intermittent filter refusals during the Asian rollover (around 22:00–23:00 server time). Requires a broker that quotes XAUUSD in 0.01-point increments and supports FOK filling.

Strategy Logic

Pipsgrowth EX12056 MultiIndicatorConfluence — Strategy Logic Analysis (from .mq5 source)

Family: MultiIndicatorConfluence Magic: 22212056 Version: 2.00

BRIEF: Inside Bar pattern detection with EMA trend filter on XAUUSD M5. Identifies inside bar formations and trades breakouts in the direction of the EMA trend. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • CheckSignal()
  • OpenBuy()
  • OpenSell()
  • CalculateLotSize()
  • TryClose_EX12056()
  • TryClosePartial_EX12056()
  • TryModify_EX12056()

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (10 total across 3 groups):

  • [=== Strategy Parameters ===] InpTrendEMA = 50 // Trend Filter (EMA)
  • [=== Strategy Parameters ===] InpUseInsideBar = true // Inside Bar Pattern
  • [=== Money Management ===] InpRiskPercent = 1.0 // Risk Percent per Trade
  • [=== Money Management ===] InpFixedLot = 0.01 // Fixed Lot (if Risk=0)
  • [=== Money Management ===] InpStopLoss = 350 // Stop Loss (points)
  • [=== Money Management ===] InpTakeProfit = 700 // Take Profit (points)
  • [=== Trade Management ===] InpMagicNumber = 22212056 // Magic number
  • [=== Trade Management ===] InpTradeComment = "Psgrowth.com Expert_12056" // Trade comment
  • [=== Trade Management ===] InpMaxSpread = 250 // Max Spread (points)
  • [=== Trade Management ===] InpSlippage = 3 // Slippage
Pseudocode
// Pipsgrowth EX12056 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// Inside Bar pattern detection with EMA trend filter on XAUUSD M5. Identifies inside bar formations and trades breakouts in the direction of the EMA trend. 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
InpTrendEMA50Trend Filter (EMA)
InpUseInsideBartrueInside Bar Pattern
InpRiskPercent1.0Risk Percent per Trade
InpFixedLot0.01Fixed Lot (if Risk=0)
InpStopLoss350Stop Loss (points)
InpTakeProfit700Take Profit (points)
InpMagicNumber22212056Magic number
InpTradeComment"Psgrowth.com Expert_12056"Trade comment
InpMaxSpread250Max Spread (points)
InpSlippage3Slippage
Source Code (.mq5)Open Source
Pipsgrowth_com_EX12056.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX12056 PatternIntegration_XAUUSD_5M — Inside Bar pattern with EMA trend filter, full 12-layer stack."

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

CTrade         trade;
CPositionInfo  position;
CSymbolInfo    mysymbol;
CAccountInfo   account;

//--- Input Groups
input group "=== Strategy Parameters ==="
input int      InpTrendEMA       = 50;       // Trend Filter (EMA)
input bool     InpUseInsideBar   = true;     // Inside Bar Pattern

input group "=== Money Management ==="
input double   InpRiskPercent    = 1.0;      // Risk Percent per Trade
input double   InpFixedLot       = 0.01;     // Fixed Lot (if Risk=0)
input int      InpStopLoss       = 350;      // Stop Loss (points)
input int      InpTakeProfit     = 700;      // Take Profit (points)

input group "=== Trade Management ==="
input long     InpMagicNumber    = 22212056;  // Magic number
input string   InpTradeComment   = "Psgrowth.com Expert_12056"; // Trade comment
input int      InpMaxSpread      = 250;      // Max Spread (points)
input int      InpSlippage       = 3;        // Slippage

//--- Handles
int    hMA;

//--- Global Buffers
double bufMA[];

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   trade.SetExpertMagicNumber(InpMagicNumber);
   trade.SetDeviationInPoints(InpSlippage);
   trade.SetTypeFilling(ORDER_FILLING_FOK);

   hMA = iMA(_Symbol, _Period, InpTrendEMA, 0, MODE_EMA, PRICE_CLOSE);
   
   if(hMA == INVALID_HANDLE) 
      return(INIT_FAILED);
   
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)

Full source code available on download

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

Tags:ex12056multiindicatorconfluencepipsgrowthfreemt5xauusd

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