P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX12017 MultiIndicatorConfluence

MT5 Expert Advisor (Open Source) · XAUUSD · M5

Pipsgrowth.com EX12017 AMLI_XAUUSD_5M — Adaptive Market Liquidity Index EA for XAUUSD, full 12-layer stack.

Overview

Pipsgrowth EX12017 reads market microstructure through a single composite index it constructs on the fly — the Adaptive Market Liquidity Index, or AMLI. The indicator does not live in a chart subwindow; it is computed in the EA's own CalculateAMLI() function by combining a smoothed tick-volume ratio with an ATR ratio into a 0-100 oscillator. The reading sits at 50.0 (neutral) by default, drifts above 50 when both volume and volatility expand in lockstep, and falls below 50 when the market thins out. That sub-50 zone is the liquidity trap the EA is designed to trade: when order flow dries up and price stops moving meaningfully, AMLI collapses, and a subsequent burst of activity is the breakout the EA wants to capture.

The trap logic is event-driven, not bar-driven. OnTick() first refreshes the symbol and rejects any tick where the spread has blown out past the InpMaxSpread input (200 points on XAUUSD M5, i.e. a 20-pip tolerance — loose enough to survive most intraday widening but tight enough to filter illiquid prints). It then runs ManageProfitLock() against the open position list before the new-bar check, so the trailing engine is always one tick ahead of the signal engine. Once a new M5 bar opens, the EA pulls AMLI from the current closed bar (shift 1) and the bar before that (shift 2). The trap state is the boolean (amli_curr < InpLiquidityTrap), and the EA tracks a counter g_trap_duration that increments only while AMLI stays sub-trap. The signal fires on the transition: when the previous bar was in the trap and the current bar is not — provided the trap lasted at least two bars (g_trap_duration >= 2) and the absolute change in AMLI exceeds the InpMinAMLIChange floor (3.0 index points). When the trap-breakout gate is missed, a second path is left open: a strong-momentum entry is allowed whenever |amli_change| >= InpMinAMLIChange * 1.5, regardless of trap state. The direction follows the sign of the AMLI delta — positive change is a buy, negative change is a sell.

Position management is where EX12017 quietly diverges from a vanilla breakout EA. It does not pyramid by adding to a position on a new signal at the same level; it only adds when the existing position has already banked secured profit. CheckPyramidSafety() walks the open list and computes secured = (sl - open) / _Point for buys (and the mirror for sells). If that secured distance is below InpPyramidMinProfit (100 points, 10 pips), the new entry is rejected. This means the second and third pyramid adds (the InpMaxPyramidTrades cap is 3) only happen after the trailing stop has been pulled above entry — the EA is forced to be patient. Adding against the open direction (a buy signal while a sell is live, or vice versa) is also blocked at the safety layer, so the EA cannot net itself into a hedged mess when the trap-breakout direction flips on consecutive bars. The total open-position ceiling is 3, which keeps the EA from compounding into a runaway basket when the trap re-arms.

The trailing engine is a step-ratchet, not a continuous curve. ManageProfitLock() only acts once the trade is at least InpLockTrigger (300 points, 30 pips) into profit, and even then it only moves the stop if the new target beats the current stop by at least InpLockStep (50 points, 5 pips). The new stop is set at current price minus InpLockDistance (100 points, 10 pips), which means once a long trade is past the 30-pip trigger, the SL follows price in 5-pip increments with a 10-pip cushion. That cushion is the trade's max drawdown from current price during the trail — it never widens. The original fixed SL (500 points) and TP (750 points) remain on the position; the lock is an overlay, not a replacement. TryModify_EX12017 wraps the modify in a 3-retry loop with 100ms backoff on TRADE_RETCODE_REQUOTE and TRADE_RETCODE_TIMEOUT, and TryClose_EX12017 / TryClosePartial_EX12017 do the same for closes with 200ms backoff on the broader requote/timeout/price-off/price-changed set.

Risk and money management follow a clean separation. GetLotSize() sizes from balance when InpRiskPercent is positive (1.0% of account balance by default), with the per-point value computed against InpStopLoss so that a wider stop produces a smaller lot — the standard risk-normalized sizing math. When InpRiskPercent is set to zero, the EA falls back to InpFixedLot (0.01) and a hard cap at InpMaxLotSize (10.0 lots per trade). The stop distance is InpStopLoss = 500 points (50 pips on 5-digit XAUUSD), the take is InpTakeProfit = 750 points (75 pips), giving a 1:1.5 risk:reward on the fixed branch. The EA is wired to m_trade.SetTypeFilling(ORDER_FILLING_FOK) and SetDeviationInPoints(InpSlippage=30), and the InpMagicNumber defaults to 22212017 so multiple instances on the same account can be partitioned cleanly.

The time filter is plain-vanilla but worth noting. IsTradingTime() parses InpStartTime ("08:00") and InpEndTime ("20:00") into minutes and gates the new-bar branch on that window. Outside the window, the EA neither opens new trades nor modifies existing ones (ManageProfitLock still runs because it sits above the time gate), unless InpCloseAtEnd is true — in which case CloseAllPositions() is invoked to flatten the book. The 08:00-20:00 server window covers the full London session and the first two-thirds of the New York session, which is where XAUUSD spot volume and the trap-vs-breakout behavior the AMLI is measuring actually occur. The fill mode is FOK, so any trade that cannot be filled at the requested price is rejected outright rather than partially filled.

What to expect in a backtest versus live. Because AMLI is a derived indicator (volume ratio + ATR ratio normalized to 0-100), the EA's behavior is highly regime-dependent: in trending gold years (2020, 2024) the strong-momentum branch produces a steady stream of entries; in range-bound years (2022 Q3) the trap-breakout branch fires less often and most signals come from the relaxed 1.5x threshold. The 500/750 fixed point SL/TP pair means the EA does not breathe with volatility — on a 2x ATR day, the 50-pip stop is tighter than ideal, and on a 0.5x ATR day it is generous. The pyramid cap of 3 is conservative; aggressive users will want to stress-test InpMaxPyramidTrades up to 5 only after they have seen the secured-profit gate work the way they expect. A live deployment should run with InpRiskPercent = 0.5 (not the default 1.0) for the first two weeks, sized to the worst-case 3-position basket at 3% of balance per slot, and InpUsePyramid should be flipped to false for the first week of paper trading to isolate the single-entry branch.

Strategy Deep Dive

On every M5 tick the EA first refuses to act when the XAUUSD spread exceeds 200 points, then runs ManageProfitLock() against the open list before the new-bar gate. On each new bar it computes AMLI from the prior two closed bars in CalculateAMLI() — a 0-100 index built from a 14-bar volume ratio times a 20-bar ATR ratio, normalized around 50. A signal fires on one of two paths: a trap-breakout where AMLI crosses above 35 after a 2+ bar sub-trap dwell with delta ≥ 3, or a momentum path with delta ≥ 4.5. CheckPyramidSafety() then vetoes the entry if the new signal fights the open direction or if every existing position has not yet pulled its SL into ≥ 100 points of secured profit, and the position is capped at 3 concurrent. Risk is sized at 1% of balance against the 500-point stop (or InpFixedLot when risk is zero), the 750-point TP is attached at entry, and the FOK fill mode rejects any unfillable order outright. ProfitLock walks the SL behind price in 50-point ratchets with a 100-point cushion once profit clears 300 points, and the 08:00-20:00 server-time gate forces the EA idle overnight.

Entry Signal

Triggers a long when AMLI (50 × (vol_ratio + atr_ratio), clamped 0-100) crosses back above InpLiquidityTrap (35) after a 2+ bar sub-trap stretch with |ΔAMLI| ≥ 3.0, or on any bar where |ΔAMLI| ≥ 4.5 (1.5× the floor) regardless of trap state. The sign of the AMLI delta sets the direction. Pyramiding adds only when the existing position's secured profit (SL vs entry in points) ≥ InpPyramidMinProfit (100 pts), capped at 3 simultaneous positions on XAUUSD M5.

Exit Signal

Positions exit on the original fixed TP of 750 points (75 pips on 5-digit XAUUSD), or via the profit-lock overlay once the trade is ≥ 300 points in profit and the trailing stop is hit. Outside the configured time window with InpCloseAtEnd enabled, CloseAllPositions() force-flattens the book. There is no signal-flip exit — the EA treats the pyramid as a one-direction stack, not a hedged swing book.

Stop Loss

Fixed 500 points (50 pips on 5-digit XAUUSD) set at entry by m_trade.Buy()/Sell(), then progressively tightened by the profit-lock ratchet once profit exceeds 300 points. Per-trade risk is 1% of balance by default, normalized to the 500-point stop so a wider InpStopLoss would naturally shrink the lot size.

Take Profit

Fixed 750 points (75 pips on 5-digit XAUUSD) attached at entry — 1:1.5 risk-to-reward against the 500-point stop. TP is not trailed; the profit-lock modifies the SL only, leaving the original TP in place until either the TP or the locked stop is hit.

Best For

Built for XAUUSD on M5 with a recommended starting balance of $100. The fixed 500/750 point SL/TP pair and 1% risk-per-trade default make it a clean fit for traders who want explicit, predictable risk per entry rather than ATR-adaptive sizing. The 200-point spread cap (20 pips) tolerates a wider spread than a raw-spread scalper would, but a low-spread ECN broker is still required to keep the 500-point stop realistic. Best run during the 08:00-20:00 server window — the London session and the first two-thirds of New York — where XAUUSD liquidity produces the volume-volatility regime the AMLI is measuring.

Strategy Logic

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

Family: MultiIndicatorConfluence Magic: 22212017 Version: 2.00

BRIEF: This EA implements internal AMLI (Adaptive Market Liquidity Index) logic using Volume and ATR-based volatility analysis. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • CalculateAMLI()
  • CheckPyramidSafety()
  • ManageProfitLock()
  • GetLotSize()
  • RefreshRates()
  • IsTradingTime()
  • StrToTime()
  • CloseAllPositions()
  • TryClose_EX12017()
  • TryClosePartial_EX12017()
  • TryModify_EX12017()

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (24 total across 6 groups):

  • [=== AMLI Indicator Parameters ===] InpVolumePeriod = 14 // Volume Smoothing Period
  • [=== AMLI Indicator Parameters ===] InpVolatilityPeriod = 20 // Volatility (ATR) Period
  • [=== AMLI Indicator Parameters ===] InpLiquidityTrap = 35.0 // Liquidity Trap Level (0-100)
  • [=== AMLI Indicator Parameters ===] InpMinAMLIChange = 3.0 // Minimum AMLI Change for Signal
  • [=== 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 = 750 // Take Profit (Points)
  • [=== Trade Management ===] InpSlippage = 30 // Max Slippage (Points)
  • [=== Trade Management ===] InpMaxSpread = 200 // Max Spread (Points)
  • [=== Trade Management ===] InpMagicNumber = 22212017 // Magic Number
  • [=== Pyramid / Scaling ===] InpUsePyramid = true // Enable Safe Pyramiding
  • [=== Pyramid / Scaling ===] InpMaxPyramidTrades = 3 // Max Open Positions
  • [=== Pyramid / Scaling ===] InpPyramidMinProfit = 100 // Min Secured Profit (Points) for Next Add
  • [=== 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
  • [=== Time Management ===] InpTradeComment = "Psgrowth.com Expert_12017" // Trade Comment
Pseudocode
// Pipsgrowth EX12017 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// This EA implements internal AMLI (Adaptive Market Liquidity Index) logic using Volume and ATR-based volatility analysis. 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
InpVolumePeriod14Volume Smoothing Period
InpVolatilityPeriod20Volatility (ATR) Period
InpLiquidityTrap35.0Liquidity Trap Level (0-100)
InpMinAMLIChange3.0Minimum AMLI Change for Signal
InpRiskPercent1.0Risk per trade (% of Balance)
InpFixedLot0.01Fixed Lot (if Risk=0)
InpMaxLotSize10.0Max Lot Size per trade
InpStopLoss500Stop Loss (Points)
InpTakeProfit750Take Profit (Points)
InpSlippage30Max Slippage (Points)
InpMaxSpread200Max Spread (Points)
InpMagicNumber22212017Magic Number
InpUsePyramidtrueEnable Safe Pyramiding
InpMaxPyramidTrades3Max Open Positions
InpPyramidMinProfit100Min Secured Profit (Points) for Next Add
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
InpTradeComment"Psgrowth.com Expert_12017"Trade Comment
Source Code (.mq5)Open Source
Pipsgrowth_com_EX12017.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX12017 AMLI_XAUUSD_5M — Adaptive Market Liquidity Index EA for XAUUSD, 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 "=== AMLI Indicator Parameters ==="
input int      InpVolumePeriod      = 14;          // Volume Smoothing Period
input int      InpVolatilityPeriod  = 20;          // Volatility (ATR) Period
input double   InpLiquidityTrap     = 35.0;        // Liquidity Trap Level (0-100)
input double   InpMinAMLIChange     = 3.0;         // Minimum AMLI Change for Signal

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        = 750;         // Take Profit (Points)
input int      InpSlippage          = 30;          // Max Slippage (Points)
input int      InpMaxSpread         = 200;         // Max Spread (Points)
input ulong    InpMagicNumber       = 22212017;    // Magic Number

input group "=== Pyramid / Scaling ==="
input bool     InpUsePyramid        = true;        // Enable Safe Pyramiding
input int      InpMaxPyramidTrades  = 3;           // Max Open Positions
input int      InpPyramidMinProfit  = 100;         // Min Secured Profit (Points) for Next Add

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

input string   InpTradeComment      = "Psgrowth.com Expert_12017"; // Trade Comment

// --- Global Handles ---
int h_atr        = INVALID_HANDLE;

// --- State Tracking ---

Full source code available on download

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

Tags:ex12017multiindicatorconfluencepipsgrowthfreemt5xauusd

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