P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX12004 MultiIndicatorConfluence

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

Pipsgrowth.com EX12004 USDJPY Confluence — 5-factor AND-gate confluence EA, full 12-layer stack.

Overview

EX12004 MultiIndicatorConfluence is a USDJPY-tuned trend-confirmation EA built around a strict 5-of-5 AND gate. The whole strategy is reductionist: rather than scoring votes or ranking indicators, the EA waits for five independent conditions to line up on the same closed bar before it will even consider opening a position. Partial agreement — even 4 out of 5 — produces no signal. This is what makes the entry frequency low but the win-rate-versus-noise ratio disproportionately high in trending regimes on M5.

The five factors in CoreSignal() are: (1) EMA(21) versus EMA(55) direction, (2) smoothed Heikin-Ashi candle color on the closed bar, (3) RSI(14) above the bull threshold of 55.0 or below the bear threshold of 45.0, (4) MACD(12,26,9) main line above or below signal line, and (5) ADX(14) ≥ 18.0 (InpADXMin) with +DI/-DI directional agreement. Each factor contributes a single bull or bear vote, and only a clean 5-bull or 5-bear tally returns a non-zero signal. The closed bar (idx=1) is the only reference point, so signal evaluation is deterministic and not subject to intra-bar repaint.

Heikin-Ashi is constructed in-line in BuildHeikinAshi() from the last 256 M5 bars using the standard HA close/open formulas, then EMA-smoothed with smoothing period 3 (alpha = 2/(3+1) = 0.5). The result is a colour-stable filter that suppresses chop-noise on the raw candle series. Combined with the EMA cross, the Heikin-Ashi check effectively requires the price to be making higher-high/higher-low structure on a smoothed basis, not just a single-bar bounce.

Regime detection runs on every new bar through DetectRegime(), which classifies the current state into one of eight categories: STRONG_TREND (ADX ≥ 30), WEAK_TREND (ADXInpADXMin but < 30), EXPAND (ATR-percentile > 70 and Bollinger-band width expanding ≥ 1.15×), COMPRESS (ATR-percentile < 25), BREAKOUT (tight band, rising ADX), RANGE, CHOPPY, or REG_NONE. The ATR-percentile rank is computed over a 60-bar lookback (InpATRPctLookback), which means the regime classifier is adaptive to recent volatility — a market that feels calm because it was noisy last week still reads as COMPRESS in the current context.

Layer 5 — the no-trade block — is what actually gates entries. NoTradeBlock() refuses the trade when: the kill switch is on, spread exceeds InpMaxSpreadPts (35 points, USDJPY-tuned), outside the trading session (0–24 server time, so always-on but session itself doesn't actually filter), the regime is CHOPPY, the previous bar's range exceeded 3× ATR (news/big-candle guard), the cooldown timer is still active after consecutive losses, effective capital is below the InpCapitalCapFloor ($50), the realized daily loss has hit 3% of effective cap, the open-position count is at MAX_OPEN_TRADES (1), or it is Friday after 21:00 / Saturday / Sunday. The two big practical filters here are the CHOPPY regime rejection and the 3×-ATR news-bar rejection, both of which cut the failure modes that pure-confluence EAs typically bleed on.

Layer 6 — the capital cap — is opt-in. With InpCapitalCapAmount = 0.0 (default) the cap is disabled and EffectiveCapital() returns the full account equity. Set it to a positive value to cap the EA's notion of tradeable equity at that figure, which then governs both the position size (via InpRiskPercent = 0.5% of effective cap) and the daily-loss limit (3% of effective cap). The floor (InpCapitalCapFloor = 50) prevents the EA from trying to size trades on a near-empty account.

Stop and target are derived purely from ATR(14). SL = ATR × InpATRSLMult (default 2.0) floored at the broker's minimum stops distance. TP = SL × InpRRTP (default 2.0), so the structure is 1:2 R:R — a winning trade pays twice what a losing one risks, and the win-rate does not need to be 50% to be profitable. After entry, ManageExits() runs every tick and stacks four exit mechanics in order: (a) at +1R the stop is moved to break-even on the open price, (b) at +1R half the position is closed (PARTIAL_TP_PCT = 50), (c) an ATR(14) × InpATRTrailMult (default 2.5) trailing stop ratchets forward only, and (d) if the trade has been open for 120 bars (10 hours on M5) it is closed unconditionally.

The OnTradeTransaction handler walks the deal stream for DEAL_TRANSACTION_DEAL_ADD events matching this EA's magic and symbol, accumulates realized P&L per close, and triggers a 3-bar cooldown if COOLDOWN_AFTER_LOSS (3) consecutive losses occur. The cooldown is a TimeCurrent() + PeriodSeconds × 3 expiry — exactly three M5 bars in this default config. Combined with the 1-trade cap, the cooldown means a losing streak temporarily freezes the EA without flattening or reversing anything.

Two toggles in the input set deserve special attention. InpDryRun (default true) means the EA logs every entry attempt with full parameters (price, SL, TP, lots, confidence) but does not actually send the order — flip it to false to go live. InpKillSwitch (default false), when set to true, makes OnTick() call DoKillSwitch() and return before any other logic runs, which is the panic-button close-all-and-stop behaviour. The HTF confirmation timeframe (InpHTF) defaults to 8, which falls through the MapTimeframeInt switch and resolves to PERIOD_H1; the EA then requires the closed-bar M5 close to be on the correct side of the H1 EMA(50) before any entry will fire. Set InpHTF to 5 to make that explicit; lower values give the EA more signals but weaker trend context.

Order execution is the standard CTrade wrapper. SetDeviationInPoints(20) for a 20-point slippage budget, SetTypeFillingBySymbol() to auto-pick the broker's supported filling mode (FOKIOCRETURN), and SetMarginMode() for accurate margin checks before send. OrderCalcMargin is called explicitly before the send, and the trade is aborted if required margin exceeds free margin — a guard the typical copy-paste EA does not bother with. On entry failure the code retries once after a 150 ms sleep, then gives up. Closes and modifies are wrapped in 3-retry loops with 200 ms / 100 ms sleeps on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED.

The OnTester custom criterion is (net × profit factor) / (1 + |balance drawdown|), with a 30-trade minimum (trades below that return 0). This formula rewards both raw profit and consistency, and penalizes drawdown linearly — meaning a strategy with 2× the net profit at 3× the drawdown will score lower than a smoother strategy with half the profit. For a 5-of-5 confluence EA on M5 USDJPY, expect trade frequency in the 2–8 trades-per-day range, concentrated in the London and New York sessions, with a strong dependency on regime — most of the equity curve is built during the ADX > 25 windows, and the choppy, ranging weeks are mostly dead capital preserved by the no-trade block.

Strategy Deep Dive

Eight native indicator handles (EMA21, EMA55, RSI14, MACD 12/26/9, ADX14, ATR14, BB20-2.0, HTF EMA50) feed CoreSignal(), which tallies five independent bull/bear votes on the closed bar. DetectRegime() runs in parallel and classifies the market into one of eight states using ADX, ATR-percentile (60-bar), and Bollinger-band-width dynamics. NoTradeBlock() then enforces a 12-condition guard including CHOPPY regime, >3× ATR news bars, daily loss cap, equity floor, weekend, and Friday-21:00 cutoff. ConfirmEntry() adds the H1 EMA(50) directional agreement and a 35-point USDJPY-tuned spread cap. After all gates pass, TryEntry() sizes to 0.5% risk of effective capital, sends the order, and ManageExits() takes over on the next tick with a four-stage exit cascade. The pyramid path is intentionally disabled by MAX_OPEN_TRADES=1, making this a single-position confluence strategy rather than a scaling system.

Entry Signal

Five-factor AND gate on the closed M5 bar: EMA(21) vs EMA(55) direction, smoothed Heikin-Ashi close-vs-open color, RSI(14) above 55.0 (bull) or below 45.0 (bear), MACD(12,26,9) main above/below signal, and ADX(14) ≥ 18.0 with +DI/-DI agreement. All five must agree or the EA returns no signal. HTF (H1 by default) EMA(50) agreement is then required before any order is sent.

Exit Signal

Four-stage management: at +1R the stop moves to break-even (open price) and 50% of the position is closed as partial TP. An ATR(14) × 2.5 trailing stop ratchets forward only, never back. A 120-bar time-stop (10 hours on M5) closes the trade unconditionally. Opposite-signal or regime-change-to-CHOPPY/RANGE/COMPRESS also force an immediate exit.

Stop Loss

SL = ATR(14) × InpATRSLMult (default 2.0), floored at the broker's SYMBOL_TRADE_STOPS_LEVEL. The SL is ratcheted to break-even at +1R, then trails at ATR(14) × 2.5 thereafter. Maximum one open position at a time (MAX_OPEN_TRADES = 1).

Take Profit

TP = SL × InpRRTP (default 2.0), giving a 1:2 risk-to-reward ratio. At +1R, 50% of the position is closed as a partial TP, and the remaining 50% rides the trailing stop toward the original TP or beyond.

Best For

Designed for USDJPY M5 (works M5-M30). Recommended minimum balance $100 with 0.5% risk per trade. Best paired with a low-spread USDJPY broker (the 35-point spread cap is the binding cost constraint) on a USD or JPY-denominated account. ECN or raw-spread account required for the partial-TP and trailing-stop management to work without requote friction. Run on a VPS with low latency to the broker — the entry retry-on-150ms-sleep pattern is sensitive to execution delay. Flip InpDryRun from true to false only after at least 30 trades in the strategy tester pass the OnTester criterion.

Strategy Logic

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

Family: MultiIndicatorConfluence Magic: 22212004 Version: 2.00

BRIEF: Preserves the original 1219 thesis: ALL-of multi-indicator AND confluence (pyramid-scaler). 5-factor AND gate: EMA(fast) vs EMA(slow), Heikin-Ashi close vs open, RSI side, MACD main vs signal, ADX + DI+/DI- agreement. BUY when all 5 agree / SELL when all 5 disagree (closed bar). All inlined from native primitives (iMA/iATR/iADX/iBands/iRSI/iMACD) — no iCustom. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • MAFast
  • MASlow
  • RSI
  • MACD
  • ADX
  • ATR
  • BB
  • HTFEMA

KEY FUNCTIONS:

  • NormPrice()
  • ClampVol()
  • MinStopsDist()
  • SpreadPoints()
  • InSession()
  • IsNewBar()
  • EffectiveCapital()
  • RealizedPnLToday()
  • CountMyPositions()
  • BuildHeikinAshi()
  • CoreSignal()
  • ConfirmEntry()
  • ...and 10 more

INTERNAL CONSTANTS (1 total):

  • BIG_CANDLE_ATR_MULT = 3.0 // =================== GLOBALS / HANDLES ==============================

INPUT PARAMETERS (21 total across 6 groups):

  • [=== Identity ===] InpMagic = 22212004 // Magic number
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_12004" // Trade comment
  • [=== Signal: Multi-Indicator AND Confluence ===] InpFastEMA = 21 // Fast EMA period (bars)
  • [=== Signal: Multi-Indicator AND Confluence ===] InpSlowEMA = 55 // Slow EMA period (bars)
  • [=== Signal: Multi-Indicator AND Confluence ===] InpRSIPeriod = 14 // RSI period (bars)
  • [=== Signal: Multi-Indicator AND Confluence ===] InpRSIBullLevel = 55.0 // RSI bull threshold (>=)
  • [=== Signal: Multi-Indicator AND Confluence ===] InpRSIBearLevel = 45.0 // RSI bear threshold (<=)
  • [=== Regime Gate ===] InpADXMin = 18.0 // Min ADX for WeakTrend
  • [=== Regime Gate ===] InpATRPctLookback = 60 // ATR percentile lookback (bars)
  • [=== Confirm & No-Trade ===] InpHTF = 8 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // HTF trend time-frame
  • [=== Confirm & No-Trade ===] InpHTFEMA = 50 // HTF EMA period (bars)
  • [=== Confirm & No-Trade ===] InpMaxSpreadPts = 35.0 // Max spread (points, USDJPY-tuned)
  • [=== Risk & Sizing ===] InpDryRun = true // Dry-run: no real sends
  • [=== Risk & Sizing ===] InpKillSwitch = false // Kill switch (closes all on tick)
  • [=== Risk & Sizing ===] InpCapitalCapAmount = 0.0 // Capital cap amount ($ equity)
  • [=== Risk & Sizing ===] InpCapitalCapFloor = 50.0 // Capital cap floor ($)
  • [=== Risk & Sizing ===] InpRiskPercent = 0.5 // Risk per trade (% of eff. cap)
  • [=== Risk & Sizing ===] InpDailyLossLimit = 3.0 // Daily loss limit (% of eff. cap)
  • [=== Risk & Sizing ===] InpATRSLMult = 2.0 // SL = ATR x mult
  • [=== Risk & Sizing ===] InpRRTP = 2.0 // TP = R x mult (R = SL dist)
  • [=== Manage & Exit ===] InpATRTrailMult = 2.5 // ATR trail distance (x ATR)
Pseudocode
// Pipsgrowth EX12004 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// Preserves the original 1219 thesis: ALL-of multi-indicator AND confluence (pyramid-scaler). 5-factor AND gate: EMA(fast) vs EMA(slow), Heikin-Ashi close vs open, RSI side, MACD main vs signal, ADX + DI+/DI- agreement. BUY when all 5 agree / SELL when all 5 disagree (closed bar). All inlined from native primitives (iMA/iATR/iADX/iBands/iRSI/iMACD) — no iCustom. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

ON_INIT:
    Create indicator handles: MAFast, MASlow, RSI, MACD, ADX, ATR, BB, HTFEMA
    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:
USDJPY
Optimized Timeframes:
M5M30

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
InpMagic22212004Magic number
InpTradeComment"Psgrowth.com Expert_12004"Trade comment
InpFastEMA21Fast EMA period (bars)
InpSlowEMA55Slow EMA period (bars)
InpRSIPeriod14RSI period (bars)
InpRSIBullLevel55.0RSI bull threshold (>=)
InpRSIBearLevel45.0RSI bear threshold (<=)
InpADXMin18.0Min ADX for WeakTrend
InpATRPctLookback60ATR percentile lookback (bars)
InpHTF8Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // HTF trend time-frame
InpHTFEMA50HTF EMA period (bars)
InpMaxSpreadPts35.0Max spread (points, USDJPY-tuned)
InpDryRuntrueDry-run: no real sends
InpKillSwitchfalseKill switch (closes all on tick)
InpCapitalCapAmount0.0Capital cap amount ($ equity)
InpCapitalCapFloor50.0Capital cap floor ($)
InpRiskPercent0.5Risk per trade (% of eff. cap)
InpDailyLossLimit3.0Daily loss limit (% of eff. cap)
InpATRSLMult2.0SL = ATR x mult
InpRRTP2.0TP = R x mult (R = SL dist)
InpATRTrailMult2.5ATR trail distance (x ATR)
Source Code (.mq5)Open Source
Pipsgrowth_com_EX12004.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX12004 USDJPY Confluence — 5-factor AND-gate confluence EA, full 12-layer stack."

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

CTrade          g_trade;
CPositionInfo   g_pos;
CSymbolInfo     g_sym;
CAccountInfo    g_acc;

//=================== INPUTS (20 total) =============================
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_InpHTF = PERIOD_H1;
input group "=== Identity ==="
input long    InpMagic               = 22212004;  // Magic number
input string  InpTradeComment        = "Psgrowth.com Expert_12004"; // Trade comment

ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
   switch(tf)
   {
      case 1: return PERIOD_M1;
      case 2: return PERIOD_M5;
      case 3: return PERIOD_M15;

Full source code available on download

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

Tags:ex12004multiindicatorconfluencepipsgrowthfreemt5usdjpy

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_EX12004.mq5
File Size36.0 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyOther
Risk LevelMedium Risk
Timeframes
M5M30
Currency Pairs
USDJPY
Min. Deposit$100