Pipsgrowth EX17013 Volatility
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX17013 gaussian2 — Gaussian2 Adaptive EA with multi-indicator auto-tuning and HTF filters, full 12-layer stack.
Overview
Pipsgrowth EX17013 is a self-tuning multi-indicator EA built around a Gaussian-smoothed parameter engine. The defining idea is that the indicator inputs themselves move with the market rather than staying frozen: ADX period, MACD fast/slow/signal, RSI period, and the ADX/RSI thresholds are all pushed through an adaptive loop, then the historical parameter stream is weighted with a Gaussian kernel (window 20 by default, sigma = window / GaussianSigmaDivisor) so the EA never snaps abruptly to a new regime. The result is a five-classic-indicator stack — ADX(14), MACD(12,26,9), RSI(14), ATR(14) and a 20/50 SMA pair — whose periods and thresholds drift gently inside their Min/Max envelopes as conditions shift.
The adaptive loop has two flavors selectable by EnableMarketBasedTuning. In its basic form UpdateAdaptiveParameters() reads currentVolatility against a 20-bar ATR average and the current regime (Ranging/Trending/Volatile, set by AnalyzeMarketConditions()) and multiplies each parameter by a volatilityFactor (1.2 high, 0.9 low) and a trendFactor (0.85 trending, 1.15 ranging). When EnableMarketBasedTuning is on, UpdateMarketBasedParameters() goes further: it walks a 50-trade rolling history (TuningPeriod), computes a weighted win rate using CalculatePerformanceMetrics(), and pushes parameters tighter or looser depending on whether currentWinRate sits below MinWinRate (60% default) or above MinWinRate + GoodPerformanceWinDelta (15%). In every case the values are clamped to their Min/Max bands and then pushed through GaussianSmooth() to settle.
Signal strength on each bar is the sum of three weighted votes. The ADX leg gives ADX_StrongWeight (1.5) when ADX > adaptiveADXThreshold with +DI dominant and rising, ADX_ModerateWeight (1.0) when the threshold is hit with ADX_ModerateFactor (0.8) scaling, and ADX_WeakWeight (0.5) when only ADX_WeakFactor (0.6) clears. The MACD leg adds MACD_CrossWeight (1.0) on a main/signal cross and MACD_MomentumWeight (0.5) on direction. The RSI leg adds RSI_OversoldWeight or RSI_OverboughtWeight (1.0) at the adaptive levels and RSI_MomentumWeight (0.5) on a 1.2× band touch. A TrendingMarketBonus (+0.5) lands when marketCondition==1, and a LowVolatilityBonus (+0.5) lands when ATR drops below LowVolatilityPoints (100) on a ranging day. UseFlexibleSignals=true drops the threshold one notch (MinSignalStrength=2 becomes 1, etc.) so partial-confluence bars still trigger.
The risk stack is conservative. CalculateLotSizeByRisk() takes RiskPercent (2.0% default), divides by the dynamic StopLossPips × pipValue, and refuses the trade outright if the margin level is below 200% or the resulting lot is below the broker minimum. UseFixedLot=true short-circuits to FixedLotSize (0.10). Equity protection adds a second layer: CheckRiskManagement() halts the EA if daily loss hits MaxDailyLossPercent (10%), if drawdown from the high-water mark hits MaxDrawdownPercent (20%), or if margin level slips below MinMarginLevel (200%).
SL and TP are dynamic, not static. StopLossPips (20) and TakeProfitPips (15) get multiplied by VolatileSLMultiplier (1.3) / VolatileTPMultiplier (1.5) on volatile bars, by TrendingSLMultiplier (0.8) / TrendingTPMultiplier (1.2) on trending bars, and by StrongSignalSLMultiplier (0.9) / StrongSignalTPMultiplier (1.2) when the entry's signalStrength clears StrongSignalThreshold (3). The base 20/15 default gives a 1:0.75 risk-reward, but the multipliers push the live ratio anywhere from 1:0.96 (trending strong) to 1:1.15 (volatile). The opener records the strength in the comment suffix, e.g. "Psgrowth.com Expert_17013_S3".
Exits are a four-track stack. ManagePositions() runs the trailing SL once profit clears TrailingStopStartPips (10), with TrailingStopStepPips (2) increments, and the trailing TP once profit clears TrailingTPStartPips (5) with TrailingTPStepPips (1) — both forward-only (no ratchet backward). ManageProfitBasedClosing() runs every ProfitManagerCheckSeconds (10) and closes the position if profit clears MinProfitToClose ($1), if a profitable trade is older than ProfitableCloseAfterMinutes (30) — provided CloseOnlyProfitable allows it — or if a losing trade breaches MaxLossToClose ($3) or ages past UnprofitableCloseAfterMinutes (60). CloseOnOppositeSignal=true reverses the book on a flip (long flipped to short signal and vice versa). Each fill is logged via OnTradeTransaction() and merged into the 100-slot tradeHistory circular buffer that UpdateMarketBasedParameters() later reads.
A no-trade gate runs through CanEnterTrade() on every entry. IsCooldownSatisfied() blocks re-entry for PostExitCooldownMinutes (10) after a close (off by default). IsHigherTimeframeAligned() confirms a higher-TF MA cross above HigherTFTrendThresholdPips (8) when EnableHigherTFConfirmation=true. IsVolatilityExpanded() requires current ATR ≥ average × ATRExpansionMultiplier (1.2) when EnableATRExpansionFilter=true. IsTrendStrengthSufficient() requires latestTrendStrengthPips ≥ MinTrendStrengthBuffer (8) and latestAdxSlope ≥ MinAdxSlope (0.5). IsHigherTimeframeIndicatorsAligned() lets you toggle individual HTF guards for ADX, MACD, RSI and ATR via EnableHTF_ADXFilter/MACD/RSI/ATR. Every guard is independently switchable, so a user can run the EA with no extra filters, with trend-strength alone, or with the full HTF quartet.
Indicator hygiene is also tighter than most EAs. UpdateIndicatorCache() reads ADX, MACD, RSI buffers only on a new bar, then the 3-bar arrays are reused by CheckBuySignalStrength() and CheckSellSignalStrength() so the loop is not hammering CopyBuffer. SafeCircularIndex() protects the tradeHistory write path against rollover, SafeDivision() blocks divide-by-zero, and ValidateInputParameters() refuses to start the EA unless all 100+ input values sit in their declared ranges (e.g. MACD_FastEMA must be < MACD_SlowEMA, RSI_Oversold < RSI_Overbought, SessionStartHour != SessionEndHour). RefreshIndicators() releases and recreates the handles whenever an adaptive parameter drift crosses the RefreshChangeThreshold (1.0 for each indicator), so the signal votes always read from handles that match the current period set.
A practical backtest outline: on XAUUSD M5 the EA's regime classifier keeps it selective in quiet sessions (mostly Ranging, low signal strength, fewer entries) and aggressive in clean trends (Trending, full 3-weight ADX vote, 20/15 SL/TP with Trending multipliers tightening SL to 16 pips and extending TP to 18 pips). The auto-tuner takes ~10 trades (TuningPeriod × 0.2) before its win-rate feedback loop is allowed to start pulling thresholds, so expect the first hour of a backtest to follow the base inputs literally. Magic is 22217013, comment prefix is "Psgrowth.com Expert_17013".
Strategy Deep Dive
On every tick the EA refreshes its 3-bar indicator cache only on a new bar, then UpdateAdaptiveParameters() or UpdateMarketBasedParameters() recomputes ADX period, MACD fast/slow/signal, RSI period, and ADX/RSI thresholds using currentVolatility, the regime state (Ranging/Trending/Volatile) and a 50-trade win-rate rolling window, clamps them to Min/Max, and feeds the history through a Gaussian kernel. CheckBuySignalStrength() and CheckSellSignalStrength() sum three weighted votes against the now-adaptive thresholds, the score is filtered through CanEnterTrade()'s cooldown/HTF/ATR/trend gates, and OpenPosition() sizes the lot from the dynamic SL and risk percent. ManagePositions() ratchets SL and TP forward once profits clear the trailing thresholds, ManageProfitBasedClosing() scans for profit-target and time-based exits, CloseOnOppositeSignal() flips the book on a regime change, and every closed deal is fed back into UpdateMarketBasedParameters() through OnTradeTransaction() so the parameter drift self-corrects toward MinWinRate.
A bar is scored by three weighted votes: ADX strong/moderate/weak (1.5/1.0/0.5) on adaptiveADXThreshold with +DI or -DI dominance, MACD cross or momentum (1.0/0.5), and RSI oversold/overbought or momentum (1.0/0.5) on the adaptive RSI bands, plus a +0.5 bonus when marketCondition==1 (trending). A long triggers when total score meets MinSignalStrength (2) with plusDI dominant and the no-trade gate (cooldown, HTF MA alignment, ATR expansion, trend-strength buffer) clears.
Exits run on four tracks: trailing SL ratchets forward after TrailingStopStartPips (10) in 2-pip steps, trailing TP pulls down after TrailingTPStartPips (5) in 1-pip steps, ManageProfitBasedClosing closes once profit clears MinProfitToClose ($1) or a profitable trade ages past ProfitableCloseAfterMinutes (30) and a losing trade past UnprofitableCloseAfterMinutes (60), and CloseOnOppositeSignal reverses the book on a flip of the score's direction.
Default 20 pips, multiplied by VolatileSLMultiplier (1.3) on volatile bars, TrendingSLMultiplier (0.8) on trending bars, and an extra StrongSignalSLMultiplier (0.9) when entry signal strength hits 3 or more — so the live SL can land anywhere from 16 pips (strong trend) to 26 pips (volatile weak signal).
Default 15 pips, scaled by VolatileTPMultiplier (1.5), TrendingTPMultiplier (1.2), and StrongSignalTPMultiplier (1.2) when signal strength hits StrongSignalThreshold (3) — base 1:0.75 risk-reward that improves to roughly 1:1.15 in volatile conditions with strong confluence.
XAUUSD on M5 with a $100 minimum balance, MEDIUM risk tolerance, and an ECN or low-spread broker (the 3.0-pip spread filter assumes typical XAUUSD spreads under 25 points). Use a $300+ balance for the default 2% risk sizing to keep the lot above the broker minimum comfortably, and run on a London + New York overlap VPS to capture the volatility windows where the regime classifier and adaptive SL/TP multipliers have the most material to work with.
Strategy Logic
Pipsgrowth EX17013 Volatility — Strategy Logic Analysis (from .mq5 source)
Family: Volatility
Magic: 22217013
Version: 2.00
BRIEF:
Gaussian2 Adaptive EA with ADX, MACD, RSI, ATR, MA and market-based auto-tuning. Enhanced with HTF filters, dynamic SL/TP, session filter, trailing stops, and position closing. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
CalculateGaussianWeights()CalculateGaussianWeightsCustom()CheckMagicNumberConflict()ValidateInputParameters()SafeTradeHistoryAccess()SafeTradeHistoryWrite()SafeCircularIndex()CheckRiskManagement()SafeDivision()UpdateIndicatorCache()OnTradeTransaction()UpdateAdaptiveParameters()- ...and 23 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (115 total across 15 groups):
- [=== Execution & Limits ===]
MaxPositions= 2 // Max simultaneous positions - [=== Execution & Limits ===]
MaxDailyTrades= 100 // Max trades per day - [=== Execution & Limits ===]
MaxSpreadPips=3.0// Max spread allowed - [=== Execution & Limits ===] Slippage = 5 // Max slippage in points
- [=== Execution & Limits ===] Timeframe = 4 //
Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Working timeframe for indicators - [=== Risk Management ===]
RiskPercent=2.0// Risk percent per trade - [=== Risk Management ===]
StopLossPips= 20 // Stop loss in pips - [=== Risk Management ===]
TakeProfitPips= 15 // Take profit in pips - [=== Risk Management ===]
UseFixedLot=false// Use fixed lot size instead of risk-based - [=== Risk Management ===]
FixedLotSize=0.10// Fixed lot size when enabled - [=== Risk Management ===]
MaxDailyLossPercent=10.0// Max daily loss as % of balance - [=== Risk Management ===]
MaxDrawdownPercent=20.0// Max drawdown as % of balance - [=== Risk Management ===]
MinMarginLevel=200.0// Minimum marginlevel% - [=== Risk Management ===]
EnableEquityProtection=true// Enable equity-based protection - [=== Signals & Filters ===]
UseFlexibleSignals=true// Allow partial signal matches - [=== Signals & Filters ===]
MinSignalStrength= 2 // Minimum signals required (1-3) - [=== Gaussian & Auto-Tuning ===]
EnableGaussianSmoothing=true// Enable Gaussian smoothing - [=== Gaussian & Auto-Tuning ===]
GaussianWindow= 20 // Window for gauss averaging - [=== Gaussian & Auto-Tuning ===]
GaussianSigmaDivisor=6.0// Controls Gaussian sigma (sigma = window / this) - [=== Gaussian & Auto-Tuning ===]
GaussianWindowThresholds= 12 // Window for threshold smoothing - [=== Gaussian & Auto-Tuning ===]
GaussianSigmaDivisor_Thresholds=6.0// Sigma divisor for thresholds smoothing - [=== Gaussian & Auto-Tuning ===]
EnableMarketBasedTuning=true// Enable market-based auto-tuning - [=== Gaussian & Auto-Tuning ===]
TuningPeriod= 50 // Trades to analyze for tuning - [=== Gaussian & Auto-Tuning ===]
MinWinRate=60.0// Minimum win rate to maintain - [=== Gaussian & Auto-Tuning ===]
GoodPerformanceWinDelta=15.0// Delta aboveMinWinRateto consider "good" - [=== Gaussian & Auto-Tuning ===]
TuningAggressivenessScale=1.0// Scale factor for tuning aggressiveness - [=== Gaussian & Auto-Tuning ===]
TuningStabilityScale=1.0// Scale factor for tuning stability - [===
ADXSettings ===]EnableADX=true// UseADX-based signals - [===
ADXSettings ===] ADX_Period = 14 // InitialADXPeriod - [===
ADXSettings ===] ADX_Threshold =25.0// InitialADXThreshold - [===
ADXSettings ===] ADX_Lookback = 5 // Bars to read fromADXbuffers - [===
ADXSettings ===]RequireADXRisingForTrend=true// RequireADXrising to confirm a trend - [===
ADXSettings ===] ADX_StrongWeight =1.5// Buy/sell score whenADXstrong with direction - [===
ADXSettings ===] ADX_ModerateWeight =1.0// Score whenADXmoderately strong - [===
ADXSettings ===] ADX_WeakWeight =0.5// Score whenADXweak - [===
ADXSettings ===] ADX_ModerateFactor =0.8// Moderate threshold factor ofADX - [===
ADXSettings ===] ADX_WeakFactor =0.6// Weak threshold factor ofADX - [===
ADXSettings ===]MinAdxSlope=0.5// MinimumADXslope required - [===
ADXSettings ===]RefreshChangeThreshold_ADX=1.0// MinADXchange to refresh indicators - [===
ADXSettings ===]EnableHTF_ADXFilter=false// Require higherg_TimeframeADXalignment - [===
ADXSettings ===] HTF_ADX_Timeframe = 8 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) - [===
MACDSettings ===]EnableMACD=true// UseMACD-based signals - [===
MACDSettings ===] MACD_FastEMA = 12 // InitialMACDFastEMAPeriod - [===
MACDSettings ===] MACD_SlowEMA = 26 // InitialMACDSlowEMAPeriod - [===
MACDSettings ===] MACD_SignalSMA = 9 // InitialMACDSignalSMAPeriod - [===
MACDSettings ===] MACD_CrossWeight =1.0// Score forMACDcross - [===
MACDSettings ===] MACD_MomentumWeight =0.5// Score forMACDmomentum - [===
MACDSettings ===]RefreshChangeThreshold_MACD=1.0// MinMACDchange to refresh indicators - [===
MACDSettings ===]EnableHTF_MACDFilter=false// Require higherg_TimeframeMACDconfirmation - [===
MACDSettings ===] HTF_MACD_Timeframe = 8 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) - [===
RSISettings ===]EnableRSI=true// UseRSI-based signals - [===
RSISettings ===] RSI_Period = 14 // InitialRSIPeriod - [===
RSISettings ===] RSI_Overbought =70.0//RSIOverboughtlevel - [===
RSISettings ===] RSI_Oversold =30.0//RSIOversoldlevel - [===
RSISettings ===] RSI_OversoldWeight =1.0// Score forRSIoversold - [===
RSISettings ===] RSI_OverboughtWeight =1.0// Score forRSIoverbought - [===
RSISettings ===] RSI_MomentumWeight =0.5// Score forRSImomentum - [===
RSISettings ===]RefreshChangeThreshold_RSI=1.0// MinRSIchange to refresh indicators - [===
RSISettings ===]EnableHTF_RSIFilter=false// Require higherg_TimeframeRSIguardrails - [===
RSISettings ===] HTF_RSI_Timeframe = 8 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) - [===
ATRSettings ===]EnableATR=true// UseATR-based volatility checks - [===
ATRSettings ===] ATR_Period = 14 //ATRperiod for volatility - [===
ATRSettings ===] ATR_AvgLookback = 20 // Bars to averageATR - [===
ATRSettings ===]VolatilityMultiplier=1.2// Multiplier vs averageATRto classify volatile market - [===
ATRSettings ===]LowVolatilityPoints=100.0// Points threshold to grant low-volatility bonus - [===
ATRSettings ===]EnableATRExpansionFilter=false// RequireATRexpansion before entries - [===
ATRSettings ===] ATRExpansionMultiplier =1.2//ATRmultiple vs average to trade - [===
ATRSettings ===]EnableHTF_ATRFilter=false// Require higherg_TimeframeATRminimum volatility - [===
ATRSettings ===] HTF_ATR_Timeframe = 8 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) - [=== Moving Average Settings ===]
EnableMovingAverages=true// Use moving-average trend confirmation - [=== Moving Average Settings ===] MA_FastPeriod = 20 // Fast MA period for trend detection
- [=== Moving Average Settings ===] MA_SlowPeriod = 50 // Slow MA period for trend detection
- [=== Moving Average Settings ===] MA_Lookback = 5 // Bars to read from MA buffers
- [=== Moving Average Settings ===]
TrendStrengthPips=5.0// Minimum MA distance (in pips) to consider trend - [=== Moving Average Settings ===]
TrendingMarketBonus=0.5// Bonus in trending market - [=== Moving Average Settings ===]
LowVolatilityBonus=0.5// Bonus in low-volatility conditions - [=== Moving Average Settings ===]
EnableTrendStrengthBuffer=false// Enforce minimum trend/ADXslope buffers - [=== Moving Average Settings ===]
MinTrendStrengthBuffer=8.0// Minimum MA distance buffer (pips) - [=== Moving Average Settings ===]
EnableHigherTFConfirmation=false// Require higherg_Timeframetrend alignment - [=== Moving Average Settings ===]
HigherTFConfirmationPeriod= 6 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher timeframe to confirm trend - [=== Moving Average Settings ===]
HigherTFFastMAPeriod= 20 // Fast MA period on higher timeframe - [=== Moving Average Settings ===]
HigherTFSlowMAPeriod= 50 // Slow MA period on higher timeframe - [=== Moving Average Settings ===]
HigherTFTrendThresholdPips=8.0// Minimum MA distance (pips) on higherg_Timeframe - [=== Market Analysis ===]
MarketAnalysisPrintEvery= 100 //Printmarket analysis every N ticks - [=== Trailing ===]
UseTrailingStop=true// Enable trailing stop loss - [=== Trailing ===]
TrailingStopStartPips= 10 // Trailing SL start after profit in pips - [=== Trailing ===]
TrailingStopStepPips= 2 // Trailing SL step pips - [=== Trailing ===]
UseTrailingTP=true// Enable trailing take profit - [=== Trailing ===]
TrailingTPStartPips= 5 // Start trailing TP after this many pips - [=== Trailing ===]
TrailingTPStepPips= 1 // Trailing TP step pips - [=== Dynamic SL/TP ===]
VolatileSLMultiplier=1.3// SL multiplier in volatile markets - [=== Dynamic SL/TP ===]
VolatileTPMultiplier=1.5// TP multiplier in volatile markets - [=== Dynamic SL/TP ===]
TrendingSLMultiplier=0.8// SL multiplier in trending markets - [=== Dynamic SL/TP ===]
TrendingTPMultiplier=1.2// TP multiplier in trending markets - [=== Dynamic SL/TP ===]
StrongSignalThreshold= 3 // Signal strength considered "strong" - [=== Dynamic SL/TP ===]
StrongSignalSLMultiplier=0.9// SL multiplier for strong signals - [=== Dynamic SL/TP ===]
StrongSignalTPMultiplier=1.2// TP multiplier for strong signals - [=== Position Closing ===]
CloseOnOppositeSignal=true// Close positions on opposite signal - [=== Position Closing ===]
CloseOnlyProfitable=true// Close only profitable positions - [=== Position Closing ===]
MinProfitToClose=1.0// Minimum profit in $ to consider closing - [=== Position Closing ===]
MaxLossToClose=3.0// Maximum loss in $ before forcing close (0=disabled threshold) - [=== Position Closing ===]
ProfitableCloseAfterMinutes= 30 // Minutes after which to close profitable trades - [=== Position Closing ===]
UnprofitableCloseAfterMinutes= 60 // Minutes after which to close losing trades (if allowed) - [=== Position Closing ===]
ProfitManagerCheckSeconds= 10 // Interval between profit manager checks - [=== Position Closing ===]
EnablePostExitCooldown=false// Prevent re-entry for cooldown period - [=== Position Closing ===]
PostExitCooldownMinutes= 10 // Cooldown duration after exit (minutes) - [=== Session Filter ===]
UseSessionFilter=false// Enable time/day session filter for entries - [=== Session Filter ===]
SessionStartHour= 0 // Trading window start hour (0-23) - [=== Session Filter ===]
SessionEndHour= 24 // Trading window end hour (1-24) - [=== Session Filter ===]
TradeMonday=true// Allow trading on Monday - [=== Session Filter ===]
TradeTuesday=true// Allow trading on Tuesday - [=== Session Filter ===]
TradeWednesday=true// Allow trading on Wednesday - [=== Session Filter ===]
TradeThursday=true// Allow trading on Thursday - [=== Session Filter ===]
TradeFriday=true// Allow trading on Friday - [=== Identity ===]
MagicNumber=22217013// Order magic number
// Pipsgrowth EX17013 Volatility — Execution Flow (from source analysis)
// Family: Volatility
// Gaussian2 Adaptive EA with ADX, MACD, RSI, ATR, MA and market-based auto-tuning. Enhanced with HTF filters, dynamic SL/TP, session filter, trailing stops, and position closing. 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 |
|---|---|---|
| MaxPositions | 2 | Max simultaneous positions |
| MaxDailyTrades | 100 | Max trades per day |
| MaxSpreadPips | 3.0 | Max spread allowed |
| Slippage | 5 | Max slippage in points |
| Timeframe | 4 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Working timeframe for indicators |
| RiskPercent | 2.0 | Risk percent per trade |
| StopLossPips | 20 | Stop loss in pips |
| TakeProfitPips | 15 | Take profit in pips |
| UseFixedLot | false | Use fixed lot size instead of risk-based |
| FixedLotSize | 0.10 | Fixed lot size when enabled |
| MaxDailyLossPercent | 10.0 | Max daily loss as % of balance |
| MaxDrawdownPercent | 20.0 | Max drawdown as % of balance |
| MinMarginLevel | 200.0 | Minimum margin level % |
| EnableEquityProtection | true | Enable equity-based protection |
| UseFlexibleSignals | true | Allow partial signal matches |
| MinSignalStrength | 2 | Minimum signals required (1-3) |
| EnableGaussianSmoothing | true | Enable Gaussian smoothing |
| GaussianWindow | 20 | Window for gauss averaging |
| GaussianSigmaDivisor | 6.0 | Controls Gaussian sigma (sigma = window / this) |
| GaussianWindowThresholds | 12 | Window for threshold smoothing |
| GaussianSigmaDivisor_Thresholds | 6.0 | Sigma divisor for thresholds smoothing |
| EnableMarketBasedTuning | true | Enable market-based auto-tuning |
| TuningPeriod | 50 | Trades to analyze for tuning |
| MinWinRate | 60.0 | Minimum win rate to maintain |
| GoodPerformanceWinDelta | 15.0 | Delta above MinWinRate to consider "good" |
| TuningAggressivenessScale | 1.0 | Scale factor for tuning aggressiveness |
| TuningStabilityScale | 1.0 | Scale factor for tuning stability |
| EnableADX | true | Use ADX-based signals |
| ADX_Period | 14 | Initial ADX Period |
| ADX_Threshold | 25.0 | Initial ADX Threshold |
| ADX_Lookback | 5 | Bars to read from ADX buffers |
| RequireADXRisingForTrend | true | Require ADX rising to confirm a trend |
| ADX_StrongWeight | 1.5 | Buy/sell score when ADX strong with direction |
| ADX_ModerateWeight | 1.0 | Score when ADX moderately strong |
| ADX_WeakWeight | 0.5 | Score when ADX weak |
| ADX_ModerateFactor | 0.8 | Moderate threshold factor of ADX |
| ADX_WeakFactor | 0.6 | Weak threshold factor of ADX |
| MinAdxSlope | 0.5 | Minimum ADX slope required |
| RefreshChangeThreshold_ADX | 1.0 | Min ADX change to refresh indicators |
| EnableHTF_ADXFilter | false | Require higher g_Timeframe ADX alignment |
| HTF_ADX_Timeframe | 8 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) |
| EnableMACD | true | Use MACD-based signals |
| MACD_FastEMA | 12 | Initial MACD Fast EMA Period |
| MACD_SlowEMA | 26 | Initial MACD Slow EMA Period |
| MACD_SignalSMA | 9 | Initial MACD Signal SMA Period |
| MACD_CrossWeight | 1.0 | Score for MACD cross |
| MACD_MomentumWeight | 0.5 | Score for MACD momentum |
| RefreshChangeThreshold_MACD | 1.0 | Min MACD change to refresh indicators |
| EnableHTF_MACDFilter | false | Require higher g_Timeframe MACD confirmation |
| HTF_MACD_Timeframe | 8 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) |
| EnableRSI | true | Use RSI-based signals |
| RSI_Period | 14 | Initial RSI Period |
| RSI_Overbought | 70.0 | RSI Overbought level |
| RSI_Oversold | 30.0 | RSI Oversold level |
| RSI_OversoldWeight | 1.0 | Score for RSI oversold |
| RSI_OverboughtWeight | 1.0 | Score for RSI overbought |
| RSI_MomentumWeight | 0.5 | Score for RSI momentum |
| RefreshChangeThreshold_RSI | 1.0 | Min RSI change to refresh indicators |
| EnableHTF_RSIFilter | false | Require higher g_Timeframe RSI guardrails |
| HTF_RSI_Timeframe | 8 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) |
| EnableATR | true | Use ATR-based volatility checks |
| ATR_Period | 14 | ATR period for volatility |
| ATR_AvgLookback | 20 | Bars to average ATR |
| VolatilityMultiplier | 1.2 | Multiplier vs average ATR to classify volatile market |
| LowVolatilityPoints | 100.0 | Points threshold to grant low-volatility bonus |
| EnableATRExpansionFilter | false | Require ATR expansion before entries |
| ATRExpansionMultiplier | 1.2 | ATR multiple vs average to trade |
| EnableHTF_ATRFilter | false | Require higher g_Timeframe ATR minimum volatility |
| HTF_ATR_Timeframe | 8 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) |
| EnableMovingAverages | true | Use moving-average trend confirmation |
| MA_FastPeriod | 20 | Fast MA period for trend detection |
| MA_SlowPeriod | 50 | Slow MA period for trend detection |
| MA_Lookback | 5 | Bars to read from MA buffers |
| TrendStrengthPips | 5.0 | Minimum MA distance (in pips) to consider trend |
| TrendingMarketBonus | 0.5 | Bonus in trending market |
| LowVolatilityBonus | 0.5 | Bonus in low-volatility conditions |
| EnableTrendStrengthBuffer | false | Enforce minimum trend/ADX slope buffers |
| MinTrendStrengthBuffer | 8.0 | Minimum MA distance buffer (pips) |
| EnableHigherTFConfirmation | false | Require higher g_Timeframe trend alignment |
| HigherTFConfirmationPeriod | 6 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher timeframe to confirm trend |
| HigherTFFastMAPeriod | 20 | Fast MA period on higher timeframe |
| HigherTFSlowMAPeriod | 50 | Slow MA period on higher timeframe |
| HigherTFTrendThresholdPips | 8.0 | Minimum MA distance (pips) on higher g_Timeframe |
| MarketAnalysisPrintEvery | 100 | Print market analysis every N ticks |
| UseTrailingStop | true | Enable trailing stop loss |
| TrailingStopStartPips | 10 | Trailing SL start after profit in pips |
| TrailingStopStepPips | 2 | Trailing SL step pips |
| UseTrailingTP | true | Enable trailing take profit |
| TrailingTPStartPips | 5 | Start trailing TP after this many pips |
| TrailingTPStepPips | 1 | Trailing TP step pips |
| VolatileSLMultiplier | 1.3 | SL multiplier in volatile markets |
| VolatileTPMultiplier | 1.5 | TP multiplier in volatile markets |
| TrendingSLMultiplier | 0.8 | SL multiplier in trending markets |
| TrendingTPMultiplier | 1.2 | TP multiplier in trending markets |
| StrongSignalThreshold | 3 | Signal strength considered "strong" |
| StrongSignalSLMultiplier | 0.9 | SL multiplier for strong signals |
| StrongSignalTPMultiplier | 1.2 | TP multiplier for strong signals |
| CloseOnOppositeSignal | true | Close positions on opposite signal |
| CloseOnlyProfitable | true | Close only profitable positions |
| MinProfitToClose | 1.0 | Minimum profit in $ to consider closing |
| MaxLossToClose | 3.0 | Maximum loss in $ before forcing close (0=disabled threshold) |
| ProfitableCloseAfterMinutes | 30 | Minutes after which to close profitable trades |
| UnprofitableCloseAfterMinutes | 60 | Minutes after which to close losing trades (if allowed) |
| ProfitManagerCheckSeconds | 10 | Interval between profit manager checks |
| EnablePostExitCooldown | false | Prevent re-entry for cooldown period |
| PostExitCooldownMinutes | 10 | Cooldown duration after exit (minutes) |
| UseSessionFilter | false | Enable time/day session filter for entries |
| SessionStartHour | 0 | Trading window start hour (0-23) |
| SessionEndHour | 24 | Trading window end hour (1-24) |
| TradeMonday | true | Allow trading on Monday |
| TradeTuesday | true | Allow trading on Tuesday |
| TradeWednesday | true | Allow trading on Wednesday |
| TradeThursday | true | Allow trading on Thursday |
| TradeFriday | true | Allow trading on Friday |
| MagicNumber | 22217013 | Order magic number |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX17013 gaussian2 — Gaussian2 Adaptive EA with multi-indicator auto-tuning and HTF filters, full 12-layer stack."
#include <Trade\Trade.mqh>
// Input Parameters
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_TIMEFRAMES g_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HTF_ADX_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HTF_MACD_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HTF_RSI_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HTF_ATR_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HigherTFConfirmationPeriod = PERIOD_H1;
input group "=== Execution & Limits ==="
input int MaxPositions = 2; // Max simultaneous positions
input int MaxDailyTrades = 100; // Max trades per day
input double MaxSpreadPips = 3.0; // Max spread allowed
input int Slippage = 5; // Max slippage in points
input int Timeframe = 4; // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Working timeframe for indicators
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_TIMEFRAMES g_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HTF_ADX_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HTF_MACD_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HTF_RSI_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HTF_ATR_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_HigherTFConfirmationPeriod = PERIOD_H1;
input group "=== Risk Management ==="
input double RiskPercent = 2.0; // Risk percent per trade
input int StopLossPips = 20; // Stop loss in pips
input int TakeProfitPips = 15; // Take profit in pips
input bool UseFixedLot = false; // Use fixed lot size instead of risk-based
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.