P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX12052 MultiIndicatorConfluence

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

Pipsgrowth.com EX12052 EX18 — True Gaussian Bands mean-reversion EA with DLP and multi-model sizing, full 12-layer stack.

Overview

Pipsgrowth EX12052 is a mean-reversion EA built around True Gaussian Bands, a kernel-smoothed price envelope that differs from a textbook Bollinger setup in one specific way: the midline and the outer bands are both computed from a weighted moving average whose weights are the row of Pascal's triangle, normalised to sum to one. In BuildGaussianWeights() the EA builds C(period-1, k) iteratively (no factorials, so it never overflows on long periods) and feeds those weights into ComputeTGB(). The result is a near-Gaussian smoother — the closer a sample is to the centre, the heavier its contribution to both the mean and the standard deviation. With the default TGB_Period=21 and TGB_StdDevFactor=2.0 the bands are visibly tighter than a 21-period Bollinger on the same data because the kernel down-weights tail samples instead of treating them equally.

The signal itself is a band-touch cross. ComputeIntent() pulls the close of the previous two bars through GetAppliedPriceSeries(), and looks for the bar-2 close below the lower band with the bar-1 close above the lower band (BUY, reason="cross_up_lower"), or the inverse for SELL. There is no slope check, no momentum filter, no trend alignment in the core engine — the signal is purely the close crossing back inside the envelope after a single excursion. The MinHistoryBars=200 input gates when ComputeTGB() is allowed to run, so the EA waits until the symbol has at least 200 bars of clean history on the chosen strategy timeframe before it starts trading.

Where most mean-reversion EAs fire the moment the close crosses the band, EX12052 puts a Signal Buffer between the signal and the order. When Sb_EnableBuffer is true, a fresh cross on a new bar does not place an order — it creates a SignalBuffer record with the direction, the timestamp, and the close at the cross (the anchor price). The trade only fires on a subsequent tick, and only if Buffer_Valid() still returns true, which requires TimeCurrent()-g_sig.tstamp <= Sb_ValidityMinutes*60. With the default 3-minute window the EA has three minutes to actually act on the signal; after that the buffer is cleared with reason="expired". Inside those 3 minutes, RevalidateIfNeeded() re-runs ComputeTGB on the latest closed bar, checks that the close is still on the right side of the relevant band, and — if Sb_MaxDriftPoints=100 is enabled — verifies the current ask/bid has not drifted more than 100 points away from the anchor price at the time of the cross. This is the EA's main defence against chasing a cross that's already moved on.

Position management runs on every tick and is split into two parallel routines. RunSLManagers() combines two stop models. The DLP (Dynamic Lock Profit) layer is enabled by default with SL_LockEveryXPoints=200 and SL_LockMinusBuffer=40: once price has moved 200 points in profit, the stop is ratcheted to open ± (1×200 - 40) = 160 points. After 400 points of profit, the stop jumps to 360 points. The step is monotonic — ModifySL() rejects any modification that loosens the stop, and the validation also checks the symbol's SYMBOL_TRADE_STOPS_LEVEL so the new stop never lands inside the freeze zone. Optionally, SL_EnableATR engages an ATR-derived stop at SL_ATR_Period=14 and SL_ATR_Multiplier=2.0. The two stops are combined as a "safer-of": for a BUY, the higher of the two is applied; for a SELL, the lower. RunTPManager() runs only when TP_EnableATR is true and uses a separate ATR handle (TP_ATR_Period=14, TP_ATR_Multiplier=2.0 by default); when price moves TP_ATR_Multiplier × ATR in profit, ClosePosition() is called via the CTrade wrapper TryClose_EX12052() with a 3-attempt retry on requotes/timeouts.

Sizing is the most configurable part of the EA. ComputeFinalVolume() runs five independent sizing methods in parallel — Sizing_Fixed (Sz_FixedLot=1.00 default, ON), Sizing_Balance (Sz_BalancePerLot=5000, OFF), Sizing_Equity (Sz_EquityPerLot=5000, OFF), Sizing_PercentRisk (Sz_RiskPercent=1.0%, OFF), and Sizing_ATR (Sz_RiskPerATR=10, OFF) — and picks the minimum of whichever methods are enabled, then runs the result through NormalizeVolume() which floors to g_volstep and clamps between Sz_MinLotClamp=0.01 and Sz_MaxLotClamp=50. The combination is intentionally conservative: enabling more sizing models never makes the lot larger, only smaller. PercentRisk uses EstimateSLDistancePointsForRisk() to figure out the SL distance, preferring an ATR-derived distance if SL_EnableATR is on, otherwise the DLP step size, otherwise the Sz_RiskSL_FallbackPoints=300 default.

Confirmations are stacked on top of the core cross. MA_OK(), RSI_OK() and ADX_OK() each gate the entry independently and are all off by default — turning them on is a per-input choice. C_MA_Enabled with C_MA_Period=200 and C_MA_Method=MODE_EMA requires price to be on the right side of the MA (close ≥ MA for buys, close ≤ MA for sells). C_RSI_Enabled with C_RSI_Period=14 and the bands C_RSI_BuyMax=60 / C_RSI_SellMin=40 encodes a mean-reversion bias — buys only when RSI is at or below 60, sells only when RSI is at or above 40. C_ADX_Enabled with C_ADX_Period=14 and C_ADX_Min=15 filters out the most dead markets by requiring ADX ≥ 15. None of these is on out of the box, so the default behaviour is the raw TGB cross with the buffer validation.

The gate chain in GatesOK() runs in this order on every entry attempt: tick freshness (reject if TimeCurrent() - tick.time > Misc_MaxTickAgeSec=5), session check via SessionsOK(), SpreadOK() with the rolling 200-tick median (or 300-point absolute cap if F_Spread_UseAbsolute=true), SlippageOK() with F_Slip_MaxPoints=5, the three confirmations, free margin check (FM_MinFreeMargin=500 by default), the loss-streak pause window, the total position cap (Add_MaxOpenTrades=5), and finally the additions profitability check (Add_OnlyProfitable=true requires all same-direction positions to be at least Add_MinProfitPts=5.0 points in profit before another add fires). Sessions default to Tokyo 02:00-11:00, London 10:00-18:00, New York 15:00-23:00, all Mon-Fri only, with Saturday and Sunday disabled.

The pause guards live in OnTradeTransaction(). When a deal closes with negative profit (after swap and commission), g_lossStreakCount increments; on the first profitable close it resets to zero. Two pause triggers fire off the streak: Pause_OnLossCount=true with Pause_LossCount=3 sets g_tradePauseUntil to TimeCurrent() + 30 minutes (Pause_LossCount_Min=30); Pause_OnLossAmount=true with Pause_LossAmount=200 sets the same g_tradePauseUntil to TimeCurrent() + Pause_LossAmt_Min=30 minutes. Whichever trigger fires clears its counter so the next streak starts fresh. The order of send uses req.sl=0 and req.tp=0 at open — the SL and TP are managed entirely by RunSLManagers() and RunTPManager() in subsequent ticks, which is why the trade comments on the positions are the only thing the broker sees at fill time (the order is sent as a market order with no hard SL/TP, and the CTrade wrapper falls back to FOKIOCRETURN filling modes via ResolveFillingMode()).

For the trader, what this means in practice is: the EA waits for a real band excursion, holds the signal for 3 minutes while re-checking the bands, and only fires when the cross is still valid. From there it picks the smallest lot that all enabled sizing models agree is safe, manages the position with a step-ratchet that locks progressively more of the profit, and bails out for half an hour after three consecutive losses or $200 of cumulative loss. Default risk level is MEDIUM with a recommended minimum deposit of $100 on XAUUSD. The EA defaults to M1 timeframe but StrategyTimeframe can be set to M1, M5, M15, M30, H1, H4 or D1, and the on-tick work is cheap enough that it runs on all of them without issue. Below M1 is not supported by the input range; above D1 the TGB envelope becomes too smooth to catch most intraday reversals.

Strategy Deep Dive

True Gaussian Bands replace the standard Bollinger: BuildGaussianWeights() constructs a Pascal-row binomial kernel, ComputeTGB() feeds that kernel into both the weighted mean and the weighted variance over TGB_Period=21 samples, and the result is TGB_StdDevFactor=2.0 envelopes that weight the centre of the window more heavily than the tails. ComputeIntent() then watches the close of the previous two bars for a band-touch cross — below-then-above the lower band fires BUY, above-then-below the upper band fires SELL. Rather than acting on the cross immediately, the EA parks it in a SignalBuffer with a 3-minute TTL, and OnTick's TryEntries() re-runs the cross check via RevalidateIfNeeded() before SendEntry() ever builds the MqlTradeRequest — the request goes out at ask/bid with req.sl=0 and req.tp=0 and is filled through ResolveFillingMode()'s FOKIOCRETURN fallback chain, while the actual SL/TP is layered on afterwards by RunSLManagers() and RunTPManager() on each subsequent tick. Sizing picks the minimum lot from whichever of the five models (Fixed, Balance, Equity, PercentRisk, ATR) are toggled on, and the per-tick SL manager combines the DLP step-ratchet and the optional ATR-SL as a safer-of before pushing the new stop through ModifySL()'s never-loosen validation.

Entry Signal

Entries fire on a TGB band cross: BUY when the previous bar closed below the lower Gaussian band and the latest bar closes back above it, SELL on the mirror image. With Sb_EnableBuffer=true the cross is held in a SignalBuffer for up to 3 minutes (Sb_ValidityMinutes) and revalidated on every tick — RevalidateIfNeeded() rejects the trade if the latest close has fallen back through the band or if the current ask/bid has drifted more than Sb_MaxDriftPoints=100 from the cross anchor. The trade then clears the gates (tick freshness, session, spread, slippage, optional MA/RSI/ADX confirmations, free margin, loss-streak pause, total-position cap, additions-profitability check) before ComputeFinalVolume() returns the lot and SendEntry() fires the market order via the CTrade wrapper.

Exit Signal

Exits are managed on every tick by RunTPManager(), which closes a position when price has moved TP_ATR_Multiplier=2.0 × ATR(14) in profit (only when TP_EnableATR is on). If TP is disabled, the only hard exit path is a reverse TGB cross in the opposite direction or the optional MA/RSI/ADX confirmations flipping the gate. All open trades are also force-closed by CTrade wrapper TryClose_EX12052() with 3 retry attempts (200ms sleep on requote/timeout) when the TP triggers, and ModifySL() will not loosen stops under any condition — once a stop is moved, it only tightens.

Stop Loss

Stop loss is the safer of DLP and ATR-SL: a 200-point ratchet step with a 40-point buffer (open ± (steps×200 - 40) once price is in profit) OR an ATR(14) × 2.0 trailing stop — whichever is closer to price in the right direction. ModifySL() rejects any modification that loosens an existing stop, respects SYMBOL_TRADE_STOPS_LEVEL, and runs every tick. With SL_EnableDLP=true (default) and SL_EnableATR=false (default), the EA ships with a pure DLP ratchet and no ATR-SL overlay.

Take Profit

TP is optional and ATR-based. When TP_EnableATR=true the EA closes the position once price has moved TP_ATR_Period=14 × TP_ATR_Multiplier=2.0 in profit from the entry price, with the close routed through TryClose_EX12052()'s 3-attempt CTrade retry. With TP disabled (default), the position is held indefinitely and exits only on a reverse signal, a free-margin stop, or a manual close — the DLP ratchet protects profit, but a hard TP does not exist on the order itself.

Best For

Recommended for XAUUSD M1 (the default strategy timeframe) and other high-volatility mean-reversion symbols on a low-spread ECN/RAW account. With the default 1.00 fixed lot the EA needs at least $100 of balance to trade the minimum contract, and the loss-streak pause ($200 cumulative or 3 consecutive losses, 30-minute cooldown) keeps the damage per session bounded. The Tokyo 02:00-11:00 / London 10:00-18:00 / New York 15:00-23:00 session defaults are tuned for a GMT+2 / GMT+3 server clock, so traders on a UTC broker should adjust Ses1/Ses2/Ses3_Start_HH forward by 2-3 hours. Risk is MEDIUM by default but swings higher when all four confirmations are enabled simultaneously — most live users will run with confirmations off and the DLP ratchet as the sole profit-protector.

Strategy Logic

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

Family: MultiIndicatorConfluence Magic: 22212052 Version: 2.00

BRIEF: True Gaussian Bands mean-reversion EA with Gaussian- weighted MA and standard deviation bands, signal buffer with revalidation, multi-model position sizing, DLP stop manager, optional ATR-SL/TP, and multi-session filtering. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • Log()
  • LogThrottled()
  • RefreshSymbolInfo()
  • PointsToPrice()
  • PriceToPoints()
  • DayEnabled()
  • InSession()
  • SessionsOK()
  • GetCurrentSpreadPoints()
  • Median()
  • SpreadOK()
  • SlippageOK()
  • ...and 37 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (103 total across 13 groups):

  • [=== CORE IDENTIFIERS & EXECUTION CONTEXT ===] InpMagicNumber = 22212052 // 2220 + Expert ID (314)
  • [=== CORE IDENTIFIERS & EXECUTION CONTEXT ===] InpSymbol = "" // Symbol override ("" = chart symbol) (Opt: -, -, -)
  • [=== CORE IDENTIFIERS & EXECUTION CONTEXT ===] StrategyTimeframe = 1 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // StrategyTimeframe (Opt: PERIOD_M1,1,PERIOD_M15)
  • [=== CORE IDENTIFIERS & EXECUTION CONTEXT ===] InpOrderFilling = FillAuto // Order filling mode: Auto/FOK/IOC/RETURN (Opt: 0,1,3)
  • [=== CORE IDENTIFIERS & EXECUTION CONTEXT ===] InpAllowBuy = true // Allow BUY entries (Opt: false, true, true)
  • [=== CORE IDENTIFIERS & EXECUTION CONTEXT ===] InpAllowSell = true // Allow SELL entries (Opt: false, true, true)
  • [=== ENTRY SIGNAL (TRUE GAUSSIAN BANDS) ===] TGB_Period = 21 // TGB Period (odd recommended) (Opt: 7,2,61)
  • [=== ENTRY SIGNAL (TRUE GAUSSIAN BANDS) ===] TGB_StdDevFactor = 2.0 // Bands StdDev Multiplier (Opt: 0.5,0.1,4.0)
  • [=== ENTRY SIGNAL (TRUE GAUSSIAN BANDS) ===] TGB_Price = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted)// Applied price (Opt: PRICE_CLOSE,1,PRICE_TYPICAL)
  • [=== ENTRY SIGNAL (TRUE GAUSSIAN BANDS) ===] TGB_MinHistoryBars = 200 // Minimum bars to operate (Opt: 100,50,2000)
  • [=== SIGNAL BUFFER & REVALIDATION ===] Sb_EnableBuffer = true // Enable Signal Buffer (Opt: false, true, true)
  • [=== SIGNAL BUFFER & REVALIDATION ===] Sb_ValidityMinutes = 3 // SignalValidityMinutes (Opt: 1,1,60)
  • [=== SIGNAL BUFFER & REVALIDATION ===] Sb_RevalidateDirection = true // RevalidateDirection before order send (Opt: false, true, true)
  • [=== SIGNAL BUFFER & REVALIDATION ===] Sb_MaxDriftPoints = 100 // MaxDriftPoints from anchor (points) (Opt: 0,10,1000)
  • [=== FILTERS: SPREAD & SLIPPAGE ===] F_Spread_Enabled = true // Enable Spread Filter (Opt: false, true, true)
  • [=== FILTERS: SPREAD & SLIPPAGE ===] F_Spread_UseAbsolute = false // Use Absolute cap (else median×multiplier) (Opt: false, true, true)
  • [=== FILTERS: SPREAD & SLIPPAGE ===] F_Spread_AbsCapPoints = 300 // Absolute cap (points) (Opt: 50,10,2000)
  • [=== FILTERS: SPREAD & SLIPPAGE ===] F_Spread_MedianTicks = 200 // Rolling median window (ticks) (Opt: 50,10,2000)
  • [=== FILTERS: SPREAD & SLIPPAGE ===] F_Spread_MedianMult = 3.0 // Multiplier × rolling median (Opt: 1.0,0.1,5.0)
  • [=== FILTERS: SPREAD & SLIPPAGE ===] F_Slip_Enabled = true // Enable Slippage Filter (Opt: false, true, true)
  • [=== FILTERS: SPREAD & SLIPPAGE ===] F_Slip_MaxPoints = 5 // Max permitted slippage (points) (Opt: 1,1,50)
  • [=== FILTER: SESSIONS ===] Ses_Enabled = true // Enable Sessions Filter (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses1_Start_HH = 02 // S1 Start Hour (Opt: 0,1,23)
  • [=== FILTER: SESSIONS ===] Ses1_Start_MM = 00 // S1 Start Minute (Opt: 0,1,59)
  • [=== FILTER: SESSIONS ===] Ses1_End_HH = 11 // S1 End Hour (Opt: 0,1,23)
  • [=== FILTER: SESSIONS ===] Ses1_End_MM = 00 // S1 End Minute (Opt: 0,1,59)
  • [=== FILTER: SESSIONS ===] Ses1_Mon = true // S1 Monday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses1_Tue = true // S1 Tuesday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses1_Wed = true // S1 Wednesday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses1_Thu = true // S1 Thursday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses1_Fri = true // S1 Friday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses1_Sat = false // S1 Saturday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses1_Sun = false // S1 Sunday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses2_Start_HH = 10 // S2 Start Hour (Opt: 0,1,23)
  • [=== FILTER: SESSIONS ===] Ses2_Start_MM = 00 // S2 Start Minute (Opt: 0,1,59)
  • [=== FILTER: SESSIONS ===] Ses2_End_HH = 18 // S2 End Hour (Opt: 0,1,23)
  • [=== FILTER: SESSIONS ===] Ses2_End_MM = 00 // S2 End Minute (Opt: 0,1,59)
  • [=== FILTER: SESSIONS ===] Ses2_Mon = true // S2 Monday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses2_Tue = true // S2 Tuesday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses2_Wed = true // S2 Wednesday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses2_Thu = true // S2 Thursday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses2_Fri = true // S2 Friday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses2_Sat = false // S2 Saturday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses2_Sun = false // S2 Sunday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses3_Start_HH = 15 // S3 Start Hour (Opt: 0,1,23)
  • [=== FILTER: SESSIONS ===] Ses3_Start_MM = 00 // S3 Start Minute (Opt: 0,1,59)
  • [=== FILTER: SESSIONS ===] Ses3_End_HH = 23 // S3 End Hour (Opt: 0,1,23)
  • [=== FILTER: SESSIONS ===] Ses3_End_MM = 00 // S3 End Minute (Opt: 0,1,59)
  • [=== FILTER: SESSIONS ===] Ses3_Mon = true // S3 Monday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses3_Tue = true // S3 Tuesday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses3_Wed = true // S3 Wednesday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses3_Thu = true // S3 Thursday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses3_Fri = true // S3 Friday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses3_Sat = false // S3 Saturday (Opt: false, true, true)
  • [=== FILTER: SESSIONS ===] Ses3_Sun = false // S3 Sunday (Opt: false, true, true)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_MA_Enabled = false // Enable Trend/MA confirmation (Opt: false, true, true)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_MA_Period = 200 // MA Period (Opt: 50,10,400)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_MA_Method = MODE_EMA // MA Method (Opt: MODE_SMA,1,MODE_LWMA)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_MA_Price = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted)// MA Price (Opt: PRICE_CLOSE,1,PRICE_TYPICAL)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_RSI_Enabled = false // Enable RSI confirmation (Opt: false, true, true)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_RSI_Period = 14 // RSI Period (Opt: 5,1,50)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_RSI_BuyMax = 60 // BUY if RSI <= BuyMax (mean-rev bias) (Opt: 40,1,80)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_RSI_SellMin = 40 // SELL if RSI >= SellMin (Opt: 20,1,80)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_ADX_Enabled = false // Enable ADX confirmation (Opt: false, true, true)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_ADX_Period = 14 // ADX Period (Opt: 7,1,50)
  • [=== CONFIRMATIONS (TREND/MA, RSI, ADX) ===] C_ADX_Min = 15 // Min ADX to allow entries (Opt: 5,1,40)
  • [=== RISK & POSITION SIZING ===] Sz_EnableFixed = true // Enable Fixed Lot (Opt: false, true, true)
  • [=== RISK & POSITION SIZING ===] Sz_FixedLot = 1.00 // Fixed Lot (lots) (Opt: 0.01,0.01,5.00)
  • [=== RISK & POSITION SIZING ===] Sz_EnableBalance = false // Enable Balance-based sizing (Opt: false, true, true)
  • [=== RISK & POSITION SIZING ===] Sz_BalancePerLot = 5000.0 // BalancePerLot ($ per 1.0 lot) (Opt: 1000,500,20000)
  • [=== RISK & POSITION SIZING ===] Sz_EnableEquity = false // Enable Equity-based sizing (Opt: false, true, true)
  • [=== RISK & POSITION SIZING ===] Sz_EquityPerLot = 5000.0 // EquityPerLot ($ per 1.0 lot) (Opt: 1000,500,20000)
  • [=== RISK & POSITION SIZING ===] Sz_EnablePercentRisk = false // Enable %Risk sizing (Opt: false, true, true)
  • [=== RISK & POSITION SIZING ===] Sz_RiskPercent = 1.0 // %Risk per trade (of Balance) (Opt: 0.1,0.1,5.0)
  • [=== RISK & POSITION SIZING ===] Sz_RiskSL_FallbackPoints = 300 // Fallback SL distance (points) if no ATR-SL & DLP step (Opt: 50,10,1500)
  • [=== RISK & POSITION SIZING ===] Sz_EnableATR = false // Enable ATR-based sizing (Opt: false, true, true)
  • [=== RISK & POSITION SIZING ===] Sz_ATR_Size_Period = 14 // ATR period for sizing (Opt: 5,1,50)
  • [=== RISK & POSITION SIZING ===] Sz_RiskPerATR = 10.0 // RiskPerATR ($ per 1×ATR move) (Opt: 1,1,200)
  • [=== RISK & POSITION SIZING ===] Sz_MinLotClamp = 0.01 // User min lot clamp (lots) (Opt: 0.01,0.01,1.0)
  • [=== RISK & POSITION SIZING ===] Sz_MaxLotClamp = 50.0 // User max lot clamp (lots) (Opt: 0.1,0.1,100.0)
  • [=== STOP LOSS MANAGEMENT ===] SL_EnableDLP = true // Enable Dynamic Lock Profit (primary) (Opt: false, true, true)
  • [=== STOP LOSS MANAGEMENT ===] SL_LockEveryXPoints = 200 // DLP: lock step size (points) (Opt: 50,10,1500)
  • [=== STOP LOSS MANAGEMENT ===] SL_LockMinusBuffer = 40 // DLP: minus buffer (points) (Opt: 0,5,200)
  • [=== STOP LOSS MANAGEMENT ===] SL_EnableATR = false // Enable ATR-SL (safer-of vs DLP) (Opt: false, true, true)
  • [=== STOP LOSS MANAGEMENT ===] SL_ATR_Period = 14 // ATR period for SL (Opt: 5,1,50)
  • [=== STOP LOSS MANAGEMENT ===] SL_ATR_Multiplier = 2.0 // ATR Multiplier for SL (Opt: 0.5,0.1,6.0)
  • [=== TAKE PROFIT MANAGEMENT ===] TP_EnableATR = false // Enable ATR-based TP close (Opt: false, true, true)
  • [=== TAKE PROFIT MANAGEMENT ===] TP_ATR_Period = 14 // ATR period for TP (Opt: 5,1,50)
  • [=== TAKE PROFIT MANAGEMENT ===] TP_ATR_Multiplier = 2.0 // ATR Multiplier for TP (Opt: 0.5,0.1,6.0)
  • [=== ADDITIONAL TRADES POLICY ===] Add_MaxOpenTrades = 5 // MaxOpenTrades total (Opt: 1,1,20)
  • [=== ADDITIONAL TRADES POLICY ===] Add_OnlyProfitable = true // AllowOnlyProfitableAdditions (Opt: false, true, true)
  • [=== ADDITIONAL TRADES POLICY ===] Add_MinProfitPts = 5.0 // MinProfitPerTradeToAdd (points) (Opt: 2,1,200)
  • [=== PAUSE GUARDS ===] Pause_OnLossCount = true // PauseOnConsecutiveLosses (Opt: false, true, true)
  • [=== PAUSE GUARDS ===] Pause_LossCount = 3 // PauseConsecutiveLossesCount (Opt: 2,1,10)
  • [=== PAUSE GUARDS ===] Pause_LossCount_Min = 30 // PauseConsecutiveLossesMinutes (Opt: 5,5,240)
  • [=== PAUSE GUARDS ===] Pause_OnLossAmount = true // PauseOnLossAmount (Opt: false, true, true)
  • [=== PAUSE GUARDS ===] Pause_LossAmount = 200.0 // PauseLossAmount ($) (Opt: 50,10,5000)
  • [=== PAUSE GUARDS ===] Pause_LossAmt_Min = 30 // PauseLossAmountMinutes (Opt: 5,5,240)
  • [=== MARGIN / CAPITAL PROTECTION ===] FM_PauseOnLowMargin = true // PauseOpeningNewTradesOnFreeMargin (Opt: false, true, true)
  • [=== MARGIN / CAPITAL PROTECTION ===] FM_MinFreeMargin = 500.0 // FreeMarginRequiredBeforeOpenNewTrade ($) (Opt: 100,50,10000)
  • [=== DIAGNOSTICS & LOGGING ===] Misc_MaxTickAgeSec = 5 // Reject ticks older than (s) (Opt: 1,1,15)
  • [=== DIAGNOSTICS & LOGGING ===] Misc_Debug = true // Enable debug logs (Opt: false, true, true)
  • [=== DIAGNOSTICS & LOGGING ===] Misc_DebugThrottleSec = 5 // Min seconds between status logs (Opt: 1,1,60)
Pseudocode
// Pipsgrowth EX12052 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// True Gaussian Bands mean-reversion EA with Gaussian- weighted MA and standard deviation bands, signal buffer with revalidation, multi-model position sizing, DLP stop manager, optional ATR-SL/TP, and multi-session filtering. 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:
M1H1

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
InpMagicNumber222120522220 + Expert ID (314)
InpSymbol""Symbol override ("" = chart symbol) (Opt: -, -, -)
StrategyTimeframe1Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // StrategyTimeframe (Opt: PERIOD_M1,1,PERIOD_M15)
InpOrderFillingFillAutoOrder filling mode: Auto/FOK/IOC/RETURN (Opt: 0,1,3)
InpAllowBuytrueAllow BUY entries (Opt: false, true, true)
InpAllowSelltrueAllow SELL entries (Opt: false, true, true)
TGB_Period21TGB Period (odd recommended) (Opt: 7,2,61)
TGB_StdDevFactor2.0Bands StdDev Multiplier (Opt: 0.5,0.1,4.0)
TGB_Price1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted)// Applied price (Opt: PRICE_CLOSE,1,PRICE_TYPICAL)
TGB_MinHistoryBars200Minimum bars to operate (Opt: 100,50,2000)
Sb_EnableBuffertrueEnable Signal Buffer (Opt: false, true, true)
Sb_ValidityMinutes3SignalValidityMinutes (Opt: 1,1,60)
Sb_RevalidateDirectiontrueRevalidateDirection before order send (Opt: false, true, true)
Sb_MaxDriftPoints100MaxDriftPoints from anchor (points) (Opt: 0,10,1000)
F_Spread_EnabledtrueEnable Spread Filter (Opt: false, true, true)
F_Spread_UseAbsolutefalseUse Absolute cap (else median×multiplier) (Opt: false, true, true)
F_Spread_AbsCapPoints300Absolute cap (points) (Opt: 50,10,2000)
F_Spread_MedianTicks200Rolling median window (ticks) (Opt: 50,10,2000)
F_Spread_MedianMult3.0Multiplier × rolling median (Opt: 1.0,0.1,5.0)
F_Slip_EnabledtrueEnable Slippage Filter (Opt: false, true, true)
F_Slip_MaxPoints5Max permitted slippage (points) (Opt: 1,1,50)
Ses_EnabledtrueEnable Sessions Filter (Opt: false, true, true)
Ses1_Start_HH02S1 Start Hour (Opt: 0,1,23)
Ses1_Start_MM00S1 Start Minute (Opt: 0,1,59)
Ses1_End_HH11S1 End Hour (Opt: 0,1,23)
Ses1_End_MM00S1 End Minute (Opt: 0,1,59)
Ses1_MontrueS1 Monday (Opt: false, true, true)
Ses1_TuetrueS1 Tuesday (Opt: false, true, true)
Ses1_WedtrueS1 Wednesday (Opt: false, true, true)
Ses1_ThutrueS1 Thursday (Opt: false, true, true)
Ses1_FritrueS1 Friday (Opt: false, true, true)
Ses1_SatfalseS1 Saturday (Opt: false, true, true)
Ses1_SunfalseS1 Sunday (Opt: false, true, true)
Ses2_Start_HH10S2 Start Hour (Opt: 0,1,23)
Ses2_Start_MM00S2 Start Minute (Opt: 0,1,59)
Ses2_End_HH18S2 End Hour (Opt: 0,1,23)
Ses2_End_MM00S2 End Minute (Opt: 0,1,59)
Ses2_MontrueS2 Monday (Opt: false, true, true)
Ses2_TuetrueS2 Tuesday (Opt: false, true, true)
Ses2_WedtrueS2 Wednesday (Opt: false, true, true)
Ses2_ThutrueS2 Thursday (Opt: false, true, true)
Ses2_FritrueS2 Friday (Opt: false, true, true)
Ses2_SatfalseS2 Saturday (Opt: false, true, true)
Ses2_SunfalseS2 Sunday (Opt: false, true, true)
Ses3_Start_HH15S3 Start Hour (Opt: 0,1,23)
Ses3_Start_MM00S3 Start Minute (Opt: 0,1,59)
Ses3_End_HH23S3 End Hour (Opt: 0,1,23)
Ses3_End_MM00S3 End Minute (Opt: 0,1,59)
Ses3_MontrueS3 Monday (Opt: false, true, true)
Ses3_TuetrueS3 Tuesday (Opt: false, true, true)
Ses3_WedtrueS3 Wednesday (Opt: false, true, true)
Ses3_ThutrueS3 Thursday (Opt: false, true, true)
Ses3_FritrueS3 Friday (Opt: false, true, true)
Ses3_SatfalseS3 Saturday (Opt: false, true, true)
Ses3_SunfalseS3 Sunday (Opt: false, true, true)
C_MA_EnabledfalseEnable Trend/MA confirmation (Opt: false, true, true)
C_MA_Period200MA Period (Opt: 50,10,400)
C_MA_MethodMODE_EMAMA Method (Opt: MODE_SMA,1,MODE_LWMA)
C_MA_Price1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted)// MA Price (Opt: PRICE_CLOSE,1,PRICE_TYPICAL)
C_RSI_EnabledfalseEnable RSI confirmation (Opt: false, true, true)
C_RSI_Period14RSI Period (Opt: 5,1,50)
C_RSI_BuyMax60BUY if RSI <= BuyMax (mean-rev bias) (Opt: 40,1,80)
C_RSI_SellMin40SELL if RSI >= SellMin (Opt: 20,1,80)
C_ADX_EnabledfalseEnable ADX confirmation (Opt: false, true, true)
C_ADX_Period14ADX Period (Opt: 7,1,50)
C_ADX_Min15Min ADX to allow entries (Opt: 5,1,40)
Sz_EnableFixedtrueEnable Fixed Lot (Opt: false, true, true)
Sz_FixedLot1.00Fixed Lot (lots) (Opt: 0.01,0.01,5.00)
Sz_EnableBalancefalseEnable Balance-based sizing (Opt: false, true, true)
Sz_BalancePerLot5000.0BalancePerLot ($ per 1.0 lot) (Opt: 1000,500,20000)
Sz_EnableEquityfalseEnable Equity-based sizing (Opt: false, true, true)
Sz_EquityPerLot5000.0EquityPerLot ($ per 1.0 lot) (Opt: 1000,500,20000)
Sz_EnablePercentRiskfalseEnable %Risk sizing (Opt: false, true, true)
Sz_RiskPercent1.0%Risk per trade (of Balance) (Opt: 0.1,0.1,5.0)
Sz_RiskSL_FallbackPoints300Fallback SL distance (points) if no ATR-SL & DLP step (Opt: 50,10,1500)
Sz_EnableATRfalseEnable ATR-based sizing (Opt: false, true, true)
Sz_ATR_Size_Period14ATR period for sizing (Opt: 5,1,50)
Sz_RiskPerATR10.0RiskPerATR ($ per 1×ATR move) (Opt: 1,1,200)
Sz_MinLotClamp0.01User min lot clamp (lots) (Opt: 0.01,0.01,1.0)
Sz_MaxLotClamp50.0User max lot clamp (lots) (Opt: 0.1,0.1,100.0)
SL_EnableDLPtrueEnable Dynamic Lock Profit (primary) (Opt: false, true, true)
SL_LockEveryXPoints200DLP: lock step size (points) (Opt: 50,10,1500)
SL_LockMinusBuffer40DLP: minus buffer (points) (Opt: 0,5,200)
SL_EnableATRfalseEnable ATR-SL (safer-of vs DLP) (Opt: false, true, true)
SL_ATR_Period14ATR period for SL (Opt: 5,1,50)
SL_ATR_Multiplier2.0ATR Multiplier for SL (Opt: 0.5,0.1,6.0)
TP_EnableATRfalseEnable ATR-based TP close (Opt: false, true, true)
TP_ATR_Period14ATR period for TP (Opt: 5,1,50)
TP_ATR_Multiplier2.0ATR Multiplier for TP (Opt: 0.5,0.1,6.0)
Add_MaxOpenTrades5MaxOpenTrades total (Opt: 1,1,20)
Add_OnlyProfitabletrueAllowOnlyProfitableAdditions (Opt: false, true, true)
Add_MinProfitPts5.0MinProfitPerTradeToAdd (points) (Opt: 2,1,200)
Pause_OnLossCounttruePauseOnConsecutiveLosses (Opt: false, true, true)
Pause_LossCount3PauseConsecutiveLossesCount (Opt: 2,1,10)
Pause_LossCount_Min30PauseConsecutiveLossesMinutes (Opt: 5,5,240)
Pause_OnLossAmounttruePauseOnLossAmount (Opt: false, true, true)
Pause_LossAmount200.0PauseLossAmount ($) (Opt: 50,10,5000)
Pause_LossAmt_Min30PauseLossAmountMinutes (Opt: 5,5,240)
FM_PauseOnLowMargintruePauseOpeningNewTradesOnFreeMargin (Opt: false, true, true)
FM_MinFreeMargin500.0FreeMarginRequiredBeforeOpenNewTrade ($) (Opt: 100,50,10000)
Misc_MaxTickAgeSec5Reject ticks older than (s) (Opt: 1,1,15)
Misc_DebugtrueEnable debug logs (Opt: false, true, true)
Misc_DebugThrottleSec5Min seconds between status logs (Opt: 1,1,60)
Source Code (.mq5)Open Source
Pipsgrowth_com_EX12052.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX12052 EX18 — True Gaussian Bands mean-reversion EA with DLP and multi-model sizing, full 12-layer stack."
#include <Trade\Trade.mqh>

//------------------------------------ Utility Macros ------------------------------------
#define  ARR_SIZE(a)      (int(ArraySize(a)))
#define  CLAMP(x,a,b)     (MathMax((a), MathMin((x),(b))))
#define  EPS              1e-12

//------------------------------------ Enumerations --------------------------------------
enum ENUM_FillOpt { FillAuto=0, FillFOK=1, FillIOC=2, FillRETURN=3 };

//--------------------------------------------------------------------------------------------------
// 1. CORE IDENTIFIERS & EXECUTION CONTEXT
//--------------------------------------------------------------------------------------------------
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_StrategyTimeframe = PERIOD_H1;
ENUM_APPLIED_PRICE g_TGB_Price = PRICE_CLOSE;
ENUM_APPLIED_PRICE g_C_MA_Price = PRICE_CLOSE;
input group "=== CORE IDENTIFIERS & EXECUTION CONTEXT ==="
input long           InpMagicNumber        = 22212052;                  // 2220 + Expert ID (314)
input string         InpTradeComment = "Psgrowth.com Expert_12052";
input string         InpSymbol             = "";         // Symbol override ("" = chart symbol) (Opt: -, -, -)
input int StrategyTimeframe = 1; // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1)  // StrategyTimeframe (Opt: PERIOD_M1,1,PERIOD_M15)
input ENUM_FillOpt   InpOrderFilling       = FillAuto;   // Order filling mode: Auto/FOK/IOC/RETURN (Opt: 0,1,3)
input bool           InpAllowBuy           = true;       // Allow BUY entries (Opt: false, true, true)
input bool           InpAllowSell          = true;       // Allow SELL entries (Opt: false, true, true)

//--------------------------------------------------------------------------------------------------
// 2. ENTRY SIGNAL (TRUE GAUSSIAN BANDS)

Full source code available on download

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

Tags:ex12052multiindicatorconfluencepipsgrowthfreemt5xauusd

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