Pipsgrowth EX12009 MultiIndicatorConfluence
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX12009 MACDStoch_XAUUSD_5M — dual-MACD + Stochastic confluence, full 12-layer stack.
Overview
Pipsgrowth EX12009 runs two MACD timeframes and a Stochastic in parallel on the same XAUUSD M5 chart, and only opens a position when all three agree. The slow MACD(34, 144) sets the directional bias; the fast MACD(13, 21) is used as a pullback gauge; the Stochastic(7, 3, 3, SMA, STO_LOWHIGH) confirms the reversal. The CheckSignal() function is the only place entry decisions are made, and it runs once per closed bar through a static datetime lastBar plus iTime gate so the EA never re-evaluates mid-bar.
The buy requires five clauses to all be true on the same bar: the slow MACD must be positive (M2 > 0, meaning the higher-timeframe trend is up), the fast MACD must be negative (M1 < 0, meaning price has pulled back below the fast MACD's zero line), the Stochastic main line must be in oversold territory below 20, and the Stochastic must cross up through its signal line (main on bar 1 above signal on bar 1, while main on bar 2 was at or below signal on bar 2). The sell mirrors the conditions: slow MACD negative, fast MACD positive, Stochastic main above 80, and a downward cross of the Stochastic signal line. There is no ADX filter, no volume filter, and no higher-timeframe candle confirmation — the entry is purely a three-indicator technicals agreement.
Position sizing is risk-percent based. CalculateLotSize() takes the broker's tick value, tick size, and point, computes riskPerLot = stopLossPoints * (tickValue / (tickSize / point)), divides balance * riskPercent by that, floors the result to LotsStep, and clamps to the symbol's min and max lot. With the defaults (1% risk, 400-point stop on a $1,000 XAUUSD account) the lot resolves to roughly 0.02 lots. Setting InpRiskPercent = 0 falls back to the fixed InpFixedLot = 0.01. This is a 1%-per-trade risk EA by default — more conservative than the 2% common in the EX10 family — and the 400-point stop on gold means each lost trade risks about $0.80 per 0.01 lot.
Stop loss is fixed at InpStopLoss = 400 points (4.00 price units on XAUUSD) and take profit is InpTakeProfit = 1200 points (12.00 price units), giving a 1:3 risk-to-reward ratio on the initial order. The default setup is therefore a 'let winners run' configuration: the EA assumes a $0.80 worst case on 0.01 lot and targets a $2.40 best case on the same lot. SL and TP are applied to every order at open through trade.Buy(lot, _Symbol, ask, sl, tp, comment) and trade.Sell(lot, _Symbol, bid, sl, tp, comment).
Trailing is where the EA does its real profit management. ManageProfitLock() runs on every tick, walks open positions in reverse, and for each position belonging to this EA's magic number checks whether the unrealized profit has crossed InpTrailStart = 300 points (3.00 price units). Once it has, the stop is ratcheted to currentBid - InpTrailDistance = 150 points (1.50 price units below price). The check is newSL > position.StopLoss(), so the stop only ever moves in the direction of profit — it never steps back. The ratchet is forward-only and is applied through TryModify_EX12009() which retries the modify up to 3 times at 100ms intervals on REQUOTE and TIMEOUT retcodes only — it deliberately does not retry on PRICE_CHANGED because a price-changed modify is almost always stale and should be recomputed from the new quote.
Pyramiding is enabled by default (InpEnablePyramid = true) and is the EA's only scaling method. Up to InpMaxPositions = 3 positions are allowed per direction, but a new position is only opened if IsGridSafe() returns true. IsGridSafe() walks the open positions and requires every existing same-direction position to be in profit of at least InpMinProfitPoints = 300 (3.00 price units on gold). This is not a grid — it is 'scaling into winners.' A losing position can never be averaged into. The check runs on every signal bar, so if a position is underwater, the EA simply does not pyramid until it comes back into 300 points of profit.
The spread filter is a 250-point cap (2.50 price units on XAUUSD). For comparison, most EX10 and EX12 family EAs cap spread at 60 or 35 points. The wider cap is intentional: gold spreads on retail brokers routinely exceed 100 points during the NY close and Asian session open, and a tighter filter would block most of the trading day. The 250-point cap is the 'do not trade during news' threshold, not a 'trade only in tight liquidity' filter. Slippage is set to 3 points and order filling is hard-coded to ORDER_FILLING_FOK in OnInit — unlike the EX10013 and EX12007 EAs that walk FOK > IOC > RETURN off SYMBOL_FILLING_MODE, this EA commits to FOK only.
The TryClose_EX12009, TryClosePartial_EX12009, and TryModify_EX12009 helpers all retry up to 3 times at 200ms (close) and 100ms (modify) intervals on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED retcodes for closes, but the modify helper only retries on REQUOTE and TIMEOUT. The file is clean of additional state: no OnTradeTransaction deal-history walk, no daily or weekly loss limits, no capital cap, no session filter, no news blackout, and no regime classifier. The 5-position CountPositions() helper simply tallies buys and sells by magic.
The header advertises '12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester.' Of those, only SIGNAL, ENTRY, MANAGE, RISK, SIZING, and SCALING are actually implemented in the code. There is no regime classifier, no separate confirm layer beyond the Stochastic cross, no capital cap, no news blackout, and no OnTester() function. The '12 layers' framing is aspirational copy, not a description of runtime behaviour. Users running the MT5 optimizer should expect the default OnTester() selection (raw custom-max), not the (net * pf) / (1 + dd) formula common in other EAs of the family.
What to expect in backtest on XAUUSD M5: the EA takes relatively few trades — a five-clause agreement on gold is rare — and when it does, the 1:3 R:R means winners are three times the size of losers. The trailing kicks in at 3 price units of profit, which is far enough from the 4-unit stop that a normal pullback will not stop the position out. Pyramiding on a winner will add one or two additional layers in a strong trend, each requiring the existing layers to be 300 points in profit before being added. Drawdowns should be bounded by the 1% per-trade risk multiplied by up to 3 simultaneous positions, so a worst-case spike against all three layers is around 3% of balance.
This is a clean, low-complexity pullback-trend EA designed for XAUUSD M5. It does not pretend to be smart money concepts, order blocks, or AI-driven; it is a 3-indicator technical agreement with disciplined risk, a 1:3 R:R, a forward-only trailing stop, and a 3-position scale-into-winners rule. Suitable for traders who want a clear, deterministic pullback entry on gold with built-in scaling and a wide enough spread cap to actually trade on retail brokers rather than getting filtered out for most of the day.
Strategy Deep Dive
On every tick the EA checks spread against the 250-point cap and runs ManageProfitLock() to ratchet stops on profitable positions; on a new bar CheckSignal() reads the previous two closed bars of the slow MACD(34, 144), the fast MACD(13, 21), and the Stochastic(7, 3, 3), and only fires when all three indicators agree. New entries go through CalculateLotSize() to size the position to 1% of balance, and existing positions are scaled up only via IsGridSafe() which requires every same-direction position to already be 300 points in profit — never averaging into a loser. The 1:3 R:R is fixed at open; only the stop moves after that, and only forward. There is no regime classifier, session filter, news blackout, daily-loss cap, or capital cap — the strategy is a pure three-indicator agreement with no other gates.
Long entries require the slow MACD(34, 144) to be positive (higher-timeframe trend up), the fast MACD(13, 21) to be negative (price has pulled back below the fast zero line), the Stochastic main line to be in oversold below 20, and a Stochastic main-vs-signal cross up on the same bar. Sell entries mirror the conditions: slow MACD negative, fast MACD positive, Stochastic main above 80, and a cross down. Signals are evaluated once per closed bar — CheckSignal() does not re-fire mid-bar.
There is no fixed time-based exit, no signal-flip exit, and no opposite-position close — the EA relies on the initial 1200-point take-profit hitting, the 400-point stop-loss being hit, or the trailing stop ratcheting the position to breakeven-plus. The trailing only activates after 300 points of unrealized profit and never moves backward. Pyramiding is not an exit mechanism; positions close individually as SL, TP, or trail dictate.
Every position is opened with a fixed 400-point stop loss (4.00 price units on XAUUSD), applied at order open via trade.Buy/Sell and never widened. The stop can only move forward through the trailing logic once the position has 300 points of unrealized profit, where it ratchets to 150 points below price and never steps back. There is no global account-level drawdown cap.
Take profit is fixed at 1200 points per position (12.00 price units on XAUUSD, 120 pips in MT4 terms), giving a 1:3 risk-to-reward ratio against the 400-point stop. The TP is set at order open through trade.Buy/Sell and is not scaled or trailed. In strong trends, the trailing stop may close positions before TP is hit, but the default expectation is that most winning positions reach the 1:3 target before the ratchet takes over.
Minimum recommended balance: $100 (with the 0.01 fixed-lot fallback), or $500 to absorb a worst-case 3% drawdown from the 3-position pyramid-into-winners. The 250-point spread cap (2.50 USD on XAUUSD) and 3-point slippage tolerance make this EA compatible with most retail ECN/STP brokers as long as commissions stay below $7 per round-trip lot. Best run on XAUUSD M5 during the London–New York overlap (13:00–17:00 UTC server) when Stochastic extremes at 20/80 are most likely to produce real reversals; the wider spread cap means the EA can also run through the Asian session without being filtered out, though trade frequency will drop. Verify the broker supports ORDER_FILLING_FOK (most ECN accounts do).
Strategy Logic
Pipsgrowth EX12009 MultiIndicatorConfluence — Strategy Logic Analysis (from .mq5 source)
Family: MultiIndicatorConfluence
Magic: 22212009
Version: 2.00
BRIEF:
Dual-MACD plus Stochastic confluence EA. A fast MACD catches pullback crossovers while a slow MACD confirms the higher-timeframe trend. Stochastic must be oversold/overbought and cross its signal line. Risk-based sizing, trailing, safe pyramiding and spread filter. 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()ManageProfitLock()IsGridSafe()CalculateLotSize()CountPositions()TryClose_EX12009()TryClosePartial_EX12009()TryModify_EX12009()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (22 total across 5 groups):
- [=== Indicator Settings ===]
InpM1Fast= 13 //MACD1 Fast - [=== Indicator Settings ===]
InpM1Slow= 21 //MACD1 Slow - [=== Indicator Settings ===]
InpM2Fast= 34 //MACD2Fast(Filter) - [=== Indicator Settings ===]
InpM2Slow= 144 //MACD2Slow(Filter) - [=== Indicator Settings ===]
InpStoK= 7 // Stochastic K - [=== Indicator Settings ===]
InpStoD= 3 // Stochastic D - [=== Indicator Settings ===]
InpStoSlow= 3 // Stochastic Slowing - [=== 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= 1200 // TakeProfit(points) - [=== Trade Management ===]
InpMagicNumber=22212009// Magic Number - [=== Trade Management ===]
InpTradeComment= "Psgrowth.com Expert_12009" // TradeComment - [=== Trade Management ===]
InpMaxSpread= 250 // MaxSpread(points) - [=== Trade Management ===]
InpSlippage= 3 // Slippage - [=== Profit Lock / Trailing ===]
InpEnableTrail=true// Enable Trailing Stop - [=== Profit Lock / Trailing ===]
InpTrailStart= 300 // Trail StartDistance(points) - [=== Profit Lock / Trailing ===]
InpTrailStep= 100 // TrailStep(points) - [=== Profit Lock / Trailing ===]
InpTrailDistance= 150 // Distance behind price (points) - [=== Pyramiding / Scaling ===]
InpEnablePyramid=true// Enable Pyramiding - [=== Pyramiding / Scaling ===]
InpMaxPositions= 3 // Max Open Positions - [=== Pyramiding / Scaling ===]
InpMinProfitPoints= 300 // MinProfit(points) to Add Next
// Pipsgrowth EX12009 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// Dual-MACD plus Stochastic confluence EA. A fast MACD catches pullback crossovers while a slow MACD confirms the higher-timeframe trend. Stochastic must be oversold/overbought and cross its signal line. Risk-based sizing, trailing, safe pyramiding and spread filter. 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 |
|---|---|---|
| InpM1Fast | 13 | MACD 1 Fast |
| InpM1Slow | 21 | MACD 1 Slow |
| InpM2Fast | 34 | MACD 2 Fast (Filter) |
| InpM2Slow | 144 | MACD 2 Slow (Filter) |
| InpStoK | 7 | Stochastic K |
| InpStoD | 3 | Stochastic D |
| InpStoSlow | 3 | Stochastic Slowing |
| InpRiskPercent | 1.0 | Risk Percent per Trade |
| InpFixedLot | 0.01 | Fixed Lot (if Risk=0) |
| InpStopLoss | 400 | Stop Loss (points) |
| InpTakeProfit | 1200 | Take Profit (points) |
| InpMagicNumber | 22212009 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_12009" | Trade Comment |
| InpMaxSpread | 250 | Max Spread (points) |
| InpSlippage | 3 | Slippage |
| InpEnableTrail | true | Enable Trailing Stop |
| InpTrailStart | 300 | Trail Start Distance (points) |
| InpTrailStep | 100 | Trail Step (points) |
| InpTrailDistance | 150 | Distance behind price (points) |
| InpEnablePyramid | true | Enable Pyramiding |
| InpMaxPositions | 3 | Max Open Positions |
| InpMinProfitPoints | 300 | Min Profit (points) to Add Next |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX12009 MACDStoch_XAUUSD_5M — dual-MACD + Stochastic confluence, 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 "=== Indicator Settings ==="
input int InpM1Fast = 13; // MACD 1 Fast
input int InpM1Slow = 21; // MACD 1 Slow
input int InpM2Fast = 34; // MACD 2 Fast (Filter)
input int InpM2Slow = 144; // MACD 2 Slow (Filter)
input int InpStoK = 7; // Stochastic K
input int InpStoD = 3; // Stochastic D
input int InpStoSlow = 3; // Stochastic Slowing
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 = 1200; // Take Profit (points)
input group "=== Trade Management ==="
input int InpMagicNumber = 22212009; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_12009"; // Trade Comment
input int InpMaxSpread = 250; // Max Spread (points)
input int InpSlippage = 3; // Slippage
input group "=== Profit Lock / Trailing ==="
input bool InpEnableTrail = true; // Enable Trailing Stop
input int InpTrailStart = 300; // Trail Start Distance (points)
input int InpTrailStep = 100; // Trail Step (points)
input int InpTrailDistance = 150; // Distance behind price (points)
input group "=== Pyramiding / Scaling ==="
input bool InpEnablePyramid = true; // Enable Pyramiding
input int InpMaxPositions = 3; // Max Open Positions
input int InpMinProfitPoints= 300; // Min Profit (points) to Add Next
//--- Handles
int hM1;
int hM2;
int hSto;
//--- Global Buffers
double bufM1[];
double bufM2[];
double bufStoM[];
double bufStoS[];
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.