P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX12050 MultiIndicatorConfluence

MT5 Expert Advisor (Open Source) · XAUUSD · M5

Pipsgrowth.com EX12050 XAUUSD_M5_VGB_MultiStrategy_EA — Volatility Gaussian Bands multi-strategy, full 12-layer stack.

Overview

Pipsgrowth EX12050 is a four-engine confluence framework that fires trades from any of four independent breakout or trend signals — Gaussian Bands (default-on), Hull MA, Supertrend, or MA Cross — with the rest disabled. The default personality is a Gaussian Bands breakout: a 10-period EMA treated as a Gaussian midline sits between two ATR-spaced bands at 0.85× the current 14-period ATR. The CheckGaussianStrategy() function looks for a true three-bar breakout: the current bar's close must close above the upper band (or below the lower band for shorts) while the prior two bars both sat on the wrong side of that band, the Gaussian midline must be sloping in the trade direction, the bar must overshoot the band by at least 0.3 pips of break distance, and the candle must qualify as a strong candle with a body-to-range ratio of 0.6 or more. With Hull MA, Supertrend, or MA Cross enabled via their boolean toggles, GenerateSignal() walks the same GenerateSignal() ladder in priority order until one engine returns a non-empty signal; each engine is otherwise self-contained and reads from the same MarketData cache.

Every signal then passes through three confirmation gates. A higher-timeframe EMA(50) trend filter on TrendFilterTF=PERIOD_H4 demands that the primary close sit on the correct side of the EMA for the trade direction, so a long signal against a 4-hour downtrend is rejected. A 14-period RSI confirms the bar is not exhausted: a buy needs RSI on bar 0 below the 70 overbought level with the bar-1 RSI strictly lower (rising momentum), a sell mirrors against the 30 oversold level. A global EnableTradeDirection enum further restricts to long-only, short-only, or both. Only after all three confirmations does ExecuteOrder() fire, tagging the comment string as either "Initial" (the first position) or "Additional" (any subsequent pyramid) so post-trade analysis can separate entries.

Sizing runs through CalculateLotSize() against the account balance at RiskPerTrade=1.0% default. The function divides risk-currency by the SL distance expressed in pips and the per-pip tick value, floors to the symbol's volume step, and clamps to the broker's min/max lot envelope. A fixed 0.01-lot fallback applies when RiskPerTrade=0. The AutoTuneFilters() routine rewrites the effective Gaussian parameters, the minimum-ATR gate, and the break distance every tick when EnableAutoTuneStrategyFilters=true: it computes a volatility ratio (current ATR versus 10-period average ATR), reads the current server hour and weekday, checks the spread regime, and combines six adjustment factors — high-volatility band, low-volatility band, London-open and NY-open hours, Asian-session hours, Monday and Friday afternoons, high-spread regimes, and strong-trend detection — to scale the base min-ATR and break-distance values up or down. The base-pip-factor is 0.0001 on a sub-3-point spread and 0.01 on a wider spread, so the floor adapts to the broker's quoting precision rather than being hard-coded.

Stop loss is sized by CalculateStopLoss() as the larger of two values: 1.5× the current ATR(14), or a 2000-point fixed floor — on a 5-digit XAUUSD broker that fixed floor is 20.0 price. Take profit is the symmetric FixedTP_Points=3000 (30.0 price on the same broker), which produces a 1.5:1 reward-to-risk ratio whenever the ATR-derived SL is at or below the fixed floor; when ATR volatility pushes the SL past 20.0, the ratio tightens to 1.5R on a 30.0 TP against a wider dynamic SL. Once a position is open, ManagePositionWithCache() runs three layers of trade management in strict order per tick: first a trailing stop that pulls the SL toward bid/ask by 1.5× ATR whenever that move is profitable and below price, then a breakeven step that snaps the SL to entry once the trade has 1.5× ATR of unrealized profit, and finally a stepped dynamic profit lock that advances the SL by 20 pips for every additional 20 pips of unrealized profit, minus a 5-pip buffer, never loosening. The dynamic lock only ratchets in the favorable direction.

Exits also include an RSI early-exit branch. With RSI_UseEarlyExit=true, ShouldExitOnRSI() computes a buy-side exit threshold of RSI_Overbought(70) + (RSI_ExtremeLevelBuy(80) − 70) × (RSI_ExitSensitivity(1.5) / RSI_ExitSensitivityDivisor(3.0)) = 75, and a sell-side threshold of 25, requiring that threshold be exceeded on two consecutive bars (RSI_ExitConfirmationPeriods=2). When RSI_UseTrendForExit=true (default) the exit also needs RSI on the most recent bar to be falling for longs or rising for shorts, so the exit confirms momentum has rolled. Optional RSI divergence and an emergency stop at EmergencyExitPips=50 (close on a 50-pip adverse excursion) extend the same early-exit pathway.

Three configurable trading windows govern when entries are allowed: Session 1 from 01:00 to 05:00, Session 2 from 08:00 to 12:00, Session 3 from 16:00 to 20:00 server time. Each session is independently togglable. IsWithinTradingSession() returns true if the current server minute falls inside any active window. Friday-trading controls add a 2-hour cut-off before the broker's stated close (default Friday 22:00) that blocks new entries and optionally force-closes all open positions. A drawdown cap in CheckMaxDrawdown() halts trading entirely if unrealized loss pushes equity more than MaxDrawdownPercent=15% below balance, and a 60-second minimum between trades prevents thrash. A 4.0-pip spread filter rejects new entries when the bid/ask spread inflates, and AllowNewTradeOnSameCandle=false blocks a second entry on the same bar as the first one.

Order execution is selectable between market, stop, and limit placement through OrderExecutionType. In the default market mode trade.Buy() and trade.Sell() are called directly with comment tags. In stop mode, pending stop orders are placed at entry plus the larger of PendingOrderPoints=50 or one ATR; in limit mode, the mirror. The ManagePendingOrders() function then walks the pending book each tick and re-prices stops that have drifted within 2 pips of current price, deletes pending orders whose age has passed PendingOrderExpirationSeconds=43200 (12 hours), cancels them on an adverse move beyond ExpirationPips × PendingOrderPipExpiryThresholdMultiplier, and removes them when an opposite-direction signal appears (when ExpireOnOppositeSignal=true). All close and modify paths run through three-retry helpers — TryClose_EX12050, TryClosePartial_EX12050, and TryModify_EX12050 — that catch REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED retcodes and sleep 200ms (close) or 100ms (modify) before re-trying, then give up. The strategy runs on M5 by default with a 1.5R target, four toggleable signal engines, and 133 input parameters that mostly expand or contract the confirmation and management layers rather than the signal logic itself.

Strategy Deep Dive

On every tick the EA loads its MarketData cache once — pulling bid/ask, spread, the current bar's open/high/low/close, ATR(14), the Gaussian EMA, the H4 trend EMA(50), the 14-period RSI for the last 5 bars, and conditionally the Hull MA, inline Supertrend, and fast/slow MA-cross — then runs AutoTuneFilters() to recompute the effective min-ATR, break distance, and Gaussian band multiplier for the current volatility regime, hour-of-day, weekday, and spread. The no-trade gate then short-circuits if ATR is below the effective floor, if drawdown has crossed 15%, if Friday-cutoff is within 2 hours, if the server time is outside any of the three enabled trading sessions, if the symbol is at the max-open-trades cap, if the spread exceeds 4 pips, or if a fresh trade would land on the same bar as an existing position. GenerateSignal() walks the four strategy engines in priority order (Gaussian, Hull, Supertrend, MA Cross) until one returns a non-empty signal; the raw signal then passes through the H4 EMA trend filter, the RSI momentum filter, and the global trade-direction toggle before ExecuteOrder() fires with the risk-percent-sized lot, the ATR-or-fixed SL, and the fixed 3000-point TP, tagging the comment as "Initial" or "Additional" based on whether a position is already open. After execution, ManagePositionWithCache() runs on every open ticket each tick, layering the trailing stop, breakeven, dynamic profit lock, and RSI early-exit logic in strict order, while ManagePendingOrders() (only in stop/limit mode) walks the pending book to re-price, expire, or cancel based on the configured thresholds. A Comment() block at the bottom of the chart prints the EA version, balance, equity, open count, spread, last signal, and last trade time so the operator can monitor state without opening the toolbox.

Entry Signal

EX12050 fires a long (or short) signal when one of four independent engines returns a non-empty signal: Gaussian Bands (default) requires a three-bar close above (below) the ATR-spaced 0.85× band, a Gaussian midline slope in the trade direction, at least 0.3 pips of break distance, and a strong-candle body-to-range ratio of 0.6. Hull MA, Supertrend (computed inline over 200 bars), and 9/21 EMA cross can be enabled as alternative or additional engines. Every raw signal must also pass a 50-period H4 EMA trend filter, a 14-period RSI momentum check (RSI<70 and rising for buys, RSI>30 and falling for sells), and a global trade-direction toggle.

Exit Signal

Exits run through a four-layer stack in ManagePositionWithCache() per open ticket. Layer 1 is an ATR-trailing stop that pulls the SL toward price by 1.5× ATR; layer 2 is a breakeven step that snaps SL to entry once profit reaches 1.5× ATR; layer 3 is a stepped dynamic profit lock that ratchets the SL by 20 pips per 20 pips of unrealized profit minus a 5-pip buffer, never loosening. Layer 4 is an RSI early-exit branch: with RSI_UseEarlyExit=true, a buy closes when RSI exceeds the computed threshold of 75 for two consecutive bars and is falling, with optional RSI divergence and a 50-pip adverse-excursion emergency stop extending the same path.

Stop Loss

Stop loss is sized in CalculateStopLoss() as the larger of 1.5× the current ATR(14) and a FixedSLDistancePoints=2000 point fixed floor — on a 5-digit XAUUSD broker the floor is 20.0 price below ask for longs (or above bid for shorts). The trailing stop then pulls that same 1.5× ATR distance toward price on each profitable tick, and a breakeven step snaps SL to entry once the trade has 1.5× ATR of unrealized profit before the dynamic profit lock ratchets it further. An emergency 50-pip adverse-excursion exit (EmergencyExitPips) acts as a secondary stop when the RSI early-exit branch is enabled.

Take Profit

Take profit is a fixed FixedTP_Points=3000 (30.0 price on a 5-digit XAUUSD broker) set in CalculateTakeProfit() at entry and never modified by the trailing or dynamic-lock layers — the trailing stop and dynamic lock only ever tighten the SL side, so the TP stays where it was placed. With the default 1.5× ATR multiplier and the 20.0-price fixed floor, the static RR at entry is 1.5:1 (30.0 TP against a 20.0 SL); when ATR volatility pushes the dynamic SL above 20.0 the same 30.0 TP gives a tighter ratio.

Best For

Best suited for XAUUSD on the M5 timeframe with a minimum account balance of $100 and the default 1.0% risk-per-trade setting (fixed 0.01-lot fallback when risk is off). The 1.5R default and the 4.0-pip spread filter demand a low-spread ECN or RAW-spread broker with reliable execution; the ATR(14) auto-tune assumes sub-3-point spread behavior in its base-pip-factor calculation, and the four-engine confluence framework works best during the configured London and New York overlap windows (Session 2 08:00-12:00 and Session 3 16:00-20:00 server time). M5-H1 is the practical operating range — below M5 the Gaussian Bands' 0.3-pip break distance stops triggering on noise, above H1 the session windows compress the daily signal count sharply. The Risk=MEDIUM label reflects the 1.0% per-trade risk, the 15% drawdown kill-switch, and the optional RSI early-exit and emergency stop on top of the ATR-based SL.

Strategy Logic

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

Family: MultiIndicatorConfluence Magic: 22212050 Version: 2.00

BRIEF: Volatility Gaussian Bands multi-strategy EA combining Gaussian filter breakouts, Hull MA, Supertrend, MA-Cross and RSI filter/exit logic with auto-tuned ATR filters, dynamic profit locking, drawdown control and session management. Full 12-layer stack: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • CanOpenNewTrade()
  • CloseAllPositions()
  • ManageOpenPositions()
  • AllPositionsInDirectionHaveMinPipsProfit()
  • ManagePendingOrders()
  • GetPipSize()
  • PipsToPrice()
  • PriceToPips()
  • NormalizePrice()
  • CalculateLotSize()
  • GetPositionProfitInPips()
  • GetPositionOpenBarByTicket()
  • ...and 44 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (133 total across 21 groups):

  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_12050" // Trade Comment
  • [=== Strategy Core Settings ===] EnableAutoTuneStrategyFilters = true // Enable/Disable automatic tuning of key strategy parameters (e.g., ATR, Break Distance) based on market conditions.
  • [=== Strategy Core Settings ===] Timeframe = 0 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Trading timeframe for primary chart
  • [=== Strategy Core Settings ===] TrendFilterTF = 6 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher timeframe for trend filter
  • [=== Strategy Core Settings ===] TrendFilterEMAPeriod = 50 // Period for the Exponential Moving Average (EMA) used as a trend filter on the Higher Timeframe (HTF).
  • [=== Strategy Core Settings ===] ATR_Period = 14 // ATR Period for calculating Average True Range, used in SL, Trailing Stop, Breakeven, and auto-tuning.
  • [=== Strategy Core Settings ===] MinATRValue = 0.0003 // Minimum ATR value to consider trading (e.g. 0.0003 for EURUSD)
  • [=== Strategy Core Settings ===] TrendStrengthLookback = 10 // Bars for Recent Trend Strength Calculation
  • [=== Strategy Core Settings ===] EnableTradeDirection = TRADE_BOTH // Enable buy, sell, or both directions globally
  • [=== Strategy Core Settings ===] UseGaussianBandsStrategy = true // Enable/Disable Gaussian Bands Strategy
  • [=== Gaussian Bands General Settings ===] Gauss_FilterPeriod = 10 // Period for the Gaussian filter (implemented as EMA).
  • [=== Gaussian Bands General Settings ===] Gauss_DistanceMultiplier = 0.85 // Multiplier for ATR to determine the distance of the Gaussian bands from the central filter line.
  • [=== Gaussian Bands General Settings ===] Gauss_StrongCandleBodyRatio = 0.6 // Strong candle body/range ratio (0.0-1.0)
  • [=== Gaussian Bands General Settings ===] Gauss_MinBreakDistancePips = 0.3 // Minimum price/band break distance in pips
  • [=== Gaussian Bands General Settings ===] UseHullMAStrategy = false // Enable/Disable Hull MA Strategy
  • [=== Hull MA General Settings ===] Hull_Period = 20 // Hull MA period
  • [=== Hull MA General Settings ===] Hull_Shift = 0 // Hull MA shift
  • [=== Hull MA General Settings ===] Hull_Method = MODE_LWMA // Hull MA method (typically LWMA for HMA)
  • [=== Hull MA General Settings ===] Hull_AppliedPrice = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Hull MA applied price
  • [=== Hull MA General Settings ===] UseSupertrendStrategy = false // Enable/Disable Supertrend Strategy
  • [=== Supertrend General Settings ===] Supertrend_ATR_Period = 10 // Supertrend ATR period
  • [=== Supertrend General Settings ===] Supertrend_Factor = 3.0 // Supertrend ATR factor/multiplier
  • [=== Supertrend General Settings ===] Supertrend_AppliedPrice = 5 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Supertrend calculation price (PRICE_MEDIAN recommended)
  • [=== Supertrend General Settings ===] UseMACrossStrategy = false // Enable/Disable MA Cross Strategy
  • [=== MA Cross General Settings ===] MACross_Fast_Period = 9 // Fast MA period
  • [=== MA Cross General Settings ===] MACross_Fast_Shift = 0 // Fast MA shift
  • [=== MA Cross General Settings ===] MACross_Fast_Method = MODE_EMA // Fast MA method
  • [=== MA Cross General Settings ===] MACross_Fast_AppliedPrice = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Fast MA applied price
  • [=== MA Cross General Settings ===] MACross_Slow_Period = 21 // Slow MA period
  • [=== MA Cross General Settings ===] MACross_Slow_Shift = 0 // Slow MA shift
  • [=== MA Cross General Settings ===] MACross_Slow_Method = MODE_EMA // Slow MA method
  • [=== MA Cross General Settings ===] MACross_Slow_AppliedPrice = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Slow MA applied price
  • [=== MA Cross General Settings ===] UseRSIFilter = true // Enable/Disable RSI as a filter or strategy component
  • [=== RSI General Settings ===] RSI_Period = 14 // RSI Period
  • [=== RSI General Settings ===] RSI_AppliedPrice = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // RSI Applied Price
  • [=== RSI General Settings ===] RSI_Overbought = 70 // RSI Overbought Level (e.g., 70)
  • [=== RSI General Settings ===] RSI_Oversold = 30 // RSI Oversold Level (e.g., 30)
  • [=== RSI Exit Settings ===] RSI_UseEarlyExit = true // Use RSI for early exit (both Buy/Sell)
  • [=== RSI Exit Settings ===] RSI_ExtremeLevelBuy = 80 // RSI extreme level for exiting buys
  • [=== RSI Exit Settings ===] RSI_ExtremeLevelSell = 20 // RSI extreme level for exiting sells
  • [=== RSI Exit Settings ===] RSI_UseDivergenceExit = false // Use RSI divergence for exit
  • [=== RSI Exit Settings ===] RSI_DivergenceLookback = 8 // Bars to look back for divergence
  • [=== RSI Exit Settings ===] RSI_ExitConfirmationPeriods = 2 // Periods to confirm RSI exit
  • [=== RSI Exit Settings ===] RSI_UseTrendForExit = true // Use RSI trend for exit
  • [=== RSI Exit Settings ===] RSI_ExitSensitivity = 1.5 // RSI sensitivity multiplier for exit
  • [=== RSI Exit Settings ===] RSI_ExitSensitivityDivisor = 3.0 // Divisor for RSI Exit Sensitivity Calc
  • [=== Trade Management ===] Lots = 0.01 // Fixed lot size (fallback if Risk=0)
  • [=== Trade Management ===] RiskPerTrade = 1.0 // Risk percentage of account balance per trade (e.g., 1.0 for 1%). If 0, Fixed LotSize is used.
  • [=== Trade Management ===] MaxOpenTrades = 1 // Maximum allowed open trades for this symbol and magic number.
  • [=== Trade Management ===] MagicNumber = 22212050 // Unique identifier for EA trades
  • [=== Trade Management ===] AllowNewTradeOnSameCandle = false // If false, prevents opening any new trade on the same candle
  • [=== Stop Loss & Take Profit ===] ATR_MultiplierSL = 1.5 // ATR multiplier used to calculate Stop Loss distance. SL distance = ATR * ATR_MultiplierSL.
  • [=== Stop Loss & Take Profit ===] FixedSLDistancePoints = 2000 // Fixed Stop Loss distance in points; actual SL is Max(ATR-based SL, this value).
  • [=== Stop Loss & Take Profit ===] FixedTP_Points = 3000 // Take Profit distance in points from the entry price.
  • [=== Stop Loss & Take Profit ===] UseTrailingStop = true // Enable/Disable trailing stop loss. Trails by ATR * ATR_MultiplierSL.
  • [=== Stop Loss & Take Profit ===] UseBreakeven = true // Enable/Disable breakeven function. Moves SL to entry price when trade is in profit by ATR * ATR_MultiplierSL.
  • [=== Profit Lock ===] EnableDynamicLockProfit = true // Enable/Disable dynamic profit locking. Adjusts SL to lock in profits as the trade moves favorably.
  • [=== Profit Lock ===] LockProfitEvery_X_Pips = 20.0 // Pips in profit to trigger the next step of profit locking.
  • [=== Profit Lock ===] LockProfitBufferPips = 5.0 // Buffer in pips. New SL is set to (Achieved Profit Steps * LockProfitEvery_X_Pips) - LockProfitBufferPips from entry.
  • [=== Risk Management ===] MaxDrawdownPercent = 15.0 // Maximum account drawdown percentage. If current drawdown exceeds this, trading is halted.
  • [=== Risk Management ===] EmergencyExitPips = 50.0 // If a trade loses this many pips, it triggers an emergency exit condition (checked within RSI exit logic).
  • [=== Session 1 ===] EnableSession1 = true // Enable Session 1
  • [=== Session 1 ===] Session1StartHour = 1 // Session 1 Start Hour (0-23)
  • [=== Session 1 ===] Session1StartMinute = 0 // Session 1 Start Minute
  • [=== Session 1 ===] Session1EndHour = 5 // Session 1 End Hour
  • [=== Session 1 ===] Session1EndMinute = 0 // Session 1 End Minute
  • [=== Session 2 ===] EnableSession2 = true // Enable Session 2
  • [=== Session 2 ===] Session2StartHour = 8 // Session 2 Start Hour
  • [=== Session 2 ===] Session2StartMinute = 0 // Session 2 Start Minute
  • [=== Session 2 ===] Session2EndHour = 12 // Session 2 End Hour
  • [=== Session 2 ===] Session2EndMinute = 0 // Session 2 End Minute
  • [=== Session 3 ===] EnableSession3 = true // Enable Session 3
  • [=== Session 3 ===] Session3StartHour = 16 // Session 3 Start Hour
  • [=== Session 3 ===] Session3StartMinute = 0 // Session 3 Start Minute
  • [=== Session 3 ===] Session3EndHour = 20 // Session 3 End Hour
  • [=== Session 3 ===] Session3EndMinute = 0 // Session 3 End Minute
  • [=== Friday Trading Controls ===] CloseTrades2HoursBeforeFriday = true // If true, close all open positions 2 hours before the specified FridayCloseHour/Minute.
  • [=== Friday Trading Controls ===] AvoidTrading2HoursBeforeFriday = true // If true, prevent opening new trades 2 hours before the specified FridayCloseHour/Minute.
  • [=== Friday Trading Controls ===] FridayCloseHour = 22 // Hour when broker closes on Friday (0-23)
  • [=== Friday Trading Controls ===] FridayCloseMinute = 0 // Minute when broker closes on Friday (0-59)
  • [=== Order Execution ===] OrderExpirationType = ORDER_TIME_GTC // Order expiration type
  • [=== Order Execution ===] OrderExecutionType = MARKET_ORDERS // Type of orders to use: Market, Stop, or Limit orders.
  • [=== Order Execution ===] PendingOrderPoints = 50 // Distance in points from the current price to place pending (Stop/Limit) orders.
  • [=== Order Execution ===] PendingOrderExpirationSeconds = 43200 // Expiration time in seconds for pending orders. 0 means no time expiration.
  • [=== Order Execution ===] PendingOrderPipExpiryThresholdMultiplier = 1.5 // Multiplier for 'ExpirationPips' to determine pending order cancellation due to adverse price movement.
  • [=== Order Execution ===] ExpireByPips = false // Enable/Disable expiration of pending orders if price moves adversely by 'ExpirationPips' * 'PendingOrderPipExpiryThresholdMultiplier'.
  • [=== Order Execution ===] ExpirationPips = 50 // Adverse price movement in pips that (when multiplied by threshold) triggers pending order cancellation, if ExpireByPips is true.
  • [=== Order Execution ===] ExpireOnOppositeSignal = false // Enable/Disable cancellation of pending orders if a new, opposite trading signal is generated.
  • [=== Holding Time Settings ===] UseMinHoldTime = true // Enable Min Holding Time
  • [=== Holding Time Settings ===] MinHoldTimeProfitMinutes = 3 // Minimum holding time in minutes for a profitable position before it can be closed by EA logic (not SL/TP hit).
  • [=== Holding Time Settings ===] MinHoldTimeLossMinutes = 1 // Minimum holding time in minutes for a losing position before it can be closed by EA logic (not SL/TP hit).
  • [=== Holding Time Settings ===] BlockCloseOnSameCandle = true // If true, prevents EA logic from closing a position on the same bar/candle it was opened on.
  • [=== Holding Time Settings ===] UseMinTimeBetweenTrades = true // Minimum time between trades
  • [=== Holding Time Settings ===] MinSecondsBetweenTrades = 60 // Minimum time in seconds that must pass after a trade is closed before a new trade can be opened.
  • [=== Spread Filter Settings ===] EnableSpreadFilter = true // Enable/Disable spread filter. Prevents opening new trades if current spread exceeds MaxAllowedSpreadPips.
  • [=== Spread Filter Settings ===] MaxAllowedSpreadPips = 4.0 // Maximum allowed spread in pips for opening new trades (if EnableSpreadFilter is true).
  • [=== Spread Filter Settings ===] EnableSpreadFilterPending = true // Enable/Disable spread filter for pending orders. Deletes pending orders if spread exceeds MaxAllowedSpreadPips at OnTick.
  • [=== Auto-Tuning Parameters ===] AutoTune_SpreadThresholdForPipFactor = 3.0 // Spread in points threshold to select basePipFactor for auto-tuning.
  • [=== Auto-Tuning Parameters ===] AutoTune_BaseMinATRFactor = 3.0 // Factor for Base Min ATR
  • [=== Auto-Tuning Parameters ===] AutoTune_VolatilityThreshold = 1.5 // Volatility Ratio threshold
  • [=== Auto-Tuning Parameters ===] AutoTune_HighVol_ATR_Factor = 1.2 // ATR factor during high volatility
  • [=== Auto-Tuning Parameters ===] AutoTune_HighVol_Break_Factor = 1.1 // Break factor during high volatility
  • [=== Auto-Tuning Parameters ===] AutoTune_LowVol_ATR_Factor = 0.8 // ATR factor during low volatility
  • [=== Auto-Tuning Parameters ===] AutoTune_LowVol_Break_Factor = 0.9 // Break factor during low volatility
  • [=== Auto-Tuning Parameters ===] AutoTune_AsianSession_ATR_Factor = 0.9 // ATR factor during Asian session hours for auto-tuning.
  • [=== Auto-Tuning Parameters ===] AutoTune_AsianSession_Break_Factor = 0.95 // Break factor during Asian session hours for auto-tuning.
  • [=== Auto-Tuning Parameters ===] AutoTune_DayOfWeek_ATR_Factor = 0.9 // ATR factor for specific days (e.g., Monday)
  • [=== Auto-Tuning Parameters ===] AutoTune_DayOfWeek_Break_Factor = 0.95 // Break factor for specific days
  • [=== Auto-Tuning Parameters ===] AutoTune_HighSpreadThresholdPoints = 1.5 // Spread in points threshold to apply high spread auto-tune adjustments.
  • [=== Auto-Tuning Parameters ===] AutoTune_HighSpread_ATR_Factor = 1.1 // ATR factor during high spread
  • [=== Auto-Tuning Parameters ===] AutoTune_HighSpread_Break_Factor = 1.05 // Break factor during high spread
  • [=== Auto-Tuning Parameters ===] AutoTune_TrendStrengthThreshold = 0.7 // Threshold for strong trend detection
  • [=== Auto-Tuning Parameters ===] AutoTune_Trend_Break_Factor = 1.05 // Break factor during strong trend
  • [=== Additional Trades Settings ===] AllowAdditionalTrades = true // Enable/disable additional trades
  • [=== Additional Trades Settings ===] AddTradesOnlyIfAllProfitable = true // Only allow if all open positions are in profit
  • [=== Additional Trades Settings ===] AddTradesOnlyIfProfitLocked = true // Only allow if all open positions have SL locking profit
  • [=== Additional Trades Settings ===] MinPipsProfitForEachTradeToAdd = 10.0 // Minimum pips profit for each open trade to allow addition
  • [=== Additional Trades Settings ===] EnableTrendFilterForAdditions = true // Require trend filter for additional trades
  • [=== Additional Trades Settings ===] MinTrendStrengthForAdd = 0.3 // Minimum trend strength for additional trades
  • [=== Additional Trades Settings ===] EnableVolatilityFilterForAdditions = true // Require ATR/volatility filter for additional trades
  • [=== Additional Trades Settings ===] MinATRForAdd = 0.0003 // Minimum ATR for additional trades
  • [=== Additional Trades Settings ===] BlockAddOnTrendChange = true // Block additional trades if recent trend change detected
  • [=== Additional Trades Settings ===] RequireMomentumForAdd = true // Require momentum confirmation for additional trades
  • [=== Additional Trades Settings ===] MinRSIForAdd = 55.0 // Minimum RSI for buy/additional trades
  • [=== Additional Trades Settings ===] MaxRSIForAdd = 45.0 // Maximum RSI for sell/additional trades
  • [=== Additional Trades Settings ===] BlockAddIfOverextended = true // Block if price is far from MA/bands
  • [=== Additional Trades Settings ===] MaxDistanceFromMAForAdd = 2.0 // Max distance (in ATR) from MA/band for additional trades
  • [=== Additional Trades Settings ===] EnableSpreadFilterAdditions = true // Spread filter for additional trades
  • [=== Additional Trades Settings ===] MaxAllowedSpreadPipsAdd = 4.0 // Max allowed spread for additional trades
  • [=== Additional Trades Settings ===] BlockAddOnNews = false // Block additional trades during news (requires news filter implementation)
  • [=== Additional Trades Settings ===] BlockAddOnLowLiquidity = true // Block additional trades during low-liquidity hours
  • [=== Additional Trades Settings ===] MaxAddTradesPerCandle = 1 // Max additional trades per candle
  • [=== Additional Trades Settings ===] MaxDrawdownPercentAdd = 15.0 // Max drawdown for additional trades
Pseudocode
// Pipsgrowth EX12050 MultiIndicatorConfluence — Execution Flow (from source analysis)
// Family: MultiIndicatorConfluence
// Volatility Gaussian Bands multi-strategy EA combining Gaussian filter breakouts, Hull MA, Supertrend, MA-Cross and RSI filter/exit logic with auto-tuned ATR filters, dynamic profit locking, drawdown control and session management. 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

Optimized Brokers:
ExnessIC Markets
Optimized Symbols:
XAUUSD
Optimized Timeframes:
M5

How to Install This EA on MT5

  1. 1Download the .mq5 file using the button above
  2. 2Open MetaTrader 5 on your computer
  3. 3Click File → Open Data Folder in the top menu
  4. 4Navigate to MQL5 → Experts and paste the .mq5 file there
  5. 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
  6. 6Drag the EA onto a chart matching the recommended timeframe
  7. 7Configure parameters according to the table on this page
  8. 8Enable Allow Algo Trading and click OK

EA Parameters

ParameterDefaultDescription
InpTradeComment"Psgrowth.com Expert_12050"Trade Comment
EnableAutoTuneStrategyFilterstrueEnable/Disable automatic tuning of key strategy parameters (e.g., ATR, Break Distance) based on market conditions.
Timeframe0Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Trading timeframe for primary chart
TrendFilterTF6Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher timeframe for trend filter
TrendFilterEMAPeriod50Period for the Exponential Moving Average (EMA) used as a trend filter on the Higher Timeframe (HTF).
ATR_Period14ATR Period for calculating Average True Range, used in SL, Trailing Stop, Breakeven, and auto-tuning.
MinATRValue0.0003Minimum ATR value to consider trading (e.g. 0.0003 for EURUSD)
TrendStrengthLookback10Bars for Recent Trend Strength Calculation
EnableTradeDirectionTRADE_BOTHEnable buy, sell, or both directions globally
UseGaussianBandsStrategytrueEnable/Disable Gaussian Bands Strategy
Gauss_FilterPeriod10Period for the Gaussian filter (implemented as EMA).
Gauss_DistanceMultiplier0.85Multiplier for ATR to determine the distance of the Gaussian bands from the central filter line.
Gauss_StrongCandleBodyRatio0.6Strong candle body/range ratio (0.0-1.0)
Gauss_MinBreakDistancePips0.3Minimum price/band break distance in pips
UseHullMAStrategyfalseEnable/Disable Hull MA Strategy
Hull_Period20Hull MA period
Hull_Shift0Hull MA shift
Hull_MethodMODE_LWMAHull MA method (typically LWMA for HMA)
Hull_AppliedPrice1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Hull MA applied price
UseSupertrendStrategyfalseEnable/Disable Supertrend Strategy
Supertrend_ATR_Period10Supertrend ATR period
Supertrend_Factor3.0Supertrend ATR factor/multiplier
Supertrend_AppliedPrice5Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Supertrend calculation price (PRICE_MEDIAN recommended)
UseMACrossStrategyfalseEnable/Disable MA Cross Strategy
MACross_Fast_Period9Fast MA period
MACross_Fast_Shift0Fast MA shift
MACross_Fast_MethodMODE_EMAFast MA method
MACross_Fast_AppliedPrice1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Fast MA applied price
MACross_Slow_Period21Slow MA period
MACross_Slow_Shift0Slow MA shift
MACross_Slow_MethodMODE_EMASlow MA method
MACross_Slow_AppliedPrice1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Slow MA applied price
UseRSIFiltertrueEnable/Disable RSI as a filter or strategy component
RSI_Period14RSI Period
RSI_AppliedPrice1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // RSI Applied Price
RSI_Overbought70RSI Overbought Level (e.g., 70)
RSI_Oversold30RSI Oversold Level (e.g., 30)
RSI_UseEarlyExittrueUse RSI for early exit (both Buy/Sell)
RSI_ExtremeLevelBuy80RSI extreme level for exiting buys
RSI_ExtremeLevelSell20RSI extreme level for exiting sells
RSI_UseDivergenceExitfalseUse RSI divergence for exit
RSI_DivergenceLookback8Bars to look back for divergence
RSI_ExitConfirmationPeriods2Periods to confirm RSI exit
RSI_UseTrendForExittrueUse RSI trend for exit
RSI_ExitSensitivity1.5RSI sensitivity multiplier for exit
RSI_ExitSensitivityDivisor3.0Divisor for RSI Exit Sensitivity Calc
Lots0.01Fixed lot size (fallback if Risk=0)
RiskPerTrade1.0Risk percentage of account balance per trade (e.g., 1.0 for 1%). If 0, Fixed LotSize is used.
MaxOpenTrades1Maximum allowed open trades for this symbol and magic number.
MagicNumber22212050Unique identifier for EA trades
AllowNewTradeOnSameCandlefalseIf false, prevents opening any new trade on the same candle
ATR_MultiplierSL1.5ATR multiplier used to calculate Stop Loss distance. SL distance = ATR * ATR_MultiplierSL.
FixedSLDistancePoints2000Fixed Stop Loss distance in points; actual SL is Max(ATR-based SL, this value).
FixedTP_Points3000Take Profit distance in points from the entry price.
UseTrailingStoptrueEnable/Disable trailing stop loss. Trails by ATR * ATR_MultiplierSL.
UseBreakeventrueEnable/Disable breakeven function. Moves SL to entry price when trade is in profit by ATR * ATR_MultiplierSL.
EnableDynamicLockProfittrueEnable/Disable dynamic profit locking. Adjusts SL to lock in profits as the trade moves favorably.
LockProfitEvery_X_Pips20.0Pips in profit to trigger the next step of profit locking.
LockProfitBufferPips5.0Buffer in pips. New SL is set to (Achieved Profit Steps * LockProfitEvery_X_Pips) - LockProfitBufferPips from entry.
MaxDrawdownPercent15.0Maximum account drawdown percentage. If current drawdown exceeds this, trading is halted.
EmergencyExitPips50.0If a trade loses this many pips, it triggers an emergency exit condition (checked within RSI exit logic).
EnableSession1trueEnable Session 1
Session1StartHour1Session 1 Start Hour (0-23)
Session1StartMinute0Session 1 Start Minute
Session1EndHour5Session 1 End Hour
Session1EndMinute0Session 1 End Minute
EnableSession2trueEnable Session 2
Session2StartHour8Session 2 Start Hour
Session2StartMinute0Session 2 Start Minute
Session2EndHour12Session 2 End Hour
Session2EndMinute0Session 2 End Minute
EnableSession3trueEnable Session 3
Session3StartHour16Session 3 Start Hour
Session3StartMinute0Session 3 Start Minute
Session3EndHour20Session 3 End Hour
Session3EndMinute0Session 3 End Minute
CloseTrades2HoursBeforeFridaytrueIf true, close all open positions 2 hours before the specified FridayCloseHour/Minute.
AvoidTrading2HoursBeforeFridaytrueIf true, prevent opening new trades 2 hours before the specified FridayCloseHour/Minute.
FridayCloseHour22Hour when broker closes on Friday (0-23)
FridayCloseMinute0Minute when broker closes on Friday (0-59)
OrderExpirationTypeORDER_TIME_GTCOrder expiration type
OrderExecutionTypeMARKET_ORDERSType of orders to use: Market, Stop, or Limit orders.
PendingOrderPoints50Distance in points from the current price to place pending (Stop/Limit) orders.
PendingOrderExpirationSeconds43200Expiration time in seconds for pending orders. 0 means no time expiration.
PendingOrderPipExpiryThresholdMultiplier1.5Multiplier for 'ExpirationPips' to determine pending order cancellation due to adverse price movement.
ExpireByPipsfalseEnable/Disable expiration of pending orders if price moves adversely by 'ExpirationPips' * 'PendingOrderPipExpiryThresholdMultiplier'.
ExpirationPips50Adverse price movement in pips that (when multiplied by threshold) triggers pending order cancellation, if ExpireByPips is true.
ExpireOnOppositeSignalfalseEnable/Disable cancellation of pending orders if a new, opposite trading signal is generated.
UseMinHoldTimetrueEnable Min Holding Time
MinHoldTimeProfitMinutes3Minimum holding time in minutes for a profitable position before it can be closed by EA logic (not SL/TP hit).
MinHoldTimeLossMinutes1Minimum holding time in minutes for a losing position before it can be closed by EA logic (not SL/TP hit).
BlockCloseOnSameCandletrueIf true, prevents EA logic from closing a position on the same bar/candle it was opened on.
UseMinTimeBetweenTradestrueMinimum time between trades
MinSecondsBetweenTrades60Minimum time in seconds that must pass after a trade is closed before a new trade can be opened.
EnableSpreadFiltertrueEnable/Disable spread filter. Prevents opening new trades if current spread exceeds MaxAllowedSpreadPips.
MaxAllowedSpreadPips4.0Maximum allowed spread in pips for opening new trades (if EnableSpreadFilter is true).
EnableSpreadFilterPendingtrueEnable/Disable spread filter for pending orders. Deletes pending orders if spread exceeds MaxAllowedSpreadPips at OnTick.
AutoTune_SpreadThresholdForPipFactor3.0Spread in points threshold to select basePipFactor for auto-tuning.
AutoTune_BaseMinATRFactor3.0Factor for Base Min ATR
AutoTune_VolatilityThreshold1.5Volatility Ratio threshold
AutoTune_HighVol_ATR_Factor1.2ATR factor during high volatility
AutoTune_HighVol_Break_Factor1.1Break factor during high volatility
AutoTune_LowVol_ATR_Factor0.8ATR factor during low volatility
AutoTune_LowVol_Break_Factor0.9Break factor during low volatility
AutoTune_AsianSession_ATR_Factor0.9ATR factor during Asian session hours for auto-tuning.
AutoTune_AsianSession_Break_Factor0.95Break factor during Asian session hours for auto-tuning.
AutoTune_DayOfWeek_ATR_Factor0.9ATR factor for specific days (e.g., Monday)
AutoTune_DayOfWeek_Break_Factor0.95Break factor for specific days
AutoTune_HighSpreadThresholdPoints1.5Spread in points threshold to apply high spread auto-tune adjustments.
AutoTune_HighSpread_ATR_Factor1.1ATR factor during high spread
AutoTune_HighSpread_Break_Factor1.05Break factor during high spread
AutoTune_TrendStrengthThreshold0.7Threshold for strong trend detection
AutoTune_Trend_Break_Factor1.05Break factor during strong trend
AllowAdditionalTradestrueEnable/disable additional trades
AddTradesOnlyIfAllProfitabletrueOnly allow if all open positions are in profit
AddTradesOnlyIfProfitLockedtrueOnly allow if all open positions have SL locking profit
MinPipsProfitForEachTradeToAdd10.0Minimum pips profit for each open trade to allow addition
EnableTrendFilterForAdditionstrueRequire trend filter for additional trades
MinTrendStrengthForAdd0.3Minimum trend strength for additional trades
EnableVolatilityFilterForAdditionstrueRequire ATR/volatility filter for additional trades
MinATRForAdd0.0003Minimum ATR for additional trades
BlockAddOnTrendChangetrueBlock additional trades if recent trend change detected
RequireMomentumForAddtrueRequire momentum confirmation for additional trades
MinRSIForAdd55.0Minimum RSI for buy/additional trades
MaxRSIForAdd45.0Maximum RSI for sell/additional trades
BlockAddIfOverextendedtrueBlock if price is far from MA/bands
MaxDistanceFromMAForAdd2.0Max distance (in ATR) from MA/band for additional trades
EnableSpreadFilterAdditionstrueSpread filter for additional trades
MaxAllowedSpreadPipsAdd4.0Max allowed spread for additional trades
BlockAddOnNewsfalseBlock additional trades during news (requires news filter implementation)
BlockAddOnLowLiquiditytrueBlock additional trades during low-liquidity hours
MaxAddTradesPerCandle1Max additional trades per candle
MaxDrawdownPercentAdd15.0Max drawdown for additional trades
Source Code (.mq5)Open Source
Pipsgrowth_com_EX12050.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX12050 XAUUSD_M5_VGB_MultiStrategy_EA — Volatility Gaussian Bands multi-strategy, full 12-layer stack."
#define EA_NAME "Volatility Gaussian Bands Pro"
#define EA_VERSION "2.2.0"
#include <Trade/Trade.mqh> // Changed backslash to forward slash
CTrade trade;

// Place this at the top of the file with other global definitions
enum ENUM_SIGNAL_TYPE {
   SIGNAL_NONE,
   SIGNAL_BUY,
   SIGNAL_SELL
};

// Function prototypes
bool CanOpenNewTrade();
void CloseAllPositions();
void ManageOpenPositions();
bool AllPositionsInDirectionHaveMinPipsProfit(string symbol, ENUM_POSITION_TYPE tradeDirection, double minPipsProfitRequired);
void ManagePendingOrders();
double GetPipSize(string symbol = NULL);
double PipsToPrice(double pips, string symbol = NULL);
double PriceToPips(double priceValue, double symbol = NULL); // Corrected: double symbol to string symbol
double NormalizePrice(double price, string symbol = NULL);
double CalculateLotSize(double riskPercent, double slDistance);
double GetPositionProfitInPips(long type, double entryPrice, double currentBid, double currentAsk);
int GetPositionOpenBarByTicket(ulong ticket);
double CalculateTakeProfit(ENUM_POSITION_TYPE type, double entryPrice);
string ErrorDescription(int error_code);
ENUM_SIGNAL_TYPE GenerateSignal();
bool ExecuteOrder(ENUM_SIGNAL_TYPE signalType, bool closeOpposite = true);
bool CheckRSIDivergence(ulong ticket);
double CalculateRecentTrendStrength();
void AutoTuneFilters(double &minATR, double &breakDistance, double &bandMult);
bool CheckMaxDrawdown();
bool ConfirmRSIExit(ulong ticket);
int CountOpenTrades(string symbol, int maxCount = 0);
void UpdateDashboard();
bool ClosePositionWithComment(ulong ticket, string closeComment, string closeReason, double profit);

//+------------------------------------------------------------------+
//| Feature toggle structure                                         |
//+------------------------------------------------------------------+
struct FeatureToggles {
   // Core features
   bool UseTrailingStop;
   bool UseBreakeven;
   bool UseDynamicLockProfit;
   bool UseRSIExit;
   bool UseRSIDivergence;
   bool UseEmergencyExit;
   
   // Load from input parameters
   void LoadFromInputs() {
      UseTrailingStop = ::UseTrailingStop;
      UseBreakeven = ::UseBreakeven;
      UseDynamicLockProfit = EnableDynamicLockProfit;

Full source code available on download

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

Tags:ex12050multiindicatorconfluencepipsgrowthfreemt5xauusd

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