Pipsgrowth EX01001 Adaptive
MT5 Expert Advisor (Open Source) · XAUUSD · H1
Pipsgrowth.com EX01001 Adaptive EA — regime-switch dispatcher (Trend/Range/Breakout) with full 12-layer stack, configurable timeframe, trailing/BE/profit-lock toggles, pyramid gate, spread filter, new-bar gate. Works on any symbol/timeframe.
Overview
Pipsgrowth EX01001 Adaptive is a single-EA regime router that classifies market conditions on every closed bar and dispatches the trade to one of three internally coded sub-strategies. There is no fixed edge in the system — the EA's job is to detect what kind of market is in front of it and pick the sub-engine that historically has the right shape for that environment. The dispatcher is ClassifyRegime() in the source, and the three sub-engines are SignalTrendFollow(), SignalRSIMeanReversion(), and SignalBreakout(). The master function MasterSignal() then maps the regime to one of these sub-engines or returns 0 in choppy conditions.
Regime classification uses four inputs measured on the last closed bar: ADX(14), the ATR(14) percentile over a 50-bar lookback, the Bollinger Band width at 20-period/2.0 deviation, and the absolute separation between EMA(21) and EMA(50). Eight regime states are defined — NEUTRAL, STRONG_TREND, WEAK_TREND, RANGE, BREAKOUT, COMPRESS, EXPAND, CHOPPY — and each maps to a different signal pipeline. BREAKOUT requires ADX above 25, ATR percentile above 60, and price piercing the upper or lower Bollinger band. STRONG_TREND requires ADX above 25 with EMA separation greater than one ATR and ATR percentile above 50. RANGE is anything with ADX below 20. CHOPPY is the only state that is hard-rejected by NoTradeGate() before any signal evaluation.
SignalTrendFollow activates in strong and weak trends. The fresh EMA(21)/EMA(50) cross on the last two closed bars carries the highest confidence score of 75; it also requires close above the EMA(200) filter and RSI(14) between the neutral low (40) and the overbought line (70). Three continuation variants follow: pullback entries where the previous bar closed back through EMA(21) inside 0.5 ATR distance, momentum re-entries on a strong body bar with body/range above 60 percent, and RSI-acceleration scalps on bars with body-to-ATR above 0.8. All four variants demand EMA(200) side agreement and reject when RSI is in the opposite extreme.
SignalRSIMeanReversion runs in RANGE and COMPRESS regimes. The four patterns are: a classic oversold/overbought cross with close on the favorable side of EMA(21), an extreme RSI reading plus a strong reversal bar, a Bollinger band touch with RSI confirming in the same direction, and a Bollinger band bounce where the bar's wick pierced the band but the close returned inside. Confidence scores range from 55 to 65 — the mean-reversion engine is intentionally lower conviction than the trend engine because the bar is fighting the prevailing direction.
SignalBreakout handles BREAKOUT, EXPAND, and NEUTRAL regimes. The classic pattern closes beyond a 20-bar Donchian high or low with volume on the closed bar above 1.5 times the 50-bar average, HTF EMA agreement on the H4 timeframe, and RSI not in extreme territory. The secondary pattern allows entries within 10 percent of the Donchian range when volume is above average and HTF trend agrees. Both patterns require the higher-timeframe EMA(50) on H4 to be on the correct side of the close.
After a signal is generated, CheckConfirm() enforces three additional gates: HTF EMA agreement, minimum risk-to-reward ratio of 1.2 (the default 2.0 ATR SL and 4.0 ATR TP give 1:2), and a minimum ADX of 15 on the closed bar. The pyramid gate can be set to off, profit-only, or profit-plus-stop-protected. The NoTradeGate() function adds a long list of vetoes: market closed, off-session, spread above 50 points, spread anomaly above 3x the 30-bar rolling average, cooldown active after a loss, three consecutive losses (default), kill switch, total drawdown above 20 percent, max open positions, max daily trades, choppy regime, capital below floor, daily loss above 3 percent of effective capital, weekly loss above 9 percent.
Position sizing is risk-based at 0.5 percent of effective capital by default. The CalcLotByRisk() function reduces size by 25 percent for each consecutive loss, with a floor at 25 percent of the base risk. Commission cost per lot is included in the loss calculation. The minimum stop distance is forced to 3x current spread to prevent instant stop-outs during volatile opens. A capital cap (InpCapAmount) lets traders isolate this EA to a fixed notional slice of the account.
Trade management runs every tick through ManageExits(). Break-even activates after 1x ATR profit, ATR trailing after 1x ATR with a 0.8 step, and profit-lock every 1x ATR with the stop trailing 0.5 ATR behind price. A time-based exit closes positions older than 240 hours. A quick scalp variant exits on a configurable ATR profit threshold within a configurable number of hours. Partial close is supported at a configurable ratio of TP1.
The session filter is hard-coded for major-session hours: London 08:00 to 16:30 GMT, New York 13:00 to 21:00 GMT, and Asia 22:00 to 06:00 GMT is the default avoid-window. The broker GMT offset is auto-detected from the weekend gap in H1 bar data, which works in the Strategy Tester as well as on live servers, and can be overridden with InpServerGMTOffset for brokers that back-adjust clocks across DST transitions.
For the suggested XAUUSD H1 setup, the 1:2 R:R profile and the ATR-based stops mean realistic drawdown periods when the regime classifier is wrong — which is why the daily, weekly, and total drawdown kill switches exist. The EA does not pyramid by default and caps itself at 3 concurrent positions and 10 entries per day, so over-trading is not the main risk; regime misclassification is. The adaptive risk reduction on consecutive losses is the design's main answer to that, scaling lot size down before limits kick in.
Strategy Deep Dive
On every closed bar the EA refreshes 8 indicator buffers — EMA(21), EMA(50), EMA(200), RSI(14), ATR(14), ADX(14), Bollinger(20, 2.0), and HTF EMA(50) — and runs ClassifyRegime() to assign one of eight states. MasterSignal() then dispatches the bar to one of three sub-engines: trend regimes go to SignalTrendFollow(), range and compression to SignalRSIMeanReversion(), breakout/expansion/neutral to SignalBreakout(). Each sub-engine emits either +1, -1, or 0 with a confidence score, and CheckConfirm() enforces HTF-EMA agreement, a 1.2 minimum R:R, and a 15 minimum ADX. The NoTradeGate() function then layers in spread, session, cooldown, drawdown, daily-trade, and capital-floor vetoes before TryEntry() computes the lot from 0.5 percent of effective capital and sends the order. ManageExits() runs every tick to apply break-even at 1x ATR, trailing at 0.8 ATR steps, profit lock every 1x ATR, and the 240-hour time stop.
Entries are routed by the live regime: in trend regimes the EA fires on a fresh EMA(21)/EMA(50) cross, a pullback to EMA(21), a momentum re-entry on a body-dominant bar, or an RSI-acceleration scalp — all with EMA(200) side agreement and HTF-EMA confirmation. In range and compression regimes it fires mean-reversion entries on RSI(14) oversold/overbought crosses, on Bollinger band touches with RSI confirming, and on band-bounce reversals. In breakout/expansion/neutral regimes it fires on Donchian(20) close-beyond with volume above 1.5x the 50-bar average and HTF trend agreement.
Exits use a layered management stack: break-even activates after 1x ATR profit, ATR trailing after 1x ATR with a 0.8 step, profit-lock every 1x ATR trailing 0.5 ATR behind price, and a hard time-stop at 240 hours. A configurable quick-scalp mode closes positions on a small ATR profit threshold within a configurable number of hours. Regime reversal to CHOPPY is not a direct exit trigger, but the choppy filter blocks new entries and existing positions fall to the management layer.
Initial stop is 2.0x ATR(14) by default, forced to a minimum of 3x current spread to prevent stop-outs from spread spikes. The risk-based lot sizing uses this exact distance: each 0.5 percent of effective capital at risk. A total drawdown kill switch at 20 percent of starting balance halts all trading.
Initial take profit is 4.0x ATR(14), producing a 1:2 risk-to-reward ratio against the 2.0x ATR stop. A minimum R:R of 1.2 is enforced in the confirm layer; settings that produce a worse ratio are rejected before any order is sent.
Minimum recommended balance: $100 with conservative lot sizing on XAUUSD H1, larger balances unlock the full adaptive risk scaling. A low-spread broker is essential — the 50-point spread cap and 3x spread minimum-stop will reject most signals on wide-spread ECN accounts. Best sessions are London 08:00–16:30 GMT and New York 13:00–21:00 GMT; the default config avoids Asia 22:00–06:00 GMT. This is a hands-off, multi-regime EA that needs at least 6 months of forward testing on the target symbol before any live deployment.
Strategy Logic
Pipsgrowth EX01001 Adaptive — Strategy Logic Analysis (from .mq5 source)
Family: Adaptive
Magic: 22201001
Version: 1.00
BRIEF:
ADX + ATR%ile + Bollinger width classify regime, then route to one of three native sub-signals: Trending -> EMA(21/50) cross + EMA(200) side Ranging -> RSI +/- OB/OS mean-reversion cross Breakout -> Donchian(20) channel + volume surge 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL ALLOCATION CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester. All paths use closed bar (shift=1)
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
RegimeName()DetectGMTOffset()RefreshClosedBarSeries()CurrentBarTime()WeekStart()DayStart()ATRPercentile()BBWidth()SignalTrendFollow()SignalRSIMeanReversion()SignalBreakout()MasterSignal()- ...and 27 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (87 total across 14 groups):
- [=== Identity ===]
InpMagic=22201001// Magic number (unique perEA) [10000000-99999999, step 1] - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_01001" // Trade comment - [=== Identity ===]
InpStrategyTag= "RegimeSwitch" // Strategy tag (logs/index) - [=== Identity ===]
InpDryRun=false// Dry-run: skip real order sends (defaultOFF) - [=== Identity ===]
InpKillSwitch=false// Emergency kill switch (blocks new entries) - [=== Identity ===]
InpEnableLogging=false// Enable logging to journal - [=== Identity ===]
InpTimeframe= 7 // Timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1[1-9, step 1] - [=== Risk & Sizing ===]
InpRiskPercent=0.5// Risk per trade, % of effective capital [0.1-5.0, step0.1] - [=== Risk & Sizing ===]
InpATR_SL_Mult=2.0// Initial SL =ATR× mult [0.5-10.0, step0.1] - [=== Risk & Sizing ===]
InpATR_TP_Mult=4.0// Initial TP =ATR× mult (sets R:R) [0.5-20.0, step0.1] - [=== Risk & Sizing ===]
InpFixedLot=0.01// Fallback lot when auto-sizing off [0.01-100.0, step0.01] - [=== Risk & Sizing ===]
InpUseAutoLot=true// Auto lot sizing from risk - [=== Risk & Sizing ===]
InpMaxLot=0.50// Hard cap on lot size [0.01-100.0, step0.01] - [=== Risk & Sizing ===]
InpSignalOnBarClose=true// Evaluate signals only on bar close - [=== Risk & Sizing ===]
InpMaxSpread= 50 // Max allowed spread in points (0=disable) [0-200, step 1] - [=== Risk & Sizing ===]
InpCommissionPerLot=7.0// Commission cost per lot (account currency) [0-50, step0.5] - [=== Capital Cap ===]
InpCapAmount=0.0// Real-money capital cap, account currency [10-100000, step 10] - [=== Capital Cap ===]
InpCapFloor=50.0// Floor below which new entries blocked [1-10000, step 1] - [=== Daily / Weekly / Total Limits ===]
InpDailyLossPct=3.0// Max daily loss, % of effective capital [0.5-20.0, step0.5] - [=== Daily / Weekly / Total Limits ===]
InpWeeklyLossPct=9.0// Max weekly loss, % of effective capital [1.0-50.0, step0.5] - [=== Daily / Weekly / Total Limits ===]
InpMaxDDPct=20.0// Max total account drawdown % from start balance (0=disable) [5-50, step 1] - [=== Daily / Weekly / Total Limits ===]
InpMaxDailyTrades= 10 // Max new entries per day [1-50, step 1] - [=== Daily / Weekly / Total Limits ===]
InpCooldownMin= 30 // Cooldown minutes after a loss [0-1440, step 1] - [=== Daily / Weekly / Total Limits ===]
InpMaxConsecLosses= 3 // Max consecutive losses before halt (0=disable) [0-20, step 1] - [=== Signal / Regime ===]
InpEMA_Fast= 21 //EMAfast period [2-500, step 1] - [=== Signal / Regime ===]
InpEMA_Slow= 50 //EMAslow period [2-500, step 1] - [=== Signal / Regime ===]
InpEMA_Filter= 200 //EMAtrend filter period [10-1000, step 1] - [=== Signal / Regime ===]
InpRSI_Period= 14 //RSIperiod [2-100, step 1] - [=== Signal / Regime ===]
InpRSI_Oversold= 30 //RSIoversold threshold [1-49, step 1] - [=== Signal / Regime ===]
InpRSI_Overbought= 70 //RSIoverbought threshold [51-99, step 1] - [=== Signal / Regime ===]
InpRSI_NeutralLow= 40 //RSIneutral low (trend signal floor) [1-49, step 1] - [=== Signal / Regime ===]
InpRSI_NeutralHigh= 70 //RSIneutral high (trend signal ceiling) [51-99, step 1] - [=== Indicator Periods ===]
InpADX_Period= 14 //ADXperiod [2-100, step 1] - [=== Indicator Periods ===]
InpATR_Period= 14 //ATRperiod [2-100, step 1] - [=== Indicator Periods ===]
InpBB_Period= 20 // Bollinger Bands period [2-100, step 1] - [=== Indicator Periods ===]
InpBB_Deviation=2.0// Bollinger Bands deviation [0.1-5.0, step0.1] - [=== Regime Thresholds ===]
InpRegime_ADX_Trend=25.0//ADXthreshold for trend regime [10-60, step0.5] - [=== Regime Thresholds ===]
InpRegime_ADX_Range=20.0//ADXthreshold for range regime [5-50, step0.5] - [=== Regime Thresholds ===]
InpATRPct_BK_Min=0.6//ATR%ile min for breakout regime [0.1-1.0, step0.05] - [=== Regime Thresholds ===]
InpATRPct_Lookback= 50 //ATRpercentile lookback bars [10-200, step 1] - [=== Regime Thresholds ===]
InpADX_Min_Signal=15.0// MinADXon closed bar for signal validity [5-50, step0.5] - [=== Regime Thresholds ===]
InpADX_WeakOffset=5.0//ADXoffset below trend threshold for weak trend [1-20, step0.5] - [=== Regime Thresholds ===]
InpATRPct_StrongTrend=50.0//ATR%ile min for strong trend [10-90, step 5] - [=== Regime Thresholds ===]
InpATRPct_Compress=25.0//ATR%ile max for compression [5-50, step 5] - [=== Regime Thresholds ===]
InpATRPct_Expand=80.0//ATR%ile min for expansion [50-95, step 5] - [=== Regime Thresholds ===]
InpATRPct_Choppy=40.0//ATR%ile max for choppy [10-60, step 5] - [=== Regime Thresholds ===]
InpBBWidth_Compress=1.0//BBwidth max for compression [0.1-5.0, step0.1] - [=== Regime Thresholds ===]
InpBBWidth_Expand=2.5//BBwidth min for expansion [0.5-10.0, step0.1] - [=== Breakout / Volume ===]
InpBreakout_Lookback= 20 // Donchian channel lookback (bars) [5-200, step 1] - [=== Breakout / Volume ===]
InpVolume_Avg_Period= 50 // Volume averaging period (bars) [10-200, step 1] - [=== Breakout / Volume ===]
InpVolume_Mult=1.5// Volume surge multiplier [1.0-5.0, step0.1] - [===
HTFConfirmation ===]InpHTF_TF= 8 //HTFtimeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1[1-9, step 1] - [===
HTFConfirmation ===]InpHTF_EMA_Period= 50 //HTFEMAperiod [5-500, step 1] - [===
HTFConfirmation ===]InpMin_RR_Ratio=1.2// Minimum R:R ratio (TP/SL) [0.5-10.0, step0.1] - [=== Trade Management Tunables ===]
InpTrail_ATR_Buffer=0.5// BE SL buffer (×ATR×0.1) [0.1-5.0, step0.1] - [=== Trade Management Tunables ===]
InpPartial_TP_Ratio=0.0// Partial TP close ratio atTP1(0=disabled) [0.0-0.9, step0.05] - [=== Trade Management Tunables ===]
InpMax_Hours_In_Trade= 240 // Max hours in trade (time-based exit) [1-2000, step 1] - [=== Trade Management Tunables ===]
InpQuickScalpATR=0.0// Quick scalp exit: minATRprofit (0=disabled) [0-5.0, step0.1] - [=== Trade Management Tunables ===]
InpQuickScalpHours=6.0// Quick scalp exit: min hours in trade [1-48, step 1] - [=== Spread / Safety Caps ===]
InpMax_Spread_Mult_Avg=3.0// Spread anomaly: reject if > N× rolling avg [1.0-10.0, step0.5] - [=== Spread / Safety Caps ===]
InpSpread_Avg_Bars= 30 // Spread rolling avg period (M1bars) [5-200, step 1] - [=== Exit / Manage ===]
InpEnableBreakEven=true// Enable break-even - [=== Exit / Manage ===]
InpATR_Breakeven=1.0// Move to BE after N×ATRprofit [0.5-10.0, step0.1] - [=== Exit / Manage ===]
InpEnableTrailingStop=true// EnableATRtrailing stop - [=== Exit / Manage ===]
InpATR_TrailStart=1.0// ActivateATRtrail after N×ATRprofit [0.5-20.0, step0.1] - [=== Exit / Manage ===]
InpATR_TrailStep=0.8//ATRtrailing step [0.1-10.0, step0.1] - [=== Exit / Manage ===]
InpEnableProfitLock=true// Lock profits in incremental steps - [=== Exit / Manage ===]
InpProfitLockIncrement=1.0// Lock every N×ATRof profit [0.5-10.0, step0.1] - [=== Exit / Manage ===]
InpProfitLockStep=0.5// Distance behind current price (N×ATR) [0.1-5.0, step0.1] - [=== Additional Trade Controls ===]
InpPyramidGateMode=PyramidGate_Off// Pyramid gate mode - [=== Additional Trade Controls ===]
InpProfitGatePoints=10.0// Minimum profit (points) per trade for pyramid [1-1000, step 1] - [=== Additional Trade Controls ===]
InpMaxOpenPos= 3 // Max concurrent positions (this symbol+magic) [1-20, step 1] - [=== Session
Filter(all times inGMT) ===]InpUseSessionFilter=true// Enable session time filter - [=== Session
Filter(all times inGMT) ===]InpServerGMTOffset= 0 // Broker serverGMToffset (hours). 0=auto-detect. For backtesting set manually (e.g. 2=winter, 3=summer) [-12-14, step 1] - [=== Session
Filter(all times inGMT) ===]InpLondonStartH= 8 // London start hour (GMT) [0-23, step 1] - [=== Session
Filter(all times inGMT) ===]InpLondonStartM= 0 // London start minute [0-59, step 1] - [=== Session
Filter(all times inGMT) ===]InpLondonEndH= 16 // London end hour (GMT) [0-23, step 1] - [=== Session
Filter(all times inGMT) ===]InpLondonEndM= 30 // London end minute [0-59, step 1] - [=== Session
Filter(all times inGMT) ===]InpNYStartH= 13 // New York start hour (GMT) [0-23, step 1] - [=== Session
Filter(all times inGMT) ===]InpNYStartM= 0 // New York start minute [0-59, step 1] - [=== Session
Filter(all times inGMT) ===]InpNYEndH= 21 // New York end hour (GMT) [0-23, step 1] - [=== Session
Filter(all times inGMT) ===]InpNYEndM= 0 // New York end minute [0-59, step 1] - [=== Session
Filter(all times inGMT) ===]InpAvoidAsia=true// Avoid Asian session - [=== Session
Filter(all times inGMT) ===]InpAsiaStartH= 22 // Asia start hour (GMT) [0-23, step 1] - [=== Session
Filter(all times inGMT) ===]InpAsiaStartM= 0 // Asia start minute [0-59, step 1] - [=== Session
Filter(all times inGMT) ===]InpAsiaEndH= 6 // Asia end hour (GMT) [0-23, step 1] - [=== Session
Filter(all times inGMT) ===]InpAsiaEndM= 0 // Asia end minute [0-59, step 1]
// Pipsgrowth EX01001 Adaptive — Execution Flow (from source analysis)
// Family: Adaptive
// ADX + ATR%ile + Bollinger width classify regime, then route to one of three native sub-signals: Trending -> EMA(21/50) cross + EMA(200) side Ranging -> RSI +/- OB/OS mean-reversion cross Breakout -> Donchian(20) channel + volume surge 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL ALLOCATION CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester. All paths use closed bar (shift=1)
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 |
|---|---|---|
| InpMagic | 22201001 | Magic number (unique per EA) [10000000-99999999, step 1] |
| InpTradeComment | "Psgrowth.com Expert_01001" | Trade comment |
| InpStrategyTag | "RegimeSwitch" | Strategy tag (logs/index) |
| InpDryRun | false | Dry-run: skip real order sends (default OFF) |
| InpKillSwitch | false | Emergency kill switch (blocks new entries) |
| InpEnableLogging | false | Enable logging to journal |
| InpTimeframe | 7 | Timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1 [1-9, step 1] |
| InpRiskPercent | 0.5 | Risk per trade, % of effective capital [0.1-5.0, step 0.1] |
| InpATR_SL_Mult | 2.0 | Initial SL = ATR × mult [0.5-10.0, step 0.1] |
| InpATR_TP_Mult | 4.0 | Initial TP = ATR × mult (sets R:R) [0.5-20.0, step 0.1] |
| InpFixedLot | 0.01 | Fallback lot when auto-sizing off [0.01-100.0, step 0.01] |
| InpUseAutoLot | true | Auto lot sizing from risk |
| InpMaxLot | 0.50 | Hard cap on lot size [0.01-100.0, step 0.01] |
| InpSignalOnBarClose | true | Evaluate signals only on bar close |
| InpMaxSpread | 50 | Max allowed spread in points (0=disable) [0-200, step 1] |
| InpCommissionPerLot | 7.0 | Commission cost per lot (account currency) [0-50, step 0.5] |
| InpCapAmount | 0.0 | Real-money capital cap, account currency [10-100000, step 10] |
| InpCapFloor | 50.0 | Floor below which new entries blocked [1-10000, step 1] |
| InpDailyLossPct | 3.0 | Max daily loss, % of effective capital [0.5-20.0, step 0.5] |
| InpWeeklyLossPct | 9.0 | Max weekly loss, % of effective capital [1.0-50.0, step 0.5] |
| InpMaxDDPct | 20.0 | Max total account drawdown % from start balance (0=disable) [5-50, step 1] |
| InpMaxDailyTrades | 10 | Max new entries per day [1-50, step 1] |
| InpCooldownMin | 30 | Cooldown minutes after a loss [0-1440, step 1] |
| InpMaxConsecLosses | 3 | Max consecutive losses before halt (0=disable) [0-20, step 1] |
| InpEMA_Fast | 21 | EMA fast period [2-500, step 1] |
| InpEMA_Slow | 50 | EMA slow period [2-500, step 1] |
| InpEMA_Filter | 200 | EMA trend filter period [10-1000, step 1] |
| InpRSI_Period | 14 | RSI period [2-100, step 1] |
| InpRSI_Oversold | 30 | RSI oversold threshold [1-49, step 1] |
| InpRSI_Overbought | 70 | RSI overbought threshold [51-99, step 1] |
| InpRSI_NeutralLow | 40 | RSI neutral low (trend signal floor) [1-49, step 1] |
| InpRSI_NeutralHigh | 70 | RSI neutral high (trend signal ceiling) [51-99, step 1] |
| InpADX_Period | 14 | ADX period [2-100, step 1] |
| InpATR_Period | 14 | ATR period [2-100, step 1] |
| InpBB_Period | 20 | Bollinger Bands period [2-100, step 1] |
| InpBB_Deviation | 2.0 | Bollinger Bands deviation [0.1-5.0, step 0.1] |
| InpRegime_ADX_Trend | 25.0 | ADX threshold for trend regime [10-60, step 0.5] |
| InpRegime_ADX_Range | 20.0 | ADX threshold for range regime [5-50, step 0.5] |
| InpATRPct_BK_Min | 0.6 | ATR%ile min for breakout regime [0.1-1.0, step 0.05] |
| InpATRPct_Lookback | 50 | ATR percentile lookback bars [10-200, step 1] |
| InpADX_Min_Signal | 15.0 | Min ADX on closed bar for signal validity [5-50, step 0.5] |
| InpADX_WeakOffset | 5.0 | ADX offset below trend threshold for weak trend [1-20, step 0.5] |
| InpATRPct_StrongTrend | 50.0 | ATR%ile min for strong trend [10-90, step 5] |
| InpATRPct_Compress | 25.0 | ATR%ile max for compression [5-50, step 5] |
| InpATRPct_Expand | 80.0 | ATR%ile min for expansion [50-95, step 5] |
| InpATRPct_Choppy | 40.0 | ATR%ile max for choppy [10-60, step 5] |
| InpBBWidth_Compress | 1.0 | BB width max for compression [0.1-5.0, step 0.1] |
| InpBBWidth_Expand | 2.5 | BB width min for expansion [0.5-10.0, step 0.1] |
| InpBreakout_Lookback | 20 | Donchian channel lookback (bars) [5-200, step 1] |
| InpVolume_Avg_Period | 50 | Volume averaging period (bars) [10-200, step 1] |
| InpVolume_Mult | 1.5 | Volume surge multiplier [1.0-5.0, step 0.1] |
| InpHTF_TF | 8 | HTF timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1 [1-9, step 1] |
| InpHTF_EMA_Period | 50 | HTF EMA period [5-500, step 1] |
| InpMin_RR_Ratio | 1.2 | Minimum R:R ratio (TP/SL) [0.5-10.0, step 0.1] |
| InpTrail_ATR_Buffer | 0.5 | BE SL buffer (×ATR×0.1) [0.1-5.0, step 0.1] |
| InpPartial_TP_Ratio | 0.0 | Partial TP close ratio at TP1 (0=disabled) [0.0-0.9, step 0.05] |
| InpMax_Hours_In_Trade | 240 | Max hours in trade (time-based exit) [1-2000, step 1] |
| InpQuickScalpATR | 0.0 | Quick scalp exit: min ATR profit (0=disabled) [0-5.0, step 0.1] |
| InpQuickScalpHours | 6.0 | Quick scalp exit: min hours in trade [1-48, step 1] |
| InpMax_Spread_Mult_Avg | 3.0 | Spread anomaly: reject if > N× rolling avg [1.0-10.0, step 0.5] |
| InpSpread_Avg_Bars | 30 | Spread rolling avg period (M1 bars) [5-200, step 1] |
| InpEnableBreakEven | true | Enable break-even |
| InpATR_Breakeven | 1.0 | Move to BE after N×ATR profit [0.5-10.0, step 0.1] |
| InpEnableTrailingStop | true | Enable ATR trailing stop |
| InpATR_TrailStart | 1.0 | Activate ATR trail after N×ATR profit [0.5-20.0, step 0.1] |
| InpATR_TrailStep | 0.8 | ATR trailing step [0.1-10.0, step 0.1] |
| InpEnableProfitLock | true | Lock profits in incremental steps |
| InpProfitLockIncrement | 1.0 | Lock every N×ATR of profit [0.5-10.0, step 0.1] |
| InpProfitLockStep | 0.5 | Distance behind current price (N×ATR) [0.1-5.0, step 0.1] |
| InpPyramidGateMode | PyramidGate_Off | Pyramid gate mode |
| InpProfitGatePoints | 10.0 | Minimum profit (points) per trade for pyramid [1-1000, step 1] |
| InpMaxOpenPos | 3 | Max concurrent positions (this symbol+magic) [1-20, step 1] |
| InpUseSessionFilter | true | Enable session time filter |
| InpServerGMTOffset | 0 | Broker server GMT offset (hours). 0=auto-detect. For backtesting set manually (e.g. 2=winter, 3=summer) [-12-14, step 1] |
| InpLondonStartH | 8 | London start hour (GMT) [0-23, step 1] |
| InpLondonStartM | 0 | London start minute [0-59, step 1] |
| InpLondonEndH | 16 | London end hour (GMT) [0-23, step 1] |
| InpLondonEndM | 30 | London end minute [0-59, step 1] |
| InpNYStartH | 13 | New York start hour (GMT) [0-23, step 1] |
| InpNYStartM | 0 | New York start minute [0-59, step 1] |
| InpNYEndH | 21 | New York end hour (GMT) [0-23, step 1] |
| InpNYEndM | 0 | New York end minute [0-59, step 1] |
| InpAvoidAsia | true | Avoid Asian session |
| InpAsiaStartH | 22 | Asia start hour (GMT) [0-23, step 1] |
| InpAsiaStartM | 0 | Asia start minute [0-59, step 1] |
| InpAsiaEndH | 6 | Asia end hour (GMT) [0-23, step 1] |
| InpAsiaEndM | 0 | Asia end minute [0-59, step 1] |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "1.00"
#property strict
#property description "Pipsgrowth.com EX01001 Adaptive EA — regime-switch dispatcher (Trend/Range/Breakout) with full 12-layer stack, configurable timeframe, trailing/BE/profit-lock toggles, pyramid gate, spread filter, new-bar gate. Works on any symbol/timeframe."
//==== Allowed includes ============================================
#include <Trade/Trade.mqh>
#include <Trade/PositionInfo.mqh>
#include <Trade/SymbolInfo.mqh>
#include <Trade/AccountInfo.mqh>
//--- pyramid gate mode enum
enum PyramidGateMode
{
PyramidGate_Off=0, // No pyramid gate
PyramidGate_ProfitOnly, // Require existing trades be in profit
PyramidGate_ProfitAndSL // Require profit + SL secured in profit
};
//==== (former hardcoded tunables — now all exposed as inputs) ======
//--- Timeframe mapping: 1=M1, 2=M3, 3=M5, 4=M10, 5=M15, 6=M30, 7=H1, 8=H4, 9=D1
ENUM_TIMEFRAMES MapTimeframe(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M3;
case 3: return PERIOD_M5;
case 4: return PERIOD_M10;
case 5: return PERIOD_M15;
case 6: return PERIOD_M30;
case 7: return PERIOD_H1;
case 8: return PERIOD_H4;
case 9: return PERIOD_D1;
default: return PERIOD_H1;
}
}
//==================================================================
// INPUTS
//==================================================================
input group "=== Identity ==="
input ulong InpMagic = 22201001; // Magic number (unique per EA) [10000000-99999999, step 1]
input string InpTradeComment = "Psgrowth.com Expert_01001"; // Trade comment
input string InpStrategyTag = "RegimeSwitch"; // Strategy tag (logs/index)
input bool InpDryRun = false; // Dry-run: skip real order sends (default OFF)
input bool InpKillSwitch = false; // Emergency kill switch (blocks new entries)
input bool InpEnableLogging = false; // Enable logging to journal
input int InpTimeframe = 7; // Timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1 [1-9, step 1]
input group "=== Risk & Sizing ==="
input double InpRiskPercent = 0.5; // Risk per trade, % of effective capital [0.1-5.0, step 0.1]
input double InpATR_SL_Mult = 2.0; // Initial SL = ATR × mult [0.5-10.0, step 0.1]
input double InpATR_TP_Mult = 4.0; // Initial TP = ATR × mult (sets R:R) [0.5-20.0, step 0.1]
input double InpFixedLot = 0.01; // Fallback lot when auto-sizing off [0.01-100.0, step 0.01]
input bool InpUseAutoLot = true; // Auto lot sizing from risk
input double InpMaxLot = 0.50; // Hard cap on lot size [0.01-100.0, step 0.01]
input bool InpSignalOnBarClose= true; // Evaluate signals only on bar closeFull 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.