Pipsgrowth EX12027 MultiIndicatorConfluence
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX12027 EA_X1_v1_1 — EMA/RSI crossover with retest filter and dynamic lock profit, full 12-layer stack.
Overview
EX12027 is built around a deliberately slow EMA pair — Fast EMA(70) and Slow EMA(290) — paired with a long-period RSI(37) that has to cross an extreme threshold (25 for buys, 70 for sells) before any signal is accepted. The combination is uncommon: the EMAs are wide enough apart to define real structural swings rather than the 5-to-50 crossovers most crossover EAs use, and the RSI thresholds are pushed to oversold/overbought rather than the more typical 30/70 midline bounces. The result is a system that holds a directional view through chop and only commits when momentum has stretched to an extremity and then begins to mean-revert toward the trend.
The signal engine has three gates. The first is the EMA trend bias, which is simply Fast EMA(70) above Slow EMA(290) for long bias and the mirror for short. The second is the RSI cross — for a buy, the previous-bar RSI value must have been below 25 and the current value at or above 25; for a sell, the previous bar must be above 70 and the current at or below 70. The third gate is an optional MACD histogram confirmation, off by default, that blocks the trade unless the histogram agrees with the direction. The MACD uses the standard 12/26/9 fast/slow/signal configuration, and you can also enforce a minimum absolute histogram value (InpMACDMinHistAbs, default 0) to require momentum of a certain size before the trade is taken. With MACD confirmation disabled, the EA trusts the EMA + RSI combination alone.
The retest (re-touch) entry filter is the EA's most distinctive optional behaviour. When InpOnlyRetestEntry is set true, a confirmed buy signal does not fire a market order immediately — instead, the EA marks the signal and waits up to InpRetestMaxBars (default 3) bars for price to pull back to within InpRetestTolerancePoints (default 150 points) of the Fast EMA(70). If the pullback arrives in time, the buy fires off the retest rather than the crossover bar; if the window expires, the pending signal is cancelled. The mirror applies to sells (a sell retest is a rally back up to the fast EMA). This is a real-world-tradable pattern: crossovers that don't get a retest tend to whipsaw, while crossovers that do get a retest tend to run.
Stops and targets have two modes. The default mode is fixed points: SL=2400 points and TP=1800 points, which yields a 1.33:1 reward-to-risk ratio against the configured SL. When InpUseATRStops is enabled, the EA switches to ATR(14) and applies a 2×ATR stop and a 3×ATR target, restoring the 1.5:1 ratio but expressed in volatility units. The ATR mode is more portable across symbols — a 2400-point stop has very different meaning on XAUUSD versus USDJPY — but the fixed-point mode is what most backtests on the default USDJPY/M5 input set have been run with. Position sizing is also dual-mode: by default the EA uses a fixed 1.0 lot per trade, but if InpUseRiskPercent is on, lots are calculated as (balance × 1%) divided by (SL points × point-value-per-lot), with the SL distance being either the ATR-derived value or the fixed 2400 points depending on the stops mode.
The dynamic lock profit (DLP) is the management layer that actually defines this EA's behaviour on winners. Once InpEnableDynamicLockProfit is on, the EA walks every open position on every tick. It measures how far price has moved in the position's favour in points, divides that move by InpLockProfitEveryXPoints (default 1500), and the integer result is the number of "lock steps" to apply. The new stop is set to entry + (steps × 1500) − 76 points, with the 76-point buffer (InpLockMinusYPointsBuffer) preventing the lock from sitting exactly on entry. The can-modify guard rejects any move that would tighten the SL by less than 0.5 points, that would put the SL inside the broker's freeze level, or that would actually loosen a buy stop or tighten a sell stop incorrectly. The net effect: every 1500 points of favourable price travel, the stop is ratcheted up by 1500 points minus the 76-point give-back. The DLP only ever ratchets in the profitable direction; the 76-point buffer keeps the trade from being closed on noise right after the lock engages.
The multi-position scaling layer permits up to 6 simultaneous trades in the same direction (MaxOpenTrades=6), but with a strict gating rule: AllowOnlyProfitableAdditions is on by default, which means a second, third, etc. position in the same direction can only be added if every existing same-direction position has moved at least MinProfitPerTradeToAdd (default 5 points) in the favourable direction. This is a real filter: it prevents the EA from averaging into a losing position during a counter-trend move. The first position in a sequence is tagged in the comment as "Initial" (or "Retest"); subsequent additions are tagged "Add#1", "Add#2", etc. The EA counts its own add-tagged positions via CountAdditionalPositions() and refuses a new add if the 6-position cap would be exceeded.
No-trade gates are layered. The spread cap (InpSpreadCapPoints, default 0) auto-resolves to 3× the rolling median spread computed over a 121-tick buffer, which is populated every tick by SpreadTrackerUpdate(). If the live spread is above that cap, no new orders are placed. The session filter is off by default but defines three discrete windows when enabled: 07:00–10:00, 13:00–17:00, and 20:00–23:00 server time, with weekends blocked regardless. Symbol trade mode is checked: if the broker reports anything other than SYMBOL_TRADE_MODE_FULL, the order is refused with a once-per-second warning. Filling mode is auto-detected per symbol via GetBestFillingMode() with IOC preferred, then RETURN, then FOK as a fallback. Slippage is capped at InpMaxSlippagePoints (default 5) and passed into the request deviation field.
The retry layer is asymmetric. Open orders go through OrderSendWithRetry with up to 3 retries, sleeping 150 ms × attempt between attempts; if the broker returns INVALID_STOPS, the EA nulls out the SL and TP and retries once more with no stops. Close retries (TryClose_EX12027) loop 3 times at 200 ms intervals, retrying on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED. Modify retries (TryModify_EX12027) loop 3 times at 100 ms but only on REQUOTE and TIMEOUT — price-change errors are not retried, on the theory that a re-quote-on-modify with a different price should not be re-attempted blindly.
What to expect on a backtest: with the default inputs (EMA 70/290, RSI 37, 25/70 thresholds, fixed 2400/1800 stops, 1.0 lot, no MACD confirm, no retest filter, DLP on, 1500/76 lock, sessions off, spread cap auto), the EA will trade infrequently. The 70/290 EMA pair only realigns a handful of times per year on H1; on M5 the same pair whipsaws more and benefits strongly from the retest filter being enabled. The DLP layer is the dominant performance shaper — it converts winners into lock-and-hold trades rather than letting them round-trip back to the entry. A user who turns the retest filter on and disables fixed stops in favour of ATR stops gets a more portable configuration at the cost of slightly more trades per signal.
Strategy Deep Dive
On every tick, the EA refreshes a 121-entry spread buffer and walks all open positions to apply the dynamic lock profit, which measures the in-favour move in points, divides by the lock step (1500 by default), and pushes the stop up by that many lock steps minus a 76-point buffer while refusing any move inside the broker's freeze level. On a new bar, SignalBuy() and SignalSell() fire: the buy requires the prior-bar RSI(37) to have been under 25 with the current bar at or above 25, the Fast EMA(70) above the Slow EMA(290), and (if enabled) MACD histogram agreement; the sell is the mirror. The session filter (off by default) blocks trades outside three discrete windows (07–10, 13–17, 20–23 server), the spread cap blocks trades above 3× the rolling median, and the multi-position manager permits up to 6 same-direction positions but only adds when every existing same-direction trade is at least 5 points in profit. When InpOnlyRetestEntry is on, a confirmed signal is held as a pending flag and the entry fires only when price returns within 150 points of the Fast EMA inside a 3-bar window, after which the pending flag is cleared.
A buy signal requires the previous-bar RSI(37) to be below 25 and the current value at or above 25, while the Fast EMA(70) is above the Slow EMA(290); a sell signal mirrors with the RSI(37) crossing down through 70 below the slow EMA. When the optional MACD confirmation is enabled, the histogram must agree with the direction; when the optional retest filter is enabled, the entry is held until price pulls back within 150 points of the Fast EMA within 3 bars.
Exits are managed by the dynamic lock profit layer on every tick: every 1500 points of favourable move, the stop is ratcheted up by 1500 points minus a 76-point buffer, with the stop only ever tightening in the profitable direction. There is no fixed-time exit and no opposite-signal exit — the EA relies on the DLP and the broker-side SL/TP to close positions.
Default stop loss is 2400 fixed points (a 1.33:1 reward-to-risk vs the 1800-point TP), with a max slippage cap of 5 points on entry. When InpUseATRStops is enabled, the stop becomes 2×ATR(14), making the SL portable across symbols. The dynamic lock profit layer also enforces a minimum stop of entry price on winning positions.
Default take profit is 1800 fixed points, yielding a 1.33:1 R:R against the 2400-point SL. When ATR stops are enabled, the TP becomes 3×ATR(14), which raises the ratio to 1.5:1 against the 2×ATR stop and adapts to the symbol's current volatility.
Best run on M5 or H1 with the default USDJPY symbol setting (or XAUUSD for higher volatility), or any major FX pair given the EMA 70/290 and RSI 37 are tuned for swing structures rather than tick noise. Recommended minimum balance is $100 with the default 1.0-lot sizing, or $1,000+ if you flip InpUseRiskPercent on to size off 1% of equity. A low-spread ECN broker is required because the 3×median spread cap is tight by design, and the dynamic lock profit layer is sensitive to spread expansion on winners. Run on a non-session-filtered server first to confirm the EMA 70/290 alignment frequency matches your symbol.
Strategy Logic
Pipsgrowth EX12027 MultiIndicatorConfluence — Strategy Logic Analysis (from .mq5 source)
Family: MultiIndicatorConfluence
Magic: 22212027
Version: 2.00
BRIEF:
EMA crossover EA with RSI threshold entries, optional MACD confirmation, retest (re-touch) entry filter, ATR-based or fixed SL/TP, dynamic lock profit, session filters, spread control, and multi-position management with profitable-add gating. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
AttemptOpenDirection()Tag()Log()WarnOncePerSec()IsOurPosition()CountOpenPositions()CountAllOpenPositions()CountAdditionalPositions()IsAllSameDirProfitableAtLeast()NormalizeVolume()NormalizePrice()ParseTimeToMinutes()- ...and 29 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (43 total across 8 groups):
- [=== Identity ===]
InpSymbol= "USDJPY" // Trading Symbol - [=== Identity ===]
InpTimeframe= 1 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Chart Timeframe - [=== Identity ===]
MagicNumber=22212027// Magic Number - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_12027" // Trade comment - [=== Signal ===]
InpEMAFastPeriod= 70 // FastEMAPeriod - [=== Signal ===]
InpEMASlowPeriod= 290 // SlowEMAPeriod - [=== Signal ===]
InpRSIPeriod= 37 //RSIPeriod - [=== Signal ===]
InpRSIBuyThreshold=25.0//RSIBuyThreshold(cross above) - [=== Signal ===]
InpRSISellThreshold=70.0//RSISellThreshold(cross below) - [=== Signal ===]
InpAllowBuy=true// Allow Buy Entries - [=== Signal ===]
InpAllowSell=true// Allow Sell Entries - [=== Signal ===]
InpUseMACDConfirm=false// UseMACDHistogram Confirmation - [=== Signal ===]
InpMACDFastEMA= 12 //MACDFastEMA - [=== Signal ===]
InpMACDSlowEMA= 26 //MACDSlowEMA - [=== Signal ===]
InpMACDSignalSMA= 9 //MACDSignalSMA - [=== Signal ===]
InpMACDMinHistAbs=0.0// Min abs histogram (0=any sign) - [=== Entry ===]
InpOnlyRetestEntry=false// Only open on retest of FastEMAafter signal - [=== Entry ===]
InpRetestMaxBars= 3 // Max bars to wait for retest - [=== Entry ===]
InpRetestTolerancePoints= 150 // Retest tolerance (points distance to FastEMA) - [=== Exit ===]
InpUseATRStops=false// UseATR-based SL/TP - [=== Exit ===]
InpATRPeriod= 14 //ATRPeriod - [=== Exit ===]
InpATRSLMult=2.0//ATRSL Multiplier - [=== Exit ===]
InpATRTPMult=3.0//ATRTP Multiplier - [=== Sizing ===]
InpUseRiskPercent=false// Use Risk Percentage - [=== Sizing ===]
InpRiskPercent=1.0// RiskPercentage(% of balance) - [=== Sizing ===]
InpFixedLot=1.0// Fixed Lot Size - [=== Sizing ===]
InpSLPoints= 2400 // Fixed StopLoss(points) - [=== Sizing ===]
InpTPPoints= 1800 // Fixed TakeProfit(points) - [=== Sizing ===]
InpMaxSlippagePoints= 5 // MaximumSlippage(points) - [===
NO-TRADE===]InpSpreadCapPoints=0.0// SpreadCap(points, 0=auto 3×median) - [===
NO-TRADE===]InpUseSessionFilter=false// Enable Session Filter - [===
NO-TRADE===]InpSession1StartTime= "07:00" // Session 1 Start Time - [===
NO-TRADE===]InpSession1EndTime= "10:00" // Session 1 End Time - [===
NO-TRADE===]InpSession2StartTime= "13:00" // Session 2 Start Time - [===
NO-TRADE===]InpSession2EndTime= "17:00" // Session 2 End Time - [===
NO-TRADE===]InpSession3StartTime= "20:00" // Session 3 Start Time - [===
NO-TRADE===]InpSession3EndTime= "23:00" // Session 3 End Time - [=== Manage ===]
InpEnableDynamicLockProfit=true// Enable Dynamic Lock Profit - [=== Manage ===]
InpLockProfitEveryXPoints= 1500 // Lock Profit Every X Points - [=== Manage ===]
InpLockMinusYPointsBuffer= 76 // LockBuffer(points back from high) - [=== Scaling ===]
MaxOpenTrades= 6 // Maximum Open Trades - [=== Scaling ===]
AllowOnlyProfitableAdditions=true// Allow Only Profitable Additions - [=== Scaling ===]
MinProfitPerTradeToAdd=5.0// Min Profit Per Trade toAdd(points)
// Pipsgrowth EX12027 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// EMA crossover EA with RSI threshold entries, optional MACD confirmation, retest (re-touch) entry filter, ATR-based or fixed SL/TP, dynamic lock profit, session filters, spread control, and multi-position management with profitable-add gating. 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 |
|---|---|---|
| InpSymbol | "USDJPY" | Trading Symbol |
| InpTimeframe | 1 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Chart Timeframe |
| MagicNumber | 22212027 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_12027" | Trade comment |
| InpEMAFastPeriod | 70 | Fast EMA Period |
| InpEMASlowPeriod | 290 | Slow EMA Period |
| InpRSIPeriod | 37 | RSI Period |
| InpRSIBuyThreshold | 25.0 | RSI Buy Threshold (cross above) |
| InpRSISellThreshold | 70.0 | RSI Sell Threshold (cross below) |
| InpAllowBuy | true | Allow Buy Entries |
| InpAllowSell | true | Allow Sell Entries |
| InpUseMACDConfirm | false | Use MACD Histogram Confirmation |
| InpMACDFastEMA | 12 | MACD Fast EMA |
| InpMACDSlowEMA | 26 | MACD Slow EMA |
| InpMACDSignalSMA | 9 | MACD Signal SMA |
| InpMACDMinHistAbs | 0.0 | Min abs histogram (0=any sign) |
| InpOnlyRetestEntry | false | Only open on retest of Fast EMA after signal |
| InpRetestMaxBars | 3 | Max bars to wait for retest |
| InpRetestTolerancePoints | 150 | Retest tolerance (points distance to Fast EMA) |
| InpUseATRStops | false | Use ATR-based SL/TP |
| InpATRPeriod | 14 | ATR Period |
| InpATRSLMult | 2.0 | ATR SL Multiplier |
| InpATRTPMult | 3.0 | ATR TP Multiplier |
| InpUseRiskPercent | false | Use Risk Percentage |
| InpRiskPercent | 1.0 | Risk Percentage (% of balance) |
| InpFixedLot | 1.0 | Fixed Lot Size |
| InpSLPoints | 2400 | Fixed Stop Loss (points) |
| InpTPPoints | 1800 | Fixed Take Profit (points) |
| InpMaxSlippagePoints | 5 | Maximum Slippage (points) |
| InpSpreadCapPoints | 0.0 | Spread Cap (points, 0=auto 3×median) |
| InpUseSessionFilter | false | Enable Session Filter |
| InpSession1StartTime | "07:00" | Session 1 Start Time |
| InpSession1EndTime | "10:00" | Session 1 End Time |
| InpSession2StartTime | "13:00" | Session 2 Start Time |
| InpSession2EndTime | "17:00" | Session 2 End Time |
| InpSession3StartTime | "20:00" | Session 3 Start Time |
| InpSession3EndTime | "23:00" | Session 3 End Time |
| InpEnableDynamicLockProfit | true | Enable Dynamic Lock Profit |
| InpLockProfitEveryXPoints | 1500 | Lock Profit Every X Points |
| InpLockMinusYPointsBuffer | 76 | Lock Buffer (points back from high) |
| MaxOpenTrades | 6 | Maximum Open Trades |
| AllowOnlyProfitableAdditions | true | Allow Only Profitable Additions |
| MinProfitPerTradeToAdd | 5.0 | Min Profit Per Trade to Add (points) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX12027 EA_X1_v1_1 — EMA/RSI crossover with retest filter and dynamic lock profit, full 12-layer stack."
#include <Trade/Trade.mqh>
//===================================================================
// CORE SETTINGS
//===================================================================
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M5;
case 3: return PERIOD_M15;
case 4: return PERIOD_M30;
case 5: return PERIOD_H1;
case 6: return PERIOD_H4;
case 7: return PERIOD_D1;
default: return PERIOD_H1;
}
}
ENUM_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
switch(ap)
{
case 1: return PRICE_CLOSE;
case 2: return PRICE_OPEN;
case 3: return PRICE_HIGH;
case 4: return PRICE_LOW;
case 5: return PRICE_MEDIAN;
case 6: return PRICE_TYPICAL;
case 7: return PRICE_WEIGHTED;
default: return PRICE_CLOSE;
}
}
ENUM_TIMEFRAMES g_InpTimeframe = PERIOD_H1;
input group "=== Identity ==="
input string InpSymbol = "USDJPY"; // Trading Symbol
input int InpTimeframe = 1; // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Chart Timeframe
input int MagicNumber = 22212027; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_12027"; // Trade comment
//===================================================================
// TRADING STRATEGY
//===================================================================
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M5;
case 3: return PERIOD_M15;
case 4: return PERIOD_M30;
case 5: return PERIOD_H1;
case 6: return PERIOD_H4;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.