P
PipsGrowth
OtherOpen Source – Free

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.

Entry Signal

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.

Exit Signal

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.

Stop Loss

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.

Take Profit

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.

Best For

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 MT5 indicators

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 per EA) [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 (default OFF)
  • [=== 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, step 0.1]
  • [=== Risk & Sizing ===] InpATR_SL_Mult = 2.0 // Initial SL = ATR × mult [0.5-10.0, step 0.1]
  • [=== Risk & Sizing ===] InpATR_TP_Mult = 4.0 // Initial TP = ATR × mult (sets R:R) [0.5-20.0, step 0.1]
  • [=== Risk & Sizing ===] InpFixedLot = 0.01 // Fallback lot when auto-sizing off [0.01-100.0, step 0.01]
  • [=== Risk & Sizing ===] InpUseAutoLot = true // Auto lot sizing from risk
  • [=== Risk & Sizing ===] InpMaxLot = 0.50 // Hard cap on lot size [0.01-100.0, step 0.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, step 0.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, step 0.5]
  • [=== Daily / Weekly / Total Limits ===] InpWeeklyLossPct = 9.0 // Max weekly loss, % of effective capital [1.0-50.0, step 0.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 // EMA fast period [2-500, step 1]
  • [=== Signal / Regime ===] InpEMA_Slow = 50 // EMA slow period [2-500, step 1]
  • [=== Signal / Regime ===] InpEMA_Filter = 200 // EMA trend filter period [10-1000, step 1]
  • [=== Signal / Regime ===] InpRSI_Period = 14 // RSI period [2-100, step 1]
  • [=== Signal / Regime ===] InpRSI_Oversold = 30 // RSI oversold threshold [1-49, step 1]
  • [=== Signal / Regime ===] InpRSI_Overbought = 70 // RSI overbought threshold [51-99, step 1]
  • [=== Signal / Regime ===] InpRSI_NeutralLow = 40 // RSI neutral low (trend signal floor) [1-49, step 1]
  • [=== Signal / Regime ===] InpRSI_NeutralHigh = 70 // RSI neutral high (trend signal ceiling) [51-99, step 1]
  • [=== Indicator Periods ===] InpADX_Period = 14 // ADX period [2-100, step 1]
  • [=== Indicator Periods ===] InpATR_Period = 14 // ATR period [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, step 0.1]
  • [=== Regime Thresholds ===] InpRegime_ADX_Trend = 25.0 // ADX threshold for trend regime [10-60, step 0.5]
  • [=== Regime Thresholds ===] InpRegime_ADX_Range = 20.0 // ADX threshold for range regime [5-50, step 0.5]
  • [=== Regime Thresholds ===] InpATRPct_BK_Min = 0.6 // ATR%ile min for breakout regime [0.1-1.0, step 0.05]
  • [=== Regime Thresholds ===] InpATRPct_Lookback = 50 // ATR percentile lookback bars [10-200, step 1]
  • [=== Regime Thresholds ===] InpADX_Min_Signal = 15.0 // Min ADX on closed bar for signal validity [5-50, step 0.5]
  • [=== Regime Thresholds ===] InpADX_WeakOffset = 5.0 // ADX offset below trend threshold for weak trend [1-20, step 0.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 // BB width max for compression [0.1-5.0, step 0.1]
  • [=== Regime Thresholds ===] InpBBWidth_Expand = 2.5 // BB width min for expansion [0.5-10.0, step 0.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, step 0.1]
  • [=== HTF Confirmation ===] 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]
  • [=== HTF Confirmation ===] InpHTF_EMA_Period = 50 // HTF EMA period [5-500, step 1]
  • [=== HTF Confirmation ===] InpMin_RR_Ratio = 1.2 // Minimum R:R ratio (TP/SL) [0.5-10.0, step 0.1]
  • [=== Trade Management Tunables ===] InpTrail_ATR_Buffer = 0.5 // BE SL buffer (×ATR×0.1) [0.1-5.0, step 0.1]
  • [=== Trade Management Tunables ===] InpPartial_TP_Ratio = 0.0 // Partial TP close ratio at TP1 (0=disabled) [0.0-0.9, step 0.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: min ATR profit (0=disabled) [0-5.0, step 0.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, step 0.5]
  • [=== Spread / Safety Caps ===] InpSpread_Avg_Bars = 30 // Spread rolling avg period (M1 bars) [5-200, step 1]
  • [=== Exit / Manage ===] InpEnableBreakEven = true // Enable break-even
  • [=== Exit / Manage ===] InpATR_Breakeven = 1.0 // Move to BE after N×ATR profit [0.5-10.0, step 0.1]
  • [=== Exit / Manage ===] InpEnableTrailingStop = true // Enable ATR trailing stop
  • [=== Exit / Manage ===] InpATR_TrailStart = 1.0 // Activate ATR trail after N×ATR profit [0.5-20.0, step 0.1]
  • [=== Exit / Manage ===] InpATR_TrailStep = 0.8 // ATR trailing step [0.1-10.0, step 0.1]
  • [=== Exit / Manage ===] InpEnableProfitLock = true // Lock profits in incremental steps
  • [=== Exit / Manage ===] InpProfitLockIncrement = 1.0 // Lock every N×ATR of profit [0.5-10.0, step 0.1]
  • [=== Exit / Manage ===] InpProfitLockStep = 0.5 // Distance behind current price (N×ATR) [0.1-5.0, step 0.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 in GMT) ===] InpUseSessionFilter = true // Enable session time filter
  • [=== Session Filter (all times in GMT) ===] InpServerGMTOffset = 0 // Broker server GMT offset (hours). 0=auto-detect. For backtesting set manually (e.g. 2=winter, 3=summer) [-12-14, step 1]
  • [=== Session Filter (all times in GMT) ===] InpLondonStartH = 8 // London start hour (GMT) [0-23, step 1]
  • [=== Session Filter (all times in GMT) ===] InpLondonStartM = 0 // London start minute [0-59, step 1]
  • [=== Session Filter (all times in GMT) ===] InpLondonEndH = 16 // London end hour (GMT) [0-23, step 1]
  • [=== Session Filter (all times in GMT) ===] InpLondonEndM = 30 // London end minute [0-59, step 1]
  • [=== Session Filter (all times in GMT) ===] InpNYStartH = 13 // New York start hour (GMT) [0-23, step 1]
  • [=== Session Filter (all times in GMT) ===] InpNYStartM = 0 // New York start minute [0-59, step 1]
  • [=== Session Filter (all times in GMT) ===] InpNYEndH = 21 // New York end hour (GMT) [0-23, step 1]
  • [=== Session Filter (all times in GMT) ===] InpNYEndM = 0 // New York end minute [0-59, step 1]
  • [=== Session Filter (all times in GMT) ===] InpAvoidAsia = true // Avoid Asian session
  • [=== Session Filter (all times in GMT) ===] InpAsiaStartH = 22 // Asia start hour (GMT) [0-23, step 1]
  • [=== Session Filter (all times in GMT) ===] InpAsiaStartM = 0 // Asia start minute [0-59, step 1]
  • [=== Session Filter (all times in GMT) ===] InpAsiaEndH = 6 // Asia end hour (GMT) [0-23, step 1]
  • [=== Session Filter (all times in GMT) ===] InpAsiaEndM = 0 // Asia end minute [0-59, step 1]
Pseudocode
// 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

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

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
InpMagic22201001Magic number (unique per EA) [10000000-99999999, step 1]
InpTradeComment"Psgrowth.com Expert_01001"Trade comment
InpStrategyTag"RegimeSwitch"Strategy tag (logs/index)
InpDryRunfalseDry-run: skip real order sends (default OFF)
InpKillSwitchfalseEmergency kill switch (blocks new entries)
InpEnableLoggingfalseEnable logging to journal
InpTimeframe7Timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1 [1-9, step 1]
InpRiskPercent0.5Risk per trade, % of effective capital [0.1-5.0, step 0.1]
InpATR_SL_Mult2.0Initial SL = ATR × mult [0.5-10.0, step 0.1]
InpATR_TP_Mult4.0Initial TP = ATR × mult (sets R:R) [0.5-20.0, step 0.1]
InpFixedLot0.01Fallback lot when auto-sizing off [0.01-100.0, step 0.01]
InpUseAutoLottrueAuto lot sizing from risk
InpMaxLot0.50Hard cap on lot size [0.01-100.0, step 0.01]
InpSignalOnBarClosetrueEvaluate signals only on bar close
InpMaxSpread50Max allowed spread in points (0=disable) [0-200, step 1]
InpCommissionPerLot7.0Commission cost per lot (account currency) [0-50, step 0.5]
InpCapAmount0.0Real-money capital cap, account currency [10-100000, step 10]
InpCapFloor50.0Floor below which new entries blocked [1-10000, step 1]
InpDailyLossPct3.0Max daily loss, % of effective capital [0.5-20.0, step 0.5]
InpWeeklyLossPct9.0Max weekly loss, % of effective capital [1.0-50.0, step 0.5]
InpMaxDDPct20.0Max total account drawdown % from start balance (0=disable) [5-50, step 1]
InpMaxDailyTrades10Max new entries per day [1-50, step 1]
InpCooldownMin30Cooldown minutes after a loss [0-1440, step 1]
InpMaxConsecLosses3Max consecutive losses before halt (0=disable) [0-20, step 1]
InpEMA_Fast21EMA fast period [2-500, step 1]
InpEMA_Slow50EMA slow period [2-500, step 1]
InpEMA_Filter200EMA trend filter period [10-1000, step 1]
InpRSI_Period14RSI period [2-100, step 1]
InpRSI_Oversold30RSI oversold threshold [1-49, step 1]
InpRSI_Overbought70RSI overbought threshold [51-99, step 1]
InpRSI_NeutralLow40RSI neutral low (trend signal floor) [1-49, step 1]
InpRSI_NeutralHigh70RSI neutral high (trend signal ceiling) [51-99, step 1]
InpADX_Period14ADX period [2-100, step 1]
InpATR_Period14ATR period [2-100, step 1]
InpBB_Period20Bollinger Bands period [2-100, step 1]
InpBB_Deviation2.0Bollinger Bands deviation [0.1-5.0, step 0.1]
InpRegime_ADX_Trend25.0ADX threshold for trend regime [10-60, step 0.5]
InpRegime_ADX_Range20.0ADX threshold for range regime [5-50, step 0.5]
InpATRPct_BK_Min0.6ATR%ile min for breakout regime [0.1-1.0, step 0.05]
InpATRPct_Lookback50ATR percentile lookback bars [10-200, step 1]
InpADX_Min_Signal15.0Min ADX on closed bar for signal validity [5-50, step 0.5]
InpADX_WeakOffset5.0ADX offset below trend threshold for weak trend [1-20, step 0.5]
InpATRPct_StrongTrend50.0ATR%ile min for strong trend [10-90, step 5]
InpATRPct_Compress25.0ATR%ile max for compression [5-50, step 5]
InpATRPct_Expand80.0ATR%ile min for expansion [50-95, step 5]
InpATRPct_Choppy40.0ATR%ile max for choppy [10-60, step 5]
InpBBWidth_Compress1.0BB width max for compression [0.1-5.0, step 0.1]
InpBBWidth_Expand2.5BB width min for expansion [0.5-10.0, step 0.1]
InpBreakout_Lookback20Donchian channel lookback (bars) [5-200, step 1]
InpVolume_Avg_Period50Volume averaging period (bars) [10-200, step 1]
InpVolume_Mult1.5Volume surge multiplier [1.0-5.0, step 0.1]
InpHTF_TF8HTF 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_Period50HTF EMA period [5-500, step 1]
InpMin_RR_Ratio1.2Minimum R:R ratio (TP/SL) [0.5-10.0, step 0.1]
InpTrail_ATR_Buffer0.5BE SL buffer (×ATR×0.1) [0.1-5.0, step 0.1]
InpPartial_TP_Ratio0.0Partial TP close ratio at TP1 (0=disabled) [0.0-0.9, step 0.05]
InpMax_Hours_In_Trade240Max hours in trade (time-based exit) [1-2000, step 1]
InpQuickScalpATR0.0Quick scalp exit: min ATR profit (0=disabled) [0-5.0, step 0.1]
InpQuickScalpHours6.0Quick scalp exit: min hours in trade [1-48, step 1]
InpMax_Spread_Mult_Avg3.0Spread anomaly: reject if > N× rolling avg [1.0-10.0, step 0.5]
InpSpread_Avg_Bars30Spread rolling avg period (M1 bars) [5-200, step 1]
InpEnableBreakEventrueEnable break-even
InpATR_Breakeven1.0Move to BE after N×ATR profit [0.5-10.0, step 0.1]
InpEnableTrailingStoptrueEnable ATR trailing stop
InpATR_TrailStart1.0Activate ATR trail after N×ATR profit [0.5-20.0, step 0.1]
InpATR_TrailStep0.8ATR trailing step [0.1-10.0, step 0.1]
InpEnableProfitLocktrueLock profits in incremental steps
InpProfitLockIncrement1.0Lock every N×ATR of profit [0.5-10.0, step 0.1]
InpProfitLockStep0.5Distance behind current price (N×ATR) [0.1-5.0, step 0.1]
InpPyramidGateModePyramidGate_OffPyramid gate mode
InpProfitGatePoints10.0Minimum profit (points) per trade for pyramid [1-1000, step 1]
InpMaxOpenPos3Max concurrent positions (this symbol+magic) [1-20, step 1]
InpUseSessionFiltertrueEnable session time filter
InpServerGMTOffset0Broker server GMT offset (hours). 0=auto-detect. For backtesting set manually (e.g. 2=winter, 3=summer) [-12-14, step 1]
InpLondonStartH8London start hour (GMT) [0-23, step 1]
InpLondonStartM0London start minute [0-59, step 1]
InpLondonEndH16London end hour (GMT) [0-23, step 1]
InpLondonEndM30London end minute [0-59, step 1]
InpNYStartH13New York start hour (GMT) [0-23, step 1]
InpNYStartM0New York start minute [0-59, step 1]
InpNYEndH21New York end hour (GMT) [0-23, step 1]
InpNYEndM0New York end minute [0-59, step 1]
InpAvoidAsiatrueAvoid Asian session
InpAsiaStartH22Asia start hour (GMT) [0-23, step 1]
InpAsiaStartM0Asia start minute [0-59, step 1]
InpAsiaEndH6Asia end hour (GMT) [0-23, step 1]
InpAsiaEndM0Asia end minute [0-59, step 1]
Source Code (.mq5)Open Source
Pipsgrowth_com_EX01001.mq5
#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 close

Full source code available on download

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

Tags:ex01001adaptivepipsgrowthfreemt5xauusd

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_EX01001.mq5
File Size68.6 KB
Versionv1.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyOther
Risk LevelMedium Risk
Timeframes
H1
Currency Pairs
XAUUSD
Min. Deposit$100