Pipsgrowth EX12049 MultiIndicatorConfluence
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX12049 XAUUSD_M5_DHLAOS_EA — Daily High/Low + Andean Oscillator confluence, full 12-layer stack.
Overview
Pipsgrowth EX12049 is built around a two-engine confluence: an inline-calculated Andean Oscillator that breaks every bar into bull and bear power, and a Daily High/Low overlay that replays the prior session's range onto the working chart as constant intraday bands. The pair was chosen so the AOS can fire directional reversals at the moment price rejects one of those bands, and the EA was wired to XAUUSD on M5 because that combination is where the rejection wicks are deepest and the AOS swings are widest.
The AOS engine is fully self-calculated — there is no iCustom handle. On every new bar the function CalculateAndeanOscillator copies g_buffSize (= InpAOSNCheck + InpDHLNCheck + 10 = 360) bars of MqlRates and runs an EMA-style smoothing on the up-leg and down-leg separately. The smoothing factor is the standard alpha = 2.0 / (InpAOSPeriod + 1) = 2/51 with the default InpAOSPeriod = 50, and the leg inputs are max(0, close - prevClose) for up and max(0, prevClose - close) for down. The bull line is upEMA / (upEMA + dnEMA) * 100 and the bear line is dnEMA / (upEMA + dnEMA) * 100, so they are bounded 0-100 and sum to 100. A signal line is then the EMA of the bull line with InpAOSSignalPeriod = 9, applied in reverse through the buffer. A bar where bull crosses up through signal is the trigger event, and a bar where bear crosses up through signal is the mirror trigger for shorts.
The Daily High/Low engine is a single CopyRates call into PERIOD_D1 covering the latest five daily bars. It captures the running today high/low and the finalized previous day high/low, then loops the working M5 buffer, splits each bar's time into a day bucket, and stamps the appropriate high/low onto every bar. The result is two constant lines per day that act as the rejection zones — for the buy arm, the EA wants a bar where the M5 high traded below the daily low while bull power was below bear power; for the sell arm it wants the opposite: an M5 low above the daily high with bull over bear.
The buy signal CheckBuySignal is a three-stage gate. First, the cross on bars [2] and [1] must show bull going from below-or-equal to signal on bar 2 to above signal on bar 1. Second, the function walks backward up to InpAOSNCheck = 300 bars looking for a prior bar j where bull crossed above bear, with three invalidation conditions in the same loop: any bull-under-bear cross, any bull-under-signal cross, or any bull-over-signal cross between the prior cross and the trigger kills the setup. If j stays 0, the function returns false. Third, the function scans from j to j + InpDHLNCheck = 50 for a single bar where iHigh was below g_dailyLow and g_aosBull < g_aosBear. If that bar exists, the buy fires. The sell mirror CheckSellSignal swaps the cross and the dominance conditions symmetrically.
Position construction uses swing extremes for the stop. GetSwingLow walks the last InpSLLookback = 7 bars of iLow and returns the minimum; the buy SL is that minimum minus InpSLDev = 60 points of buffer. GetSwingHigh mirrors that for sells. The TP target is then entry ± 1.5 × the SL distance, set by InpTPCoef = 1.5 — that is the entire risk-to-reward shape of the trade, baked at order entry. If InpReverse is true, the buy function posts a sell with the mirrored SL and TP, and the sell function posts a buy; that flag is the only macro switch between long-only and short-only bias at the signal layer.
ManageTrailingStop runs on every tick before the new-bar gate. It walks PositionsTotal and filters by symbol and magic. For a buy it computes bid - openPrice; once that move clears InpTrailStart = 300 points, it sets newSL = bid - InpTrailDistance = 200 points, but only when newSL is strictly tighter than the current SL and strictly above the open price, so the trailing never loosens and never moves below breakeven. The sell mirror uses ask - openPrice and trails to ask + 200 points. The helper TryModify_EX12049 wraps the modify in a 3-attempt retry that sleeps 100 ms on TRADE_RETCODE_REQUOTE or TRADE_RETCODE_TIMEOUT, so a brief requote does not abort the ratchet. The two closing helpers TryClose_EX12049 and TryClosePartial_EX12049 use the same retry pattern with 200 ms sleeps on REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED.
Sizing is set by CalculateLotSize, which prefers a percentage model. With InpRiskPercent = 0.5 the lot is balance * 0.005 / (slPoints * tickValue * point / tickSize), floored to the symbol's lot step, clamped to the symbol min and max, then capped by InpMaxLotSize = 1.0. Setting InpRiskPercent to 0 falls back to InpFixedLot = 0.01 — a deliberately tiny fallback that keeps the EA live on small accounts but forces the user to think before turning on real risk. The SL distance that drives the lot is the actual point gap from ask to swing-derived SL computed inside ExecuteBuy, not a generic input, so every trade sizes against the bar geometry that triggered it.
The no-trade layer is two pieces. IsWithinTradingSession checks the server hour against two optional windows: Session 1 from 8 to 12 and Session 2 from 14 to 18. The default has both enabled, which gives a London morning block, a deliberate one-hour break, and a London/NY afternoon block. Either window being on and matching the current hour is enough to pass. IsSpreadOK measures the live ask/bid gap in points and rejects anything above InpMaxSpread = 200 points (about 2.0 pips on a 5-digit XAUUSD feed). Both gates run before the indicator math on every new bar, so a quiet session costs no CPU past the trailing loop.
Pyramiding is wired but off by default. When InpEnablePyramid flips true, the EA first checks CountOpenTrades against InpMaxPyramidLevels = 3. The IsPyramidSafe helper then walks every open position of the same magic and rejects the new entry if any same-direction position has its SL not pushed at least InpMinSLProfit = 150 points into profit — for a buy that means SL > open + 150pt, for a sell that means SL < open - 150pt, with the sl == 0 case treated as not-in-profit. The result is that you cannot add a second layer until the first layer is genuinely running, which keeps the basket from doubling into a loss.
What to expect in backtest: with the default 0.5% risk on XAUUSD M5, the EA trades the rejection of the prior day's range and tends to cluster entries at the European open and the New York open. The signal is selective on purpose — the AOS cross, the preserved prior cross, and the rejection bar all have to align — so do not be surprised by lower trade counts than a typical indicator EA. The first knobs to tune are InpSLDev (tighter for cleaner breakouts, wider for noisy sessions), InpTPCoef (push above 2.0 only after verifying the rejection-bar geometry actually delivers that extension), and InpMaxSpread (lower it on brokers that widen during the rollover hour). Pyramiding is left off in this default because the AOS rejection setup already wants the position to be the only one on that side.
Strategy Deep Dive
Combines a self-calculated Andean Oscillator (EMA-smoothed bull/bear power lines + signal line) with a Daily High/Low overlay that stamps the prior and current D1 extremes onto every M5 bar as constant intraday bands. The buy arm demands a Bull-over-Signal cross on bars [2]→[1], a preserved prior Bull-over-Bear cross within the last 300 bars (no invalidations), and a downstream M5 bar where price dipped under the Daily Low with bear dominance. The sell arm mirrors that with Bear-over-Signal, prior Bull-under-Bear, and price over the Daily High with bull dominance. ManageTrailingStop runs on every tick and ratchets the SL tighter (never loosens) once price moves InpTrailStart=300 points in trade direction, with InpTrailDistance=200 points of trail. Session windows (8-12 and 14-18 server time) and the 200-point spread cap run as a no-trade gate before the indicator math each new bar. Order submission goes through a 3-retry helper that sleeps 100-200 ms on REQUOTE/TIMEOUT/PRICE_OFF/PRICE_CHANGED, so a brief requote does not abort the SL ratchet or the close.
Buy triggers when the Andean Oscillator Bull line crosses above its Signal line on bars [2]→[1] and, within the preceding 300 bars, there is a preserved Bull-above-Bear crossover (no invalidating cross between it and the trigger) followed somewhere in the next 50 bars by an M5 bar whose high traded below the Daily Low with Bull<Bear dominance. Sell is the mirror: Bear crosses above Signal, a prior Bull-below-Bear cross is preserved, then an M5 bar traded above the Daily High with Bull>Bear.
Exits are managed by the TP at 1.5× the SL distance hit, the ratcheting trailing stop (300pt activation / 200pt distance) running on every tick, and the reverse signal of the same engine when the opposite cross+rejection pattern completes. The reverse signal acts as the structural exit — if a buy is live and the sell arm validates, the next valid sell execution does not close the buy by itself; the buy is expected to be closed by either the trailing stop or the SL/TP. There is no time-based or session-end close.
Buy stop is the minimum iLow over the last InpSLLookback=7 bars minus InpSLDev=60 points of buffer; sell stop is the maximum iHigh over the last 7 bars plus 60 points. The trailing stop then ratchets tighter (never loosens) once price moves 300 points in the trade direction, with 200 points of trail distance. Pyramiding is rejected unless every existing same-direction position has its SL pushed at least InpMinSLProfit=150 points into profit.
Take-profit is calculated at order placement as entry ± InpTPCoef=1.5 × the SL distance, giving a fixed 1.5:1 reward-to-risk ratio. The TP is set once via the SL × coefficient formula using the swing-derived stop; it is not adjusted by the trailing stop, so the actual realized RR can be smaller if the trailing stop fires first.
XAUUSD on the M5 timeframe is the canonical deployment — the AOS power swings and the Daily High/Low rejection geometry are both tuned to gold's 5-minute volatility band. Recommended account size is $100 (matches the EA's minDeposit) running InpRiskPercent=0.5% with the InpFixedLot=0.01 fallback for testing, and a broker whose typical XAUUSD spread stays under InpMaxSpread=200 points (about 2.0 pips on a 5-digit feed). The two time windows — 8-12 (London morning) and 14-18 (London/NY afternoon with a 1-hour lunch break) — mean the EA is naturally suited to traders who can babysit the European and US opens rather than run it 24/5. Risk level is MEDIUM because the rejection setup is selective but the 0.5% default and 1.5:1 RR leave real room for a drawdown streak on quiet days.
Strategy Logic
Pipsgrowth EX12049 MultiIndicatorConfluence — Strategy Logic Analysis (from .mq5 source)
Family: MultiIndicatorConfluence
Magic: 22212049
Version: 2.00
BRIEF:
Self-contained Daily High/Low + Andean Oscillator confluence EA. Entries fire when AOS bull/bear power aligns with a Daily High/Low breakout/ rejection setup; SL from swing lookback, TP = SL x coefficient. Full 12-layer stack: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
CalculateAndeanOscillator()CalculateDailyHighLow()CalculateLotSize()GetSwingLow()GetSwingHigh()IsWithinTradingSession()IsSpreadOK()CountOpenTrades()IsPyramidSafe()ManageTrailingStop()CheckBuySignal()CheckSellSignal()- ...and 5 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (27 total across 8 groups):
- [=== Trade
Comment===]InpTradeComment= "Psgrowth.com Expert_12049" // TradeComment - [=== Trade
Comment===]InpMagicNumber=22212049// Magic Number - [=== Indicator Parameters ===]
InpAOSPeriod= 50 // Andean Oscillator Period - [=== Indicator Parameters ===]
InpAOSSignalPeriod= 9 //AOSSignal Period - [=== Strategy Settings ===]
InpTPCoef=1.5// TPCoefficient(x SL) - [=== Strategy Settings ===]
InpSLLookback= 7 // SL Swing Lookback - [=== Strategy Settings ===]
InpSLDev= 60 // SLDeviation(Points) - [=== Strategy Settings ===]
InpAOSNCheck= 300 //AOSMax Candles Check - [=== Strategy Settings ===]
InpDHLNCheck= 50 //DHLMax Candles Check - [=== Strategy Settings ===]
InpReverse=false// Reverse Signal - [=== Risk Management ===]
InpRiskPercent=0.5// Risk % per Trade - [=== Risk Management ===]
InpFixedLot=0.01// FixedLot(if Risk=0) - [=== Risk Management ===]
InpMaxLotSize=1.0// Max Lot Size - [=== Trailing Stop ===]
InpUseTrailing=true// Enable Trailing - [=== Trailing Stop ===]
InpTrailStart= 300 // TrailStart(Points) - [=== Trailing Stop ===]
InpTrailDistance= 200 // TrailDistance(Points) - [=== Time Management ===]
InpEnableSession1=true// Enable Session 1 - [=== Time Management ===]
InpSession1Start= 8 // Session 1 Start Hour - [=== Time Management ===]
InpSession1End= 12 // Session 1 End Hour - [=== Time Management ===]
InpEnableSession2=true// Enable Session 2 - [=== Time Management ===]
InpSession2Start= 14 // Session 2 Start Hour - [=== Time Management ===]
InpSession2End= 18 // Session 2 End Hour - [=== Spread Filter ===]
InpEnableSpreadFilter=true// Enable Spread Filter - [=== Spread Filter ===]
InpMaxSpread= 200 // MaxSpread(Points) - [=== Safe Pyramid ===]
InpEnablePyramid=false// Enable Pyramiding - [=== Safe Pyramid ===]
InpMaxPyramidLevels= 3 // Max Pyramid Positions - [=== Safe Pyramid ===]
InpMinSLProfit= 150 // Min SL inProfit(Points)
// Pipsgrowth EX12049 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// Self-contained Daily High/Low + Andean Oscillator confluence EA. Entries fire when AOS bull/bear power aligns with a Daily High/Low breakout/ rejection setup; SL from swing lookback, TP = SL x coefficient. Full 12-layer stack: 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 |
|---|---|---|
| InpTradeComment | "Psgrowth.com Expert_12049" | Trade Comment |
| InpMagicNumber | 22212049 | Magic Number |
| InpAOSPeriod | 50 | Andean Oscillator Period |
| InpAOSSignalPeriod | 9 | AOS Signal Period |
| InpTPCoef | 1.5 | TP Coefficient (x SL) |
| InpSLLookback | 7 | SL Swing Lookback |
| InpSLDev | 60 | SL Deviation (Points) |
| InpAOSNCheck | 300 | AOS Max Candles Check |
| InpDHLNCheck | 50 | DHL Max Candles Check |
| InpReverse | false | Reverse Signal |
| InpRiskPercent | 0.5 | Risk % per Trade |
| InpFixedLot | 0.01 | Fixed Lot (if Risk=0) |
| InpMaxLotSize | 1.0 | Max Lot Size |
| InpUseTrailing | true | Enable Trailing |
| InpTrailStart | 300 | Trail Start (Points) |
| InpTrailDistance | 200 | Trail Distance (Points) |
| InpEnableSession1 | true | Enable Session 1 |
| InpSession1Start | 8 | Session 1 Start Hour |
| InpSession1End | 12 | Session 1 End Hour |
| InpEnableSession2 | true | Enable Session 2 |
| InpSession2Start | 14 | Session 2 Start Hour |
| InpSession2End | 18 | Session 2 End Hour |
| InpEnableSpreadFilter | true | Enable Spread Filter |
| InpMaxSpread | 200 | Max Spread (Points) |
| InpEnablePyramid | false | Enable Pyramiding |
| InpMaxPyramidLevels | 3 | Max Pyramid Positions |
| InpMinSLProfit | 150 | Min SL in Profit (Points) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX12049 XAUUSD_M5_DHLAOS_EA — Daily High/Low + Andean Oscillator confluence, full 12-layer stack."
#include <Trade/Trade.mqh>
CTrade trade;
//+------------------------------------------------------------------+
//| Input Parameters |
//+------------------------------------------------------------------+
input group "=== Trade Comment ==="
input string InpTradeComment = "Psgrowth.com Expert_12049"; // Trade Comment
input ulong InpMagicNumber = 22212049; // Magic Number
input group "=== Indicator Parameters ==="
input int InpAOSPeriod = 50; // Andean Oscillator Period
input int InpAOSSignalPeriod = 9; // AOS Signal Period
input group "=== Strategy Settings ==="
input double InpTPCoef = 1.5; // TP Coefficient (x SL)
input int InpSLLookback = 7; // SL Swing Lookback
input int InpSLDev = 60; // SL Deviation (Points)
input int InpAOSNCheck = 300; // AOS Max Candles Check
input int InpDHLNCheck = 50; // DHL Max Candles Check
input bool InpReverse = false; // Reverse Signal
input group "=== Risk Management ==="
input double InpRiskPercent = 0.5; // Risk % per Trade
input double InpFixedLot = 0.01; // Fixed Lot (if Risk=0)
input double InpMaxLotSize = 1.0; // Max Lot Size
input group "=== Trailing Stop ==="
input bool InpUseTrailing = true; // Enable Trailing
input int InpTrailStart = 300; // Trail Start (Points)
input int InpTrailDistance = 200; // Trail Distance (Points)
input group "=== Time Management ==="
input bool InpEnableSession1 = true; // Enable Session 1
input int InpSession1Start = 8; // Session 1 Start Hour
input int InpSession1End = 12; // Session 1 End Hour
input bool InpEnableSession2 = true; // Enable Session 2
input int InpSession2Start = 14; // Session 2 Start Hour
input int InpSession2End = 18; // Session 2 End Hour
input group "=== Spread Filter ==="
input bool InpEnableSpreadFilter = true; // Enable Spread Filter
input int InpMaxSpread = 200; // Max Spread (Points)
input group "=== Safe Pyramid ==="
input bool InpEnablePyramid = false; // Enable Pyramiding
input int InpMaxPyramidLevels = 3; // Max Pyramid Positions
input int InpMinSLProfit = 150; // Min SL in Profit (Points)
//+------------------------------------------------------------------+
//| Global Variables |
//+------------------------------------------------------------------+
datetime g_lastCandle = 0;
int g_buffSize;
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.