P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX12061 MultiIndicatorConfluence

MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1

Pipsgrowth.com EX12061 G4_7 variant — Secure Momentum Pyramid with EMA+ADX, full 12-layer stack.

Overview

The Pipsgrowth EX12061 MultiIndicatorConfluence — labelled "Secure Momentum Pyramid" on its on-chart dashboard — is a trend-following accumulator built around a small but deliberate set of guards. The core signal is a single EMA cross direction combined with an ADX strength threshold, and the trade-management logic treats every entry as a member of a basket rather than as an independent ticket. There is no per-trade take-profit, no per-trade stop, and no martingale reload by default; the only lot that scales is the one a user explicitly enables by raising LotMultiplier above 1.0. The default value of 1.0 keeps every position size equal to InitialLot (0.01), which is the version most users should treat as the production configuration.

The decision tree starts in OnTick(). Three indicator handles — handle_ema_fast (EMA(20) on PRICE_CLOSE), handle_ema_slow (EMA(50) on PRICE_CLOSE), and handle_adx (ADX(14)) — are created in OnInit() with the standard iMA / iADX calls, and on every tick the EA copies the most recent three values from each buffer. The two comparisons that matter are fast_EMA vs slow_EMA (trend direction) and the main ADX line vs the input ADX_Threshold (default 22). When fast > slow and ADX > 22 the regime is "uptrend strong"; when fast < slow and ADX > 22 the regime is "downtrend strong"; in any other case the EA does not evaluate entries on that side. The naming matters: ADX > 22 is the gate that separates a real trend from a sideways EMA kiss, so this EA is intentionally quiet in ranges and will sit flat through most consolidations.

The first entry in a direction has its own rule. When the regime is bullish-strong and there are no open buys, the EA checks whether the current ask is within 200 points above or 100 points below the fast EMA (line 192). On XAUUSD with point = 0.01, that is a $2 zone above and a $1 zone below the EMA; on 5-digit FX it is 2 pips up and 1 pip down. The condition reads "ask <= currentFastEMA + 200pt AND ask >= currentFastEMA - 100pt" — a deliberately tight pullback band, not a breakout trigger. The mirror fires for sells on the bid. This is the strategy's most distinctive design choice: the first entry requires the price to come to the EMA, not chase a runaway move. A trend that never pulls back to the EMA will never get a first entry, which is a feature — it means the EA enters after the impulse has paused rather than at the top of a vertical spike.

Pyramiding is the second half of the strategy, and it is governed by two independent gates. The first is ArePositionsSecure(), which iterates PositionsTotal in reverse and verifies that every existing position in the trend direction has its stop-loss at or beyond the entry price (sl >= openPrice for buys, sl <= openPrice for sells, and sl != 0 for sells). If even one position in the stack is still at risk, ArePositionsSecure returns false and no pyramid add fires — that is the "secure" half of the strategy name. The second gate is the price-distance check: the current ask (or bid for sells) must be at least PyramidStepPoints (300 default, 30 pips on 5-digit / $3 on XAUUSD at 0.01 point) past GetLastOpenPrice() in the direction of the trend. Only when both gates pass does the EA calculate the next lot via CalculateLot() and call trade.Buy() / trade.Sell() with SL=0 and TP=0. The lot sizing helper is conservative: it uses InitialLot directly when LotMultiplier == 1.0 (the default), and only when the user explicitly raises the multiplier above 1.0 does it compute InitialLot × multiplier^existingCount. Even then, the result is floored to the symbol's volume step and clamped to the broker's min/max lot, so a misconfigured 1.5 multiplier cannot push a 0.01 micro-account into 0.05 or 0.10 lot territory by accident.

The position-management side is what converts the pyramid into a "secured" one. ManagePositions() runs every tick and walks the open positions in reverse-ticket order; for each ticket whose magic matches 22212061, it checks whether price has moved 50 points in profit and the current stop is still behind the entry. If both are true for a buy, TryModify_EX12061() is called with the new SL = openPrice; the mirror fires for sells. The modify call goes through a 3-attempt retry wrapper that sleeps 100ms on REQUOTE or TIMEOUT returns and gives up on any other error code — there is no aggressive re-quote handling beyond that, so a broker that returns INVALID_STOPS will simply leave the position unmodified. Once the stop is at break-even, the position is "secured" in the strategy's terminology and the ArePositionsSecure gate flips to true, which is what unlocks the next pyramid add.

Exits happen exclusively at the basket level. On every tick, before ManagePositions or CheckEntryLogic, the EA calls CalculateTotalProfit() which sums POSITION_PROFIT across every ticket with the matching magic. If the aggregate reaches BasketTakeProfit (default $10), CloseAll(POSITION_TYPE_BUY) and CloseAll(POSITION_TYPE_SELL) are called back-to-back, and the function returns early — no new entries will be evaluated on that tick. If the aggregate drops to -BasketStopLoss (default -$5, and only checked when BasketStopLoss > 0), the same double CloseAll fires. Because the basket is measured in account dollars rather than in pips, a 0.01-lot stack of two or three XAUUSD positions is enough to trip the $10 target on a $2-$3 per-lot move, and a 0.01-lot stack of two or three EURUSD positions will need a much larger move to clear the same threshold — the dollar framing means the EA is sensitive to instrument choice and lot sizing.

The CTrade wrapper is configured for fast fills: trade.SetDeviationInPoints(50) permits up to 5 pips of slippage on entry, and trade.SetTypeFilling(ORDER_FILLING_IOC) disables order queuing. The IOC choice is consistent with the basket philosophy — partial fills and pending orders would distort the basket profit math. On the visual side, the EA draws two right-side price tags ("DotFast" yellow, "DotSlow" dodger-blue) and a small 220×130 black-on-gold dashboard in the upper-right corner showing the net P/L, trend direction, ADX value with a strong/weak label, and the live buy/sell position counts. The dashboard updates every tick and recolors green/red based on the sign of totalProfit.

The practical shape of the strategy: a trader who wants the intended behavior leaves LotMultiplier at 1.0, BasketTakeProfit at $10, BasketStopLoss at $5, and EMA_Fast / EMA_Slow / ADX_Period / ADX_Threshold at 20/50/14/22. PyramidStepPoints at 300 gives 30-pip spacing between adds on 5-digit FX (3-pip spacing on a 0.0001-point gold feed). The EA will spend most of its time flat, take a first position when the EMA pullback hits, secure it after a 50-point move, and then stack one or two more positions on continued strength. The basket-TP or basket-SL will close the whole stack on the same tick. The biggest behavioral caveat is that BasketStopLoss is a hard floor: a -$5 drawdown on the basket will flatten everything immediately, so users testing on tight accounts should either raise the basket SL or expect to see a high frequency of basket-stop exits on choppy days where the ADX > 22 gate keeps flipping on and off.

Strategy Deep Dive

On every tick the EA pulls three bars of EMA(20), EMA(50), and ADX(14) buffers, then runs a single-pass decision tree: bullish regime = fast > slow and ADX > 22, bearish regime = fast < slow and ADX > 22, no entries otherwise. The first position in a direction triggers only when ask/bid sits within ±200/-100 points of the fast EMA — a pullback-to-EMA entry, not a breakout. Subsequent positions use the ArePositionsSecure gate (every prior position in that direction must have SL ≥ openPrice) and the price-distance gate (≥ 300 points beyond the last fill), and those two conditions together produce a secured pyramid, not a martingale reload. ManagePositions() walks PositionsTotal in reverse and shifts the stop to openPrice once profit exceeds 50 points, which is the only on-trade modification. The basket checks run before management and entry logic on every tick, so a $10 profit or -$5 loss terminates the whole book immediately via CloseAll on both sides.

Entry Signal

EMA(20)/EMA(50) cross direction combined with ADX(14) > 22 forms the regime gate: long entries open when the regime is bullish-strong and price sits within 200 points above / 100 points below the fast EMA (a pullback-to-EMA entry, not a breakout). After the first position, additional entries pyramid only when ArePositionsSecure() returns true (every existing position in that direction has SL at or past break-even) AND price has moved at least PyramidStepPoints (300 default) further in the trend's favor. The result is a stepped accumulation that adds on confirmed continuation, not on loss-recovery.

Exit Signal

Exits are basket-driven, not per-trade. When CalculateTotalProfit (summed across every open position with magic 22212061) reaches +BasketTakeProfit ($10 default) the EA calls CloseAll on both sides and prints a basket-TP message; if the aggregate drops to -BasketStopLoss (-$5 default, only checked when BasketStopLoss > 0) the same double-CloseAll fires with a basket-SL log. There is no per-position TP — the only way a single trade closes is by hitting its break-even stop (after ManagePositions ratchets SL to openPrice) or by participating in the basket trip.

Stop Loss

No per-trade stop is attached at entry — both SL and TP are passed as 0 to trade.Buy / trade.Sell. ManagePositions() ratchets the stop to openPrice once price has moved 50 points in profit, which is what flips ArePositionsSecure() to true and unlocks the next pyramid add. The real risk ceiling is the basket stop: -BasketStopLoss (default -$5 across all EA positions) force-closes both sides on the same tick if hit.

Take Profit

No per-trade TP — entries are sent with TP=0 and there is no TP value computed anywhere in the source. Profit-taking happens exclusively at the basket level: when the combined P/L of every open position crosses +BasketTakeProfit ($10 default) the EA calls CloseAll on both sides. Because pyramids add at PyramidStepPoints (300 default) intervals, the basket TP is effectively the de-facto target for the entire ladder.

Best For

Built for XAUUSD on the M5 or H1 chart with a recommended balance of $100, and the source is portable across other FX majors and metals. Because the basket is dollar-based ($10 TP / $5 SL by default), a low-spread ECN or RAW account is the right execution venue — wide-spread offshore books will routinely eat the basket with slippage before the TP fires, and the IOC fill mode requires an account that supports immediate-or-cancel execution. Use only on instruments where you can stomach 0.01-lot micro-trades; LotMultiplier defaults to 1.0 so every pyramid level is the same size as the initial entry, and PyramidStepPoints (300) is sized for 5-digit FX or XAUUSD at 0.01 point.

Strategy Logic

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

Family: MultiIndicatorConfluence Magic: 22212061 Version: 2.00

BRIEF: Secure Momentum Pyramid variant using EMA crossover with ADX strength filter. Pyramids into trends with step-based entries, basket TP/SL management, and position securing. Martingale lot multiplier disabled by default (set to 1.0). 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • CalculateLot()
  • CalculateTotalProfit()
  • CountPositions()
  • GetLastOpenPrice()
  • ArePositionsSecure()
  • CloseAll()
  • ManagePositions()
  • CheckEntryLogic()
  • UpdateDashboard()
  • CreateDashboard()
  • DrawTrendLines()
  • TryClose_EX12061()
  • ...and 2 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (12 total across 4 groups):

  • [=== Risk Management ===] InitialLot = 0.01 // Starting Lot Size
  • [=== Risk Management ===] LotMultiplier = 1.0 // Lot Multiplier (1.0 = fixed lot, >1.0 = martingale)
  • [=== Risk Management ===] BasketTakeProfit = 10.0 // Target Profit to Close All ($)
  • [=== Risk Management ===] BasketStopLoss = 5.0 // Emergency Stop Loss ($)
  • [=== Strategy Settings ===] EMA_Fast = 20 // Fast EMA
  • [=== Strategy Settings ===] EMA_Slow = 50 // Slow EMA
  • [=== Strategy Settings ===] ADX_Period = 14 // ADX Period
  • [=== Strategy Settings ===] ADX_Threshold = 22 // ADX Strength
  • [=== Strategy Settings ===] PyramidStepPoints = 300 // Points to move before adding position
  • [=== Identity ===] MagicNumber = 22212061 // Magic number
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_12061" // Trade comment
  • [=== Visuals ===] ShowDashboard = true // --- Global Variables ---
Pseudocode
// Pipsgrowth EX12061 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// Secure Momentum Pyramid variant using EMA crossover with ADX strength filter. Pyramids into trends with step-based entries, basket TP/SL management, and position securing. Martingale lot multiplier disabled by default (set to 1.0). 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:
M5H1

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
InitialLot0.01Starting Lot Size
LotMultiplier1.0Lot Multiplier (1.0 = fixed lot, >1.0 = martingale)
BasketTakeProfit10.0Target Profit to Close All ($)
BasketStopLoss5.0Emergency Stop Loss ($)
EMA_Fast20Fast EMA
EMA_Slow50Slow EMA
ADX_Period14ADX Period
ADX_Threshold22ADX Strength
PyramidStepPoints300Points to move before adding position
MagicNumber22212061Magic number
InpTradeComment"Psgrowth.com Expert_12061"Trade comment
ShowDashboardtrue--- Global Variables ---
Source Code (.mq5)Open Source
Pipsgrowth_com_EX12061.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX12061 G4_7 variant — Secure Momentum Pyramid with EMA+ADX, full 12-layer stack."

#include <Trade\Trade.mqh>

//--- Input Parameters ---
input group "=== Risk Management ==="
input double   InitialLot        = 0.01;      // Starting Lot Size
input double   LotMultiplier     = 1.0;       // Lot Multiplier (1.0 = fixed lot, >1.0 = martingale)
input double   BasketTakeProfit  = 10.0;      // Target Profit to Close All ($)
input double   BasketStopLoss    = 5.0;       // Emergency Stop Loss ($)

input group "=== Strategy Settings ==="
input int      EMA_Fast          = 20;        // Fast EMA
input int      EMA_Slow          = 50;        // Slow EMA
input int      ADX_Period        = 14;        // ADX Period
input int      ADX_Threshold     = 22;        // ADX Strength
input int      PyramidStepPoints = 300;      // Points to move before adding position

input group "=== Identity ==="
input int      MagicNumber       = 22212061;  // Magic number
input string   InpTradeComment   = "Psgrowth.com Expert_12061"; // Trade comment

input group "=== Visuals ==="
input color   BullishColor       = clrLime;
input color   BearishColor       = clrRed;
input bool    ShowDashboard      = true;

//--- Global Variables ---
CTrade trade;
int handle_ema_fast;
int handle_ema_slow;
int handle_adx;
double EMA_Fast_Buffer[];
double EMA_Slow_Buffer[];
double ADX_Buffer[];

//+------------------------------------------------------------------+
//| Helper Functions (Declared First to fix errors)                   |
//+------------------------------------------------------------------+
double CalculateLot(int existingCount);
double CalculateTotalProfit();
int CountPositions(ENUM_POSITION_TYPE type);
double GetLastOpenPrice(ENUM_POSITION_TYPE type);
bool ArePositionsSecure(ENUM_POSITION_TYPE type);
void CloseAll(ENUM_POSITION_TYPE type);
void ManagePositions();
void CheckEntryLogic(double currentTotalProfit);
void UpdateDashboard(double profit, double adx, double emaF, double emaS);
void CreateDashboard();
void DrawTrendLines();

//+------------------------------------------------------------------+
//| Expert initialization function                                     |
//+------------------------------------------------------------------+
int OnInit()
{

Full source code available on download

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

Tags:ex12061multiindicatorconfluencepipsgrowthfreemt5xauusd

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_EX12061.mq5
File Size18.2 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyOther
Risk LevelMedium Risk
Timeframes
M5H1
Currency Pairs
XAUUSD
Min. Deposit$100