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 FOK → IOC → RETURN 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 FOK → IOC → RETURN 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.
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.
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 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.
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.
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
MT5indicators
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):
- [===
COREIDENTIFIERS&EXECUTIONCONTEXT===]InpMagicNumber=22212052// 2220 + ExpertID(314) - [===
COREIDENTIFIERS&EXECUTIONCONTEXT===]InpSymbol= "" // Symbol override ("" = chart symbol) (Opt: -, -, -) - [===
COREIDENTIFIERS&EXECUTIONCONTEXT===]StrategyTimeframe= 1 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) //StrategyTimeframe(Opt:PERIOD_M1,1,PERIOD_M15) - [===
COREIDENTIFIERS&EXECUTIONCONTEXT===]InpOrderFilling=FillAuto// Order filling mode: Auto/FOK/IOC/RETURN(Opt: 0,1,3) - [===
COREIDENTIFIERS&EXECUTIONCONTEXT===]InpAllowBuy=true// AllowBUYentries (Opt:false,true,true) - [===
COREIDENTIFIERS&EXECUTIONCONTEXT===]InpAllowSell=true// AllowSELLentries (Opt:false,true,true) - [===
ENTRYSIGNAL(TRUEGAUSSIANBANDS) ===] TGB_Period = 21 //TGBPeriod(odd recommended) (Opt: 7,2,61) - [===
ENTRYSIGNAL(TRUEGAUSSIANBANDS) ===] TGB_StdDevFactor =2.0// BandsStdDevMultiplier(Opt:0.5,0.1,4.0) - [===
ENTRYSIGNAL(TRUEGAUSSIANBANDS) ===] 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) - [===
ENTRYSIGNAL(TRUEGAUSSIANBANDS) ===] TGB_MinHistoryBars = 200 // Minimum bars to operate (Opt: 100,50,2000) - [===
SIGNALBUFFER&REVALIDATION===] Sb_EnableBuffer =true// Enable SignalBuffer(Opt:false,true,true) - [===
SIGNALBUFFER&REVALIDATION===] Sb_ValidityMinutes = 3 //SignalValidityMinutes(Opt: 1,1,60) - [===
SIGNALBUFFER&REVALIDATION===] Sb_RevalidateDirection =true//RevalidateDirectionbefore order send (Opt:false,true,true) - [===
SIGNALBUFFER&REVALIDATION===] Sb_MaxDriftPoints = 100 //MaxDriftPointsfrom anchor (points) (Opt: 0,10,1000) - [===
FILTERS:SPREAD&SLIPPAGE===] F_Spread_Enabled =true// Enable SpreadFilter(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 SlippageFilter(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 SessionsFilter(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses1_Start_HH = 02 // S1 StartHour(Opt: 0,1,23) - [===
FILTER:SESSIONS===] Ses1_Start_MM = 00 // S1 StartMinute(Opt: 0,1,59) - [===
FILTER:SESSIONS===] Ses1_End_HH = 11 // S1 EndHour(Opt: 0,1,23) - [===
FILTER:SESSIONS===] Ses1_End_MM = 00 // S1 EndMinute(Opt: 0,1,59) - [===
FILTER:SESSIONS===] Ses1_Mon =true// S1Monday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses1_Tue =true// S1Tuesday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses1_Wed =true// S1Wednesday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses1_Thu =true// S1Thursday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses1_Fri =true// S1Friday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses1_Sat =false// S1Saturday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses1_Sun =false// S1Sunday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses2_Start_HH = 10 // S2 StartHour(Opt: 0,1,23) - [===
FILTER:SESSIONS===] Ses2_Start_MM = 00 // S2 StartMinute(Opt: 0,1,59) - [===
FILTER:SESSIONS===] Ses2_End_HH = 18 // S2 EndHour(Opt: 0,1,23) - [===
FILTER:SESSIONS===] Ses2_End_MM = 00 // S2 EndMinute(Opt: 0,1,59) - [===
FILTER:SESSIONS===] Ses2_Mon =true// S2Monday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses2_Tue =true// S2Tuesday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses2_Wed =true// S2Wednesday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses2_Thu =true// S2Thursday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses2_Fri =true// S2Friday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses2_Sat =false// S2Saturday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses2_Sun =false// S2Sunday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses3_Start_HH = 15 // S3 StartHour(Opt: 0,1,23) - [===
FILTER:SESSIONS===] Ses3_Start_MM = 00 // S3 StartMinute(Opt: 0,1,59) - [===
FILTER:SESSIONS===] Ses3_End_HH = 23 // S3 EndHour(Opt: 0,1,23) - [===
FILTER:SESSIONS===] Ses3_End_MM = 00 // S3 EndMinute(Opt: 0,1,59) - [===
FILTER:SESSIONS===] Ses3_Mon =true// S3Monday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses3_Tue =true// S3Tuesday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses3_Wed =true// S3Wednesday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses3_Thu =true// S3Thursday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses3_Fri =true// S3Friday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses3_Sat =false// S3Saturday(Opt:false,true,true) - [===
FILTER:SESSIONS===] Ses3_Sun =false// S3Sunday(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 // MAPeriod(Opt: 50,10,400) - [===
CONFIRMATIONS(TREND/MA,RSI,ADX) ===] C_MA_Method =MODE_EMA// MAMethod(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)// MAPrice(Opt:PRICE_CLOSE,1,PRICE_TYPICAL) - [===
CONFIRMATIONS(TREND/MA,RSI,ADX) ===] C_RSI_Enabled =false// EnableRSIconfirmation (Opt:false,true,true) - [===
CONFIRMATIONS(TREND/MA,RSI,ADX) ===] C_RSI_Period = 14 //RSIPeriod(Opt: 5,1,50) - [===
CONFIRMATIONS(TREND/MA,RSI,ADX) ===] C_RSI_BuyMax = 60 //BUYifRSI<=BuyMax(mean-rev bias) (Opt: 40,1,80) - [===
CONFIRMATIONS(TREND/MA,RSI,ADX) ===] C_RSI_SellMin = 40 //SELLifRSI>=SellMin(Opt: 20,1,80) - [===
CONFIRMATIONS(TREND/MA,RSI,ADX) ===] C_ADX_Enabled =false// EnableADXconfirmation (Opt:false,true,true) - [===
CONFIRMATIONS(TREND/MA,RSI,ADX) ===] C_ADX_Period = 14 //ADXPeriod(Opt: 7,1,50) - [===
CONFIRMATIONS(TREND/MA,RSI,ADX) ===] C_ADX_Min = 15 // MinADXto allow entries (Opt: 5,1,40) - [===
RISK&POSITIONSIZING===] Sz_EnableFixed =true// Enable FixedLot(Opt:false,true,true) - [===
RISK&POSITIONSIZING===] Sz_FixedLot =1.00// FixedLot(lots) (Opt:0.01,0.01,5.00) - [===
RISK&POSITIONSIZING===] Sz_EnableBalance =false// Enable Balance-based sizing (Opt:false,true,true) - [===
RISK&POSITIONSIZING===] Sz_BalancePerLot =5000.0//BalancePerLot($ per1.0lot) (Opt: 1000,500,20000) - [===
RISK&POSITIONSIZING===] Sz_EnableEquity =false// Enable Equity-based sizing (Opt:false,true,true) - [===
RISK&POSITIONSIZING===] Sz_EquityPerLot =5000.0//EquityPerLot($ per1.0lot) (Opt: 1000,500,20000) - [===
RISK&POSITIONSIZING===] Sz_EnablePercentRisk =false// Enable %Risk sizing (Opt:false,true,true) - [===
RISK&POSITIONSIZING===] Sz_RiskPercent =1.0// %Risk per trade (of Balance) (Opt:0.1,0.1,5.0) - [===
RISK&POSITIONSIZING===] Sz_RiskSL_FallbackPoints = 300 // Fallback SL distance (points) if noATR-SL &DLPstep (Opt: 50,10,1500) - [===
RISK&POSITIONSIZING===] Sz_EnableATR =false// EnableATR-based sizing (Opt:false,true,true) - [===
RISK&POSITIONSIZING===] Sz_ATR_Size_Period = 14 //ATRperiod for sizing (Opt: 5,1,50) - [===
RISK&POSITIONSIZING===] Sz_RiskPerATR =10.0//RiskPerATR($ per 1×ATRmove) (Opt: 1,1,200) - [===
RISK&POSITIONSIZING===] Sz_MinLotClamp =0.01// User min lot clamp (lots) (Opt:0.01,0.01,1.0) - [===
RISK&POSITIONSIZING===] Sz_MaxLotClamp =50.0// User max lot clamp (lots) (Opt:0.1,0.1,100.0) - [===
STOPLOSSMANAGEMENT===] SL_EnableDLP =true// Enable Dynamic LockProfit(primary) (Opt:false,true,true) - [===
STOPLOSSMANAGEMENT===] SL_LockEveryXPoints = 200 //DLP: lock step size (points) (Opt: 50,10,1500) - [===
STOPLOSSMANAGEMENT===] SL_LockMinusBuffer = 40 //DLP: minus buffer (points) (Opt: 0,5,200) - [===
STOPLOSSMANAGEMENT===] SL_EnableATR =false// EnableATR-SL(safer-of vsDLP) (Opt:false,true,true) - [===
STOPLOSSMANAGEMENT===] SL_ATR_Period = 14 //ATRperiod forSL(Opt: 5,1,50) - [===
STOPLOSSMANAGEMENT===] SL_ATR_Multiplier =2.0//ATRMultiplier forSL(Opt:0.5,0.1,6.0) - [===
TAKEPROFITMANAGEMENT===] TP_EnableATR =false// EnableATR-based TP close (Opt:false,true,true) - [===
TAKEPROFITMANAGEMENT===] TP_ATR_Period = 14 //ATRperiod forTP(Opt: 5,1,50) - [===
TAKEPROFITMANAGEMENT===] TP_ATR_Multiplier =2.0//ATRMultiplier forTP(Opt:0.5,0.1,6.0) - [===
ADDITIONALTRADESPOLICY===] Add_MaxOpenTrades = 5 //MaxOpenTradestotal (Opt: 1,1,20) - [===
ADDITIONALTRADESPOLICY===] Add_OnlyProfitable =true//AllowOnlyProfitableAdditions(Opt:false,true,true) - [===
ADDITIONALTRADESPOLICY===] Add_MinProfitPts =5.0//MinProfitPerTradeToAdd(points) (Opt: 2,1,200) - [===
PAUSEGUARDS===] Pause_OnLossCount =true//PauseOnConsecutiveLosses(Opt:false,true,true) - [===
PAUSEGUARDS===] Pause_LossCount = 3 //PauseConsecutiveLossesCount(Opt: 2,1,10) - [===
PAUSEGUARDS===] Pause_LossCount_Min = 30 //PauseConsecutiveLossesMinutes(Opt: 5,5,240) - [===
PAUSEGUARDS===] Pause_OnLossAmount =true//PauseOnLossAmount(Opt:false,true,true) - [===
PAUSEGUARDS===] Pause_LossAmount =200.0//PauseLossAmount($) (Opt: 50,10,5000) - [===
PAUSEGUARDS===] Pause_LossAmt_Min = 30 //PauseLossAmountMinutes(Opt: 5,5,240) - [===
MARGIN/CAPITALPROTECTION===] FM_PauseOnLowMargin =true//PauseOpeningNewTradesOnFreeMargin(Opt:false,true,true) - [===
MARGIN/CAPITALPROTECTION===] 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)
// 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
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 |
|---|---|---|
| InpMagicNumber | 22212052 | 2220 + Expert ID (314) |
| InpSymbol | "" | Symbol override ("" = chart symbol) (Opt: -, -, -) |
| StrategyTimeframe | 1 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // StrategyTimeframe (Opt: PERIOD_M1,1,PERIOD_M15) |
| InpOrderFilling | FillAuto | Order filling mode: Auto/FOK/IOC/RETURN (Opt: 0,1,3) |
| InpAllowBuy | true | Allow BUY entries (Opt: false, true, true) |
| InpAllowSell | true | Allow SELL entries (Opt: false, true, true) |
| TGB_Period | 21 | TGB Period (odd recommended) (Opt: 7,2,61) |
| TGB_StdDevFactor | 2.0 | Bands StdDev Multiplier (Opt: 0.5,0.1,4.0) |
| 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) |
| TGB_MinHistoryBars | 200 | Minimum bars to operate (Opt: 100,50,2000) |
| Sb_EnableBuffer | true | Enable Signal Buffer (Opt: false, true, true) |
| Sb_ValidityMinutes | 3 | SignalValidityMinutes (Opt: 1,1,60) |
| Sb_RevalidateDirection | true | RevalidateDirection before order send (Opt: false, true, true) |
| Sb_MaxDriftPoints | 100 | MaxDriftPoints from anchor (points) (Opt: 0,10,1000) |
| F_Spread_Enabled | true | Enable Spread Filter (Opt: false, true, true) |
| F_Spread_UseAbsolute | false | Use Absolute cap (else median×multiplier) (Opt: false, true, true) |
| F_Spread_AbsCapPoints | 300 | Absolute cap (points) (Opt: 50,10,2000) |
| F_Spread_MedianTicks | 200 | Rolling median window (ticks) (Opt: 50,10,2000) |
| F_Spread_MedianMult | 3.0 | Multiplier × rolling median (Opt: 1.0,0.1,5.0) |
| F_Slip_Enabled | true | Enable Slippage Filter (Opt: false, true, true) |
| F_Slip_MaxPoints | 5 | Max permitted slippage (points) (Opt: 1,1,50) |
| Ses_Enabled | true | Enable Sessions Filter (Opt: false, true, true) |
| Ses1_Start_HH | 02 | S1 Start Hour (Opt: 0,1,23) |
| Ses1_Start_MM | 00 | S1 Start Minute (Opt: 0,1,59) |
| Ses1_End_HH | 11 | S1 End Hour (Opt: 0,1,23) |
| Ses1_End_MM | 00 | S1 End Minute (Opt: 0,1,59) |
| Ses1_Mon | true | S1 Monday (Opt: false, true, true) |
| Ses1_Tue | true | S1 Tuesday (Opt: false, true, true) |
| Ses1_Wed | true | S1 Wednesday (Opt: false, true, true) |
| Ses1_Thu | true | S1 Thursday (Opt: false, true, true) |
| Ses1_Fri | true | S1 Friday (Opt: false, true, true) |
| Ses1_Sat | false | S1 Saturday (Opt: false, true, true) |
| Ses1_Sun | false | S1 Sunday (Opt: false, true, true) |
| Ses2_Start_HH | 10 | S2 Start Hour (Opt: 0,1,23) |
| Ses2_Start_MM | 00 | S2 Start Minute (Opt: 0,1,59) |
| Ses2_End_HH | 18 | S2 End Hour (Opt: 0,1,23) |
| Ses2_End_MM | 00 | S2 End Minute (Opt: 0,1,59) |
| Ses2_Mon | true | S2 Monday (Opt: false, true, true) |
| Ses2_Tue | true | S2 Tuesday (Opt: false, true, true) |
| Ses2_Wed | true | S2 Wednesday (Opt: false, true, true) |
| Ses2_Thu | true | S2 Thursday (Opt: false, true, true) |
| Ses2_Fri | true | S2 Friday (Opt: false, true, true) |
| Ses2_Sat | false | S2 Saturday (Opt: false, true, true) |
| Ses2_Sun | false | S2 Sunday (Opt: false, true, true) |
| Ses3_Start_HH | 15 | S3 Start Hour (Opt: 0,1,23) |
| Ses3_Start_MM | 00 | S3 Start Minute (Opt: 0,1,59) |
| Ses3_End_HH | 23 | S3 End Hour (Opt: 0,1,23) |
| Ses3_End_MM | 00 | S3 End Minute (Opt: 0,1,59) |
| Ses3_Mon | true | S3 Monday (Opt: false, true, true) |
| Ses3_Tue | true | S3 Tuesday (Opt: false, true, true) |
| Ses3_Wed | true | S3 Wednesday (Opt: false, true, true) |
| Ses3_Thu | true | S3 Thursday (Opt: false, true, true) |
| Ses3_Fri | true | S3 Friday (Opt: false, true, true) |
| Ses3_Sat | false | S3 Saturday (Opt: false, true, true) |
| Ses3_Sun | false | S3 Sunday (Opt: false, true, true) |
| C_MA_Enabled | false | Enable Trend/MA confirmation (Opt: false, true, true) |
| C_MA_Period | 200 | MA Period (Opt: 50,10,400) |
| C_MA_Method | MODE_EMA | MA Method (Opt: MODE_SMA,1,MODE_LWMA) |
| 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) |
| C_RSI_Enabled | false | Enable RSI confirmation (Opt: false, true, true) |
| C_RSI_Period | 14 | RSI Period (Opt: 5,1,50) |
| C_RSI_BuyMax | 60 | BUY if RSI <= BuyMax (mean-rev bias) (Opt: 40,1,80) |
| C_RSI_SellMin | 40 | SELL if RSI >= SellMin (Opt: 20,1,80) |
| C_ADX_Enabled | false | Enable ADX confirmation (Opt: false, true, true) |
| C_ADX_Period | 14 | ADX Period (Opt: 7,1,50) |
| C_ADX_Min | 15 | Min ADX to allow entries (Opt: 5,1,40) |
| Sz_EnableFixed | true | Enable Fixed Lot (Opt: false, true, true) |
| Sz_FixedLot | 1.00 | Fixed Lot (lots) (Opt: 0.01,0.01,5.00) |
| Sz_EnableBalance | false | Enable Balance-based sizing (Opt: false, true, true) |
| Sz_BalancePerLot | 5000.0 | BalancePerLot ($ per 1.0 lot) (Opt: 1000,500,20000) |
| Sz_EnableEquity | false | Enable Equity-based sizing (Opt: false, true, true) |
| Sz_EquityPerLot | 5000.0 | EquityPerLot ($ per 1.0 lot) (Opt: 1000,500,20000) |
| Sz_EnablePercentRisk | false | Enable %Risk sizing (Opt: false, true, true) |
| Sz_RiskPercent | 1.0 | %Risk per trade (of Balance) (Opt: 0.1,0.1,5.0) |
| Sz_RiskSL_FallbackPoints | 300 | Fallback SL distance (points) if no ATR-SL & DLP step (Opt: 50,10,1500) |
| Sz_EnableATR | false | Enable ATR-based sizing (Opt: false, true, true) |
| Sz_ATR_Size_Period | 14 | ATR period for sizing (Opt: 5,1,50) |
| Sz_RiskPerATR | 10.0 | RiskPerATR ($ per 1×ATR move) (Opt: 1,1,200) |
| Sz_MinLotClamp | 0.01 | User min lot clamp (lots) (Opt: 0.01,0.01,1.0) |
| Sz_MaxLotClamp | 50.0 | User max lot clamp (lots) (Opt: 0.1,0.1,100.0) |
| SL_EnableDLP | true | Enable Dynamic Lock Profit (primary) (Opt: false, true, true) |
| SL_LockEveryXPoints | 200 | DLP: lock step size (points) (Opt: 50,10,1500) |
| SL_LockMinusBuffer | 40 | DLP: minus buffer (points) (Opt: 0,5,200) |
| SL_EnableATR | false | Enable ATR-SL (safer-of vs DLP) (Opt: false, true, true) |
| SL_ATR_Period | 14 | ATR period for SL (Opt: 5,1,50) |
| SL_ATR_Multiplier | 2.0 | ATR Multiplier for SL (Opt: 0.5,0.1,6.0) |
| TP_EnableATR | false | Enable ATR-based TP close (Opt: false, true, true) |
| TP_ATR_Period | 14 | ATR period for TP (Opt: 5,1,50) |
| TP_ATR_Multiplier | 2.0 | ATR Multiplier for TP (Opt: 0.5,0.1,6.0) |
| Add_MaxOpenTrades | 5 | MaxOpenTrades total (Opt: 1,1,20) |
| Add_OnlyProfitable | true | AllowOnlyProfitableAdditions (Opt: false, true, true) |
| Add_MinProfitPts | 5.0 | MinProfitPerTradeToAdd (points) (Opt: 2,1,200) |
| Pause_OnLossCount | true | PauseOnConsecutiveLosses (Opt: false, true, true) |
| Pause_LossCount | 3 | PauseConsecutiveLossesCount (Opt: 2,1,10) |
| Pause_LossCount_Min | 30 | PauseConsecutiveLossesMinutes (Opt: 5,5,240) |
| Pause_OnLossAmount | true | PauseOnLossAmount (Opt: false, true, true) |
| Pause_LossAmount | 200.0 | PauseLossAmount ($) (Opt: 50,10,5000) |
| Pause_LossAmt_Min | 30 | PauseLossAmountMinutes (Opt: 5,5,240) |
| FM_PauseOnLowMargin | true | PauseOpeningNewTradesOnFreeMargin (Opt: false, true, true) |
| FM_MinFreeMargin | 500.0 | FreeMarginRequiredBeforeOpenNewTrade ($) (Opt: 100,50,10000) |
| Misc_MaxTickAgeSec | 5 | Reject ticks older than (s) (Opt: 1,1,15) |
| Misc_Debug | true | Enable debug logs (Opt: false, true, true) |
| Misc_DebugThrottleSec | 5 | Min seconds between status logs (Opt: 1,1,60) |
#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.
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.