P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX12012 MultiIndicatorConfluence

MT5 Expert Advisor (Open Source) · XAUUSD · M5

Pipsgrowth.com EX12012 AFAOSMD_XAUUSD_5M — Average Force + Andean Osc + MACD confluence, full 12-layer stack.

Overview

Average Force zero-cross, Andean Oscillator envelope, and MACD direction all need to align before this EA will fire a single trade on XAUUSD M5. The architecture is a four-clause confirmation system: nothing is placed unless every leg agrees.

The Average Force component is a smoothed Force Index computed inside GetSignal() as a simple moving average of iForce(). The default reads InpForcePeriod=20 bars of raw force, then averages the last InpForceSmooth=9 readings to produce AF(1) and AF(2). The function does not use the InpForceMethod input for the smoothing — that parameter is declared but unused in the current build, and the SMA path is what actually runs. The signal only cares whether AF crossed zero on the latest bar: AF(2) below zero and AF(1) above zero is the bull trigger, the opposite is the bear trigger.

The Andean Oscillator is built from scratch in CalculateAndeanOscillator(). With InpAndeanPeriod=50 the function walks back 3×50 = 150 bars from the requested shift, seeds the bull envelope with the close at that seed point, then iterates forward applying alpha = 2 / (period + 1) = 2/51 ≈ 0.0392. On each step the bull leg uses MathMax(close, open) — a proxy for bullish bar extension — and the bear leg uses MathMin(close, open). When the new value exceeds the current envelope, the envelope jumps to the new high; otherwise it decays exponentially toward the new low. The output is two envelope series whose relationship (bull > bear or bear > bull) defines the oscillator's directional bias.

The third leg is a standard iMACD(12, 26, 9) main line. The header brief lists Stochastic as a fourth confirmation, but the code never instantiates iStochastic. The actual fourth clause is the slope of the MACD main line itself. For a long, both md_main_1 and md_main_2 must be positive AND md_main_1 must be greater than md_main_2 — i.e. the MACD is rising while above zero. Sell is the mirror: both values negative and the more recent value lower than the older one.

Combining the four clauses in GetSignal() produces a buy iff: AOS_bull > AOS_bear on shift 1, AF(2)<0 AND AF(1)>0, MD(2)>0 AND MD(1)>0, AND MD(2)<MD(1). Sell is the strict negation across all four. The signal is then handed to OnTick(), which calls CheckPyramidSafety() before any CTrade.Buy/CTrade.Sell fires. InpReverseSignal=false by default; flipping it to true swaps the buy and sell branches, which can be useful when gold's regime is mean-reverting rather than trending.

Trade management is split across three independent modules. Lot sizing in GetLotSize() defaults to 1% of account balance (InpRiskPercent=1.0) per trade, computed as risk_money / (sl_points × tick_value_per_point), then snapped to the broker's lot step and capped at InpMaxLotSize=10 lots. Setting InpRiskPercent=0 falls back to InpFixedLot=0.01 — also the broker minimum that takes over when risk-based sizing underflows.

Stop loss and take profit are fixed-point inputs rather than ATR-derived despite what the file header implies: InpStopLoss=500 points and InpTakeProfit=1000 points, giving a hard 1:2 risk-to-reward geometry. Slippage is capped at InpSlippage=30 points via m_trade.SetDeviationInPoints().

The safe-pyramid module, CheckPyramidSafety(), is the most distinctive design choice. With InpUsePyramid=true the EA permits up to InpMaxPyramidTrades=3 simultaneous positions on the same symbol, all sharing magic 22212012. Three preconditions gate every additional entry: (a) all existing positions must be in the same direction as the new signal — opposing-direction exposure is rejected outright, which means the EA cannot be net long and net short at the same time; (b) each existing position must have a stop loss set on the trade server; (c) the distance from entry to stop must be at least InpPyramidMinProfit=100 points. That last rule is the safety hinge — the EA will not pyramid into a position whose stop is below the entry. New entries must also be at least InpPyramidMinDist=200 points from the most recent entry price. With InpUsePyramid=false the EA collapses to a strict one-position-at-a-time mode.

Profit protection runs in ManageProfitLock(). When InpUseProfitLock=true and a position has gained at least InpLockTrigger=300 points, the EA moves the stop to InpLockDistance=100 points behind the current bid/ask — but only when the implied movement exceeds InpLockStep=50 points. The effect is a step-ratchet: tiny fluctuations under 50 points do not trigger constant modifications, but once the lock has stepped up, it never steps back down. This is a simpler design than a swing-based or ATR-based trail; the developer is trading smoothness-of-modification for a hard floor on locking.

The time filter (IsTradingTime()) defaults to InpStartTime="08:00" and InpEndTime="20:00" server time, with InpUseTimeFilter=true. Outside this window the EA updates the dashboard with "Market Closed" and does not place new orders. InpCloseAtEnd=false by default, so existing trades are allowed to run past 20:00 unless the user flips it. The clock comparison supports overnight windows by branching when start > end.

Order execution uses the standard CTrade wrapper with SetTypeFilling(ORDER_FILLING_FOK), magic 22212012, and 30-point slip deviation. Close and modify operations go through TryClose_EX12012() and TryModify_EX12012() retry helpers — three attempts with 200ms sleep on REQUOTE/TIMEOUT/PRICE_OFF/PRICE_CHANGED for close, and 100ms sleep on REQUOTE/TIMEOUT only for modify. PRICE_CHANGED is not retried in modify — an asymmetric design. New-candle gating in OnTick() uses a static last_bar timestamp so signals are evaluated exactly once per M5 bar open, not on every tick.

What this EA does NOT do is as important as what it does. There is no news filter, no daily-loss cap, no equity-percent-of-balance guard, no consecutive-loss cooldown, no max-trades-per-day limit, no weekly loss cap, no regime classifier, no ATR minimum filter, no ADX filter, no volume spike detector, no higher-timeframe trend confirmation, and no dry-run flag. The signal is the only source of edge; the safety stack is purely trade-management hygiene. OnTester is not defined, so backtest fitness is the platform default.

In practice, what traders observe is an EA that takes relatively few but tightly-conditioned trades on XAUUSD M5 during the European and US active trading hours. When gold trends, the four-clause combination tends to catch the second or third push of a directional move, and the 1:2 R:R plus step-trail handles the post-entry management. When gold chops, the filter rejects most setups and trade count drops sharply. The safe-pyramid module means trends can scale exposure up to 3 lots, but only when each layer is at least 100 points secured — the EA will not add to a losing position just because price moved 200 points against it.

The most common configuration issue users hit is the slippage cap: 30 points is too tight during high-volatility XAUUSD moments (NFP, FOMC, the London and Geneva gold fixes), and a 500-point SL with 30-point slip tolerance can fill hundreds of points away from the requested price in fast markets. For brokers with wider spreads or higher rejection rates, lifting InpSlippage to 50 or 80 is reasonable. The InpAndeanPeriod default of 50 is also worth examining — pushing it to 30 tightens the envelope and produces more signals, while pushing it to 80 widens it and produces fewer but more durable signals. InpForceSmooth at 9 with InpForcePeriod at 20 is a balance point; lowering the smooth to 5 makes the AF zero-cross noisier, raising it to 14 delays entries by one or two bars.

Strategy Deep Dive

On each M5 bar close, OnTick() pulls a 20-bar window of iForce() values and computes a 9-period simple average for the AF(1) and AF(2) values used in the zero-cross check. In parallel, CalculateAndeanOscillator() walks back 3×InpAndeanPeriod=150 bars from shift 1, seeds the bull envelope with the close, then iterates with alpha=2/51 decay applied to MathMax(close, open) — a value that jumps up on bullish bars and decays toward the new low otherwise. The bear envelope mirrors this with MathMin(close, open). Standard iMACD(12,26,9) supplies the third leg. GetSignal() requires all four clauses to align before returning 1 or -1, and any non-zero signal is then gated by CheckPyramidSafety() before GetLotSize() computes the risk-based lot and CTrade fires Buy or Sell with ORDER_FILLING_FOK. ManageProfitLock() runs first on every tick to handle the step-ratchet on existing positions.

Entry Signal

Long entries fire when (1) the Andean Oscillator's bull component exceeds its bear component on the just-closed bar, (2) the smoothed Force Index crosses up through zero — AF(2)<0 and AF(1)>0, (3) the MACD main line is positive on both the previous and current bar, and (4) the MACD main line is rising while positive (MD(1) > MD(2)). Sell entries mirror all four clauses. The full signal is only evaluated once per M5 bar open via the static last_bar gate in OnTick(), and InpReverseSignal can swap the buy and sell branches when gold is in a fade-friendly regime.

Exit Signal

Positions are exited either by hitting the fixed 1000-point InpTakeProfit target or the fixed 500-point InpStopLoss. The ManageProfitLock() function ratchets the stop forward in 50-point steps once a position is 300 points in profit, anchoring the new stop 100 points behind the current bid/ask — a one-way ratchet that never loosens. InpCloseAtEnd=false by default means positions can run past 20:00; setting it to true force-closes all positions at InpEndTime. The four-clause signal also acts as a soft exit trigger: when a new candle flips the logic, CheckPyramidSafety() rejects any new entry in the new direction until the existing position is closed.

Stop Loss

Stop loss is a fixed 500 points (InpStopLoss=500), attached to the entry at order open. The profit-lock ratchet can step the stop higher by 50 points once the position is 300 points in profit, but it never moves the stop lower. Pyramid safety requires every existing position's stop to be at least 100 points (InpPyramidMinProfit) in secured profit before any additional entry is added.

Take Profit

Take profit is a fixed 1000 points (InpTakeProfit=1000), giving a strict 1:2 risk-to-reward ratio against the 500-point stop. There is no partial close, no scaled TP, and no trailing exit — the TP is the only way a position is taken off at a target, while the profit-lock ratchet handles capital protection on the way to that target.

Best For

Suited for XAUUSD M5 with a $100 minimum recommended balance, MEDIUM risk classification, 1% balance risk per trade and a 10-lot ceiling. The 08:00-20:00 server-time window targets European and US active hours, so the EA expects a broker whose server clock is GMT+2 or GMT+3 (most MetaTrader brokers). A low-spread ECN or RAW account is required because the four-clause filter fires on small M5 windows and the 500/1000-point geometry can be eroded by spread widening. The EA is not a fit for market-execution brokers with frequent requotes on gold; choose one with a typical XAUUSD spread of 20-30 points or better and clean FOK fills.

Strategy Logic

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

Family: MultiIndicatorConfluence Magic: 22212012 Version: 2.00

BRIEF: Average Force, Andean Oscillator, MACD and Stochastic confluence EA. Force Index zero-cross confirmed by Andean Oscillator bull/bear signals and MACD histogram direction. ATR-based SL/TP, safe pyramiding, profit-lock trailing, time filter and risk-based lot sizing. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • GetSignal()
  • CalculateAndeanOscillator()
  • CalculateEMA()
  • CheckPyramidSafety()
  • ManageProfitLock()
  • GetLotSize()
  • RefreshRates()
  • IsTradingTime()
  • StrToTimeStruct()
  • CloseAllPositions()
  • UpdateDashboard()
  • TryClose_EX12012()
  • ...and 2 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (30 total across 7 groups):

  • [=== Signal Settings ===] InpForcePeriod = 20 // Average Force Period
  • [=== Signal Settings ===] InpForceSmooth = 9 // Average Force Smooth Length
  • [=== Signal Settings ===] InpForceMethod = MODE_EMA // Average Force Smooth Method
  • [=== Signal Settings ===] InpAndeanPeriod = 50 // Andean Oscillator Period
  • [=== Signal Settings ===] InpAndeanSignal = 9 // Andean Signal Period (if used)
  • [=== Signal Settings ===] InpMACDFast = 12 // MACD Fast EMA
  • [=== Signal Settings ===] InpMACDSlow = 26 // MACD Slow EMA
  • [=== Signal Settings ===] InpMACDSignal = 9 // MACD Signal
  • [=== Signal Settings ===] InpReverseSignal = false // Reverse Strategy Logic
  • [=== Money Management ===] InpRiskPercent = 1.0 // Risk per trade (% of Balance)
  • [=== Money Management ===] InpFixedLot = 0.01 // Fixed Lot (if Risk=0)
  • [=== Money Management ===] InpMaxLotSize = 10.0 // Max Lot Size per trade
  • [=== Trade Management ===] InpStopLoss = 500 // Stop Loss (Points)
  • [=== Trade Management ===] InpTakeProfit = 1000 // Take Profit (Points)
  • [=== Trade Management ===] InpSlippage = 30 // Max Slippage (Points)
  • [=== Trade Management ===] InpMagicNumber = 22212012 // Magic Number
  • [=== Trade Management ===] InpTradeComment = "Psgrowth.com Expert_12012" // Trade Comment
  • [=== Pyramid / Scaling ===] InpUsePyramid = true // Enable Safe Pyramiding
  • [=== Pyramid / Scaling ===] InpMaxPyramidTrades = 3 // Max Open Positions (Pyramid)
  • [=== Pyramid / Scaling ===] InpPyramidMinDist = 200 // Min Distance for next entry (Points)
  • [=== Pyramid / Scaling ===] InpPyramidMinProfit = 100 // Min Secured Profit per trade to add new
  • [=== Profit Lock & Trail ===] InpUseProfitLock = true // Enable Profit Lock / Trailing
  • [=== Profit Lock & Trail ===] InpLockTrigger = 300 // Trigger Distance (Points in Profit)
  • [=== Profit Lock & Trail ===] InpLockStep = 50 // Step to advance SL (Points)
  • [=== Profit Lock & Trail ===] InpLockDistance = 100 // Distance to keep SL from Price (Points)
  • [=== Time Management ===] InpUseTimeFilter = true // Enable Time Filter
  • [=== Time Management ===] InpStartTime = "08:00" // Start Trading Time (Server)
  • [=== Time Management ===] InpEndTime = "20:00" // End Trading Time (Server)
  • [=== Time Management ===] InpCloseAtEnd = false // Close all at end time
  • [=== Optimization & System ===] InpDebugMode = false // Print Debug Logs
Pseudocode
// Pipsgrowth EX12012 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// Average Force, Andean Oscillator, MACD and Stochastic confluence EA. Force Index zero-cross confirmed by Andean Oscillator bull/bear signals and MACD histogram direction. ATR-based SL/TP, safe pyramiding, profit-lock trailing, time filter and risk-based lot sizing. 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:
M5

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
InpForcePeriod20Average Force Period
InpForceSmooth9Average Force Smooth Length
InpForceMethodMODE_EMAAverage Force Smooth Method
InpAndeanPeriod50Andean Oscillator Period
InpAndeanSignal9Andean Signal Period (if used)
InpMACDFast12MACD Fast EMA
InpMACDSlow26MACD Slow EMA
InpMACDSignal9MACD Signal
InpReverseSignalfalseReverse Strategy Logic
InpRiskPercent1.0Risk per trade (% of Balance)
InpFixedLot0.01Fixed Lot (if Risk=0)
InpMaxLotSize10.0Max Lot Size per trade
InpStopLoss500Stop Loss (Points)
InpTakeProfit1000Take Profit (Points)
InpSlippage30Max Slippage (Points)
InpMagicNumber22212012Magic Number
InpTradeComment"Psgrowth.com Expert_12012"Trade Comment
InpUsePyramidtrueEnable Safe Pyramiding
InpMaxPyramidTrades3Max Open Positions (Pyramid)
InpPyramidMinDist200Min Distance for next entry (Points)
InpPyramidMinProfit100Min Secured Profit per trade to add new
InpUseProfitLocktrueEnable Profit Lock / Trailing
InpLockTrigger300Trigger Distance (Points in Profit)
InpLockStep50Step to advance SL (Points)
InpLockDistance100Distance to keep SL from Price (Points)
InpUseTimeFiltertrueEnable Time Filter
InpStartTime"08:00"Start Trading Time (Server)
InpEndTime"20:00"End Trading Time (Server)
InpCloseAtEndfalseClose all at end time
InpDebugModefalsePrint Debug Logs
Source Code (.mq5)Open Source
Pipsgrowth_com_EX12012.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX12012 AFAOSMD_XAUUSD_5M — Average Force + Andean Osc + MACD confluence, full 12-layer stack."

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

// --- Global Objects ---
CTrade         m_trade;
CSymbolInfo    m_symbol;
CPositionInfo  m_position;
CAccountInfo   m_account;

// --- Inputs ---

input group "=== Signal Settings ==="
input int      InpForcePeriod       = 20;          // Average Force Period
input int      InpForceSmooth       = 9;           // Average Force Smooth Length
input ENUM_MA_METHOD InpForceMethod = MODE_EMA;    // Average Force Smooth Method
input int      InpAndeanPeriod      = 50;          // Andean Oscillator Period
input int      InpAndeanSignal      = 9;           // Andean Signal Period (if used)
input int      InpMACDFast          = 12;          // MACD Fast EMA
input int      InpMACDSlow          = 26;          // MACD Slow EMA
input int      InpMACDSignal        = 9;           // MACD Signal
input bool     InpReverseSignal     = false;       // Reverse Strategy Logic

input group "=== Money Management ==="
input double   InpRiskPercent       = 1.0;         // Risk per trade (% of Balance)
input double   InpFixedLot          = 0.01;        // Fixed Lot (if Risk=0)
input double   InpMaxLotSize        = 10.0;        // Max Lot Size per trade

input group "=== Trade Management ==="
input int      InpStopLoss          = 500;         // Stop Loss (Points)
input int      InpTakeProfit        = 1000;        // Take Profit (Points)
input int      InpSlippage          = 30;          // Max Slippage (Points)
input ulong    InpMagicNumber       = 22212012;    // Magic Number
input string   InpTradeComment      = "Psgrowth.com Expert_12012"; // Trade Comment

input group "=== Pyramid / Scaling ==="
input bool     InpUsePyramid        = true;        // Enable Safe Pyramiding
input int      InpMaxPyramidTrades  = 3;           // Max Open Positions (Pyramid)
input int      InpPyramidMinDist    = 200;         // Min Distance for next entry (Points)
input int      InpPyramidMinProfit  = 100;         // Min Secured Profit per trade to add new

input group "=== Profit Lock & Trail ==="
input bool     InpUseProfitLock     = true;        // Enable Profit Lock / Trailing
input int      InpLockTrigger       = 300;         // Trigger Distance (Points in Profit)
input int      InpLockStep          = 50;          // Step to advance SL (Points)
input int      InpLockDistance      = 100;         // Distance to keep SL from Price (Points)

input group "=== Time Management ==="
input bool     InpUseTimeFilter     = true;        // Enable Time Filter
input string   InpStartTime         = "08:00";     // Start Trading Time (Server)
input string   InpEndTime           = "20:00";     // End Trading Time (Server)
input bool     InpCloseAtEnd        = false;       // Close all at end time

Full source code available on download

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

Tags:ex12012multiindicatorconfluencepipsgrowthfreemt5xauusd

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_EX12012.mq5
File Size23.3 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyOther
Risk LevelMedium Risk
Timeframes
M5
Currency Pairs
XAUUSD
Min. Deposit$100