Pipsgrowth EX12077 MultiIndicatorConfluence
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX12077 PatternClassifier_XAUUSD_5M — Engulfing pattern with EMA trend filter, full 12-layer stack.
Overview
Pipsgrowth EX12077 Pattern Classifier is a deliberately narrow tool. It watches XAUUSD on the M5 timeframe for one specific event — a bullish or bearish engulfing candle that closes on the correct side of a 50-period EMA — and fires a single trade in that direction the moment the pattern prints. There is no grid, no martingale, no multi-symbol portfolio, no pyramid, no recovery sequence. The whole decision tree lives in seven functions and reads from a single iMA handle, which keeps the EA small enough to audit line by line and makes it a useful baseline against which the more elaborate multi-confluence EAs in the same family can be measured.
The signal logic sits in CheckSignal(). On every new bar, the function reads the open, high, low, and close of bar 1 (the just-closed bar) and bar 2 (the bar before it), pulls one buffer from the EMA handle into bufMA, and applies two boolean tests. A bullish setup requires that bar 2 is red (close below open), bar 1 is green (close above open), bar 1's close exceeds bar 2's open (body engulfs body), and bar 1's close is above the EMA — a "simplified engulf" as the source comment notes, since the high/low don't have to be engulfed, only the bodies. A bearish setup mirrors that: bar 2 green, bar 1 red, bar 1's close below bar 2's open, and bar 1's close below the EMA. The InpUseEngulfing input (default true) gates the whole pattern — flip it false and CheckSignal() returns without setting either flag.
Three gates sit between the signal and the order. The first is a spread cap at 250 points (InpMaxSpread), explicitly flagged in the input comment as "Increased for Gold" — XAUUSD routinely widens to 25-40 points during New York opens and London fixes, so a tight cap would block most sessions; 250 points (≈25 pips on a 5-digit gold quote) is a pragmatic ceiling that keeps the worst fills out without gating the day. The second is the new-bar guard inside OnTick() — static datetime lastBar paired with iTime(_Symbol, _Period, 0) — so CheckSignal() runs at most once per candle, not on every tick. The third is if(PositionsTotal() > 0) return at the top of CheckSignal(): the EA only ever holds one position at a time. There is no pyramiding into winners, no scaling into losers, and no second-entry logic.
Risk management runs through CalculateLotSize(). With InpRiskPercent = 1.0 (default), the function reads account balance, divides by 100 to get 1% of equity, then converts the 400-point stop into a per-lot dollar risk using the symbol's tick value, tick size, and point. The result is floored to the symbol's lot step with MathFloor(lot/step)*step, then clamped between the broker's LotsMin and LotsMax. Set InpRiskPercent = 0 and the function falls back to InpFixedLot = 0.01. Either path gives a deterministic, broker-aware lot — no arbitrary multipliers, no recovery ramps.
The trade itself is a clean 1:2 risk-reward. OpenBuy() computes stop loss as Ask − 400 * Point and take profit as Ask + 800 * Point. OpenSell() mirrors with bid-based math. The trade.Buy(...) and trade.Sell(...) calls pass the comment string "Psgrowth.com Expert_12077" so fills are easy to filter in journal reports, and magic 22212077 keeps them in their own bucket apart from any other EA running on the same account. The CTrade object is configured at OnInit with deviation 3 points and ORDER_FILLING_FOK — fill-or-kill means a partial fill rejects the whole order, which avoids the half-filled position state that some brokers can produce on thin gold books.
The retry helpers TryClose_EX12077, TryClosePartial_EX12077, and TryModify_EX12077 are defined at the bottom of the file. Each loops up to three times on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED retcodes with a 200 ms backoff (100 ms for the modify variant). They are not wired into the live OpenBuy / OpenSell / CheckSignal paths in this build — the EA's actual close and modify calls go straight through trade.PositionClose and trade.PositionModify. The helpers remain available for a one-line patch if the user wants to harden the exit path against requotes during volatile gold sessions.
Indicator stack: a single iMA(_Symbol, _Period, InpTrendEMA=50, 0, MODE_EMA, PRICE_CLOSE) handle initialised in OnInit and released in OnDeinit via IndicatorRelease(hMA). The handle pulls one buffer (index 0) on demand into bufMA with CopyBuffer(hMA, 0, 1, 1, bufMA), reading bar 1's value at the moment of the new bar. The whole trend filter is a single exponential moving average — no ATR, no ADX, no RSI, no volatility gate. The classification is binary: either the engulfing pattern is on the right side of the EMA or it is not.
Backtesting posture: the source header advertises the EA as part of a "12 layers" stack (REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester) but only a subset of those layers is actually implemented in this build. There is no custom OnTester() function, so the strategy tester falls back to the standard balance / max-DD / profit-factor / Sharpe scoring. There is no per-day or per-week loss cap, no equity-stop, no global drawdown circuit breaker. The hard caps are the 250-point spread gate, the one-position-at-a-time limit, and the 400-point per-trade stop. That makes the EA transparent — what you see in the source is what runs in the tester — but it also means the risk ceiling is the broker's margin call, not an internal protection.
What to expect in a forward test: trade frequency will be low. Gold M5 only prints a body-engulfing bar on the correct side of a 50-EMA on a fraction of all bars, and the one-position-at-a-time cap means the EA waits for a close before re-entering. Expect the equity curve to look like a string of small 1:2 wins interrupted by occasional full-stop losses, with long flat stretches during Asian-session consolidation when the small-bodied bars do not satisfy the engulf condition. The pattern is more useful as a session filter for a discretionary trader — a way to align with a momentum bar in the direction of a slow EMA — than as a stand-alone income stream, but the engineering is honest: no hidden lot multiplier, no martingale, no curve-fitted add-on, no equity magic.
Strategy Deep Dive
Pipsgrowth EX12077 runs a single-handle EMA stack (50-period, MODE_EMA, PRICE_CLOSE) and waits for a new M5 bar. On bar close, OnTick() confirms the spread is under 250 points and that no position is open, then CheckSignal() reads bar 1 and bar 2's OHLC plus one buffer from the EMA and tests for a simplified bullish or bearish engulfing whose close is on the correct side of the moving average. The signal is binary — body-engulf on the right side of the EMA — and the same CheckSignal() returns immediately on a position open or a wider spread, so there is no state machine beyond a static lastBar timestamp. OpenBuy() and OpenSell() then size the lot through CalculateLotSize() (1% account risk floored to the symbol's lot step, with 0.01 fixed-lot fallback) and send the order via CTrade with FOK filling and 3-point deviation. The retry helpers at the bottom of the file are not wired into the live path; closes and modifies go straight to the broker through trade.PositionClose and trade.PositionModify.
Long entry when the most recent closed M5 bar is bullish and its body engulfs the previous bar's body (close above previous open) with the bar's close also above the 50-period EMA. Short entry mirrors with a bearish engulfing bar closing below the EMA. The engulfing check is gated by InpUseEngulfing, the spread must be under 250 points, and no other position may be open (single-position cap).
Positions close at the broker on the static 400-point stop or 800-point take profit, with CTrade configured for ORDER_FILLING_FOK and 3 points of deviation. The 250-point spread gate inside OnTick() also prevents new entries from being opened on a quote the EA cannot later manage cleanly. The TryClose_EX12077 / TryModify_EX12077 retry helpers are defined at the bottom of the file but are not wired into the live CheckSignal() / OpenBuy / OpenSell paths in this build.
Fixed 400 points on every entry (InpStopLoss = 400), applied symmetrically as Ask − 400*Point for buys and Bid + 400*Point for sells. With one position at a time and no pyramid or recovery, the worst per-trade dollar risk is exactly the lot size computed from the 1% account risk divided by the symbol's per-lot stop value.
Fixed 800 points (InpTakeProfit = 800), giving a 1:2 risk-to-reward ratio against the 400-point stop. TP is set at order placement via CTrade.Buy/Sell and held at the broker — no trailing, no partial close, no break-even shift.
Best suited for traders who want a transparent, single-pattern baseline on XAUUSD M5. Minimum recommended balance: $100 (EA's minDeposit) and the default 1% risk per trade gives $1 of dollar risk on a $100 account. Run on an ECN or RAW-spread account where typical XAUUSD spread stays under 20 points most of the day so the 250-point gate is rarely triggered, on a low-latency VPS since the EA evaluates inside the bar-close window, and expect signal frequency to concentrate in the London and New York sessions when gold trends; the Asian session's small-bodied bars will pass through with no signal, which is the intended behavior.
Strategy Logic
Pipsgrowth EX12077 MultiIndicatorConfluence — Strategy Logic Analysis (from .mq5 source)
Family: MultiIndicatorConfluence
Magic: 22212077
Version: 2.00
BRIEF:
Pattern Classifier EA for XAUUSD detecting Engulfing candlestick patterns with EMA trend filter for entry signals. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
CheckSignal()OpenBuy()OpenSell()CalculateLotSize()TryClose_EX12077()TryClosePartial_EX12077()TryModify_EX12077()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (10 total across 3 groups):
- [=== Strategy Parameters ===]
InpTrendEMA= 50 // TrendFilter(EMA) - [=== Strategy Parameters ===]
InpUseEngulfing=true// Use Engulfing Pattern - [=== Money Management ===]
InpRiskPercent=1.0// Risk Percent per Trade - [=== Money Management ===]
InpFixedLot=0.01// FixedLot(if Risk=0) - [=== Money Management ===]
InpStopLoss= 400 // StopLoss(points) - [=== Money Management ===]
InpTakeProfit= 800 // TakeProfit(points) - [=== Trade Management ===]
InpMagicNumber=22212077// Magic Number - [=== Trade Management ===]
InpTradeComment= "Psgrowth.com Expert_12077" // TradeComment - [=== Trade Management ===]
InpMaxSpread= 250 // MaxSpread(points) (Increased for Gold) - [=== Trade Management ===]
InpSlippage= 3 // Slippage
// Pipsgrowth EX12077 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// Pattern Classifier EA for XAUUSD detecting Engulfing candlestick patterns with EMA trend filter for entry signals. 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 |
|---|---|---|
| InpTrendEMA | 50 | Trend Filter (EMA) |
| InpUseEngulfing | true | Use Engulfing Pattern |
| InpRiskPercent | 1.0 | Risk Percent per Trade |
| InpFixedLot | 0.01 | Fixed Lot (if Risk=0) |
| InpStopLoss | 400 | Stop Loss (points) |
| InpTakeProfit | 800 | Take Profit (points) |
| InpMagicNumber | 22212077 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_12077" | Trade Comment |
| InpMaxSpread | 250 | Max Spread (points) (Increased for Gold) |
| InpSlippage | 3 | Slippage |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX12077 PatternClassifier_XAUUSD_5M — Engulfing 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 InpUseEngulfing = true; // Use Engulfing 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 = 400; // Stop Loss (points)
input int InpTakeProfit = 800; // Take Profit (points)
input group "=== Trade Management ==="
input int InpMagicNumber = 22212077; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_12077"; // Trade Comment
input int InpMaxSpread = 250; // Max Spread (points) (Increased for Gold)
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.
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.