P
PipsGrowth
OtherOpen Source – Free

Pipsgrowth EX01002 Adaptive

MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1

Pipsgrowth.com EX01002 AdaptiveEA — adaptive MA crossover with ATR volatility filtering, regime dispatch, GMT session filter, HTF confirmation, capital cap, trailing/BE/profit-lock, pyramid gate, spread filter, new-bar gate.

Overview

EX01002 Adaptive runs a regime-dispatched moving-average crossover. The core idea is that the same MA crossover cannot be trusted in every market, so before any signal fires the EA first asks ADX(14) what kind of market it is looking at, then lets the same close-vs-AMA test behave differently depending on the answer. The dispatcher is ClassifyRegime() and the only signal generator is MasterSignal().

The regime classifier reads two values on the working timeframe: ADX(14) and ATR(14). When ADX is at or above InpRegime_ADX_Trend (25 by default) the regime is STRONG_TREND; between InpRegime_ADX_Range (20) and 25 it is WEAK_TREND; below 20 it is RANGE. The classifier also looks at ATR in pips and blocks the entire trade when ATR is below InpATRMinPips (1 pip) — the spread would eat the move — or above InpATRMaxPips (0 = disabled) when volatility is too high for the fixed stop distance. Three more enum values (NEUTRAL, BREAKOUT, CHOPPY) exist in the type definition but are not produced by ClassifyRegime() in the current build; they are reserved for the broader Adaptive family.

MasterSignal() is the only place the EA produces a directional opinion. It reads two prior AMA buffer values (the 20-period SMA on close, default) and the close of the two most recent closed bars. In STRONG_TREND and WEAK_TREND, a buy fires either on a strict close[2]<AMA_prev and close[1]>AMA_curr crossover or on a continuation pattern where both closes sit above the AMA in the direction of the trade. In RANGE, NEUTRAL, and BREAKOUT, only the strict crossover is accepted. The continuation fallback is suppressed on purpose in ranging markets because in a range, two closes above the MA usually means a fake breakout rather than a real move.

The third gate is higher-timeframe alignment. HTFTrendAgrees() copies the close of bar 1 on a higher timeframe (default H4, set with InpHTF_TF=8) and compares it to a 50-period EMA on that same higher timeframe. A long signal on the working timeframe is allowed only if HTF close is above HTF EMA; a short only if HTF close is below HTF EMA. The HTF can be reconfigured from M1 to D1, and the EMA period from 5 to 500.

The no-trade gate is the longest single function in the file. NoTradeGate() runs nine checks in sequence and returns true (gate closed) at the first failure. It checks market open (Friday after 22:00 GMT blocked, Sunday before 22:00 GMT blocked), active session (London 08:00–16:30 GMT and New York 13:00–21:00 GMT; Asia 22:00–06:00 blocked by default via InpAvoidAsia), spread against InpMaxSpread (50 points default), effective capital against InpCapFloor (50 if a cap is set), trades today against InpMaxDailyTrades (5), realized today against -5% of effective capital, realized week against -9% of effective capital, cooldown timer (30 minutes after any losing close), consecutive losses (max 3 by default), total drawdown from session start against 20% (which latches g_ddKillSwitch and blocks all new entries), open-position cap (3 default), and the pyramid gate. The g_ddKillSwitch is a hard latch — once tripped, the EA refuses every new entry until the terminal restarts or the EA is reinitialized.

Lot sizing is risk-based. CalcLotByRisk() takes 1% of effective capital (the lower of InpCapAmount and current equity) and divides by the per-point SL cost, computed as StopLossPips × point × tickValue / tickSize. The resulting lot is rounded to the broker's lot step, clamped to the symbol's min and max, and capped at InpMaxLot (100 lots). When RiskPerTradePercent is set to zero the EA falls back to FixedLotSize=0.01 — useful for prop-firm challenge accounts where percentage risk is restricted.

Order sending goes through a wrapper with three retries. TryBuy_EX01002 / TrySell_EX01002 is called, and on requote, timeout, or price-changed retcodes the wrapper sleeps 100ms, refreshes the symbol, and retries. The wrapper also clamps the SL to the broker's minimum stop distance (SYMBOL_TRADE_STOPS_LEVEL) to prevent rejection, and it pre-checks free margin — if the order would exceed free margin, the entry is skipped without retries. The minimum R:R is enforced at the confirm step: TakeProfitPips/StopLossPips must be ≥ InpMin_RR_Ratio (1.2 default), so the default 1000/500 = 2.0 R:R passes comfortably.

ManageTrades() runs every tick. It walks the open positions for this magic and symbol, and applies in order: time-based exit at InpMax_Hours_In_Trade (240 hours = 10 days default), opposite-signal exit (close if MasterSignal() flips against the open direction), partial TP at 50% of position when profit reaches TakeProfitPips × InpPartial_TP_Ratio (i.e. 500 points with the default TP of 1000), trailing stop (200 points, ratchets only in the favorable direction), and the optional break-even (off by default; when enabled, SL moves to entry + 2 points once profit reaches 100 points) and profit lock (off by default; locks SL 20 points behind price for every 50 points of profit gained). The partial-close is tracked in a 100-slot array of ticket/partial-done flags so the same position never partials twice.

The trailing logic is a single-direction ratchet. For a long, once price has moved 200 points in profit, the new SL is current_price - 200, but only if that is higher than the current SL and above the open price. The same logic applies in mirror to shorts. Because the check runs every tick, the ratchet can step multiple times within a single candle when price is moving fast.

Cooldown and consecutive-loss tracking is event-driven. OnTradeTransaction() listens for DEAL_ADD events matching the magic and symbol. On entry deals, tradesToday increments. On exit deals, the net P&L (profit + swap + commission) is added to realizedToday and realizedWeek. When the net is negative, consecLosses increments and cooldownUntil is set to now + 30 minutes. When the net is positive, consecLosses resets to zero. The cooldown is a hard gate — the EA will not consider a new entry until the timer expires, regardless of how strong the signal looks.

The daily and weekly loss caps use effective capital as the denominator. With InpDailyLossPct=5.0 and effective capital of $1,000, the EA halts new entries once realizedToday drops to -$50. The realized totals reset at the start of each trading day and each Monday (in broker-local time, then converted to GMT via DetectGMTOffset() which reads the weekend gap in the H1 bar history).

What this EA does not do matters as much as what it does. There is no martingale, no grid, no averaging down. The only scaling mode is the pyramid gate, and PyramidGate_ProfitOnly / PyramidGate_ProfitAndSL both require every prior position to be in profit before any new entry is allowed. There is no news filter, no hedging, no swap-arbitrage. The flat zone between ADX 20 and ADX 25 is where the strategy's hit rate will degrade, and that is exactly why the daily/weekly/drawdown caps exist as the second layer of safety.

A reasonable backtest plan: run the MT5 Strategy Tester on XAUUSD M5 with "Every tick based on real ticks" for at least 12 months, and lower InpMaxDDPct to 10% during the test to confirm the kill switch actually trips. If the realized drawdown in the backtest is consistently below the configured cap, the safety layer is wired correctly.

Strategy Deep Dive

On every closed bar the EA refreshes four handles — a 20-period SMA on close, ATR(14), ADX(14), and an H4 EMA(50) — and runs ClassifyRegime() to bucket the bar as STRONG_TREND, WEAK_TREND, or RANGE. MasterSignal() then tests the prior two closes against the SMA and returns +1, -1, or 0, with the continuation pattern only accepted in trend regimes. HTFTrendAgrees() gates the result against the H4 close-vs-EMA direction, and NoTradeGate() layers in nine vetoes (market open, session, spread, capital floor, daily/weekly loss, cooldown, consecutive losses, drawdown kill switch, position cap, pyramid gate) before CalcLotByRisk() sizes the trade to 1% of effective capital. ManageTrades() runs on every tick to enforce the 240-hour time stop, opposite-signal exit, 50% partial at 500 points, and a 200-point trailing ratchet.

Entry Signal

A long fires on close[2] below the 20-period SMA and close[1] above it, with ADX(14) confirming trend or range regime, the higher-timeframe close above its 50-EMA, and the no-trade gate open. A short mirrors the test. In trend regimes a continuation pattern (two closes on the same side of the SMA in the trade direction) is also accepted; in range regimes only the strict crossover is allowed.

Exit Signal

Exits are layered: time-based close at 240 hours, opposite-signal close when MasterSignal() flips, 50% partial close when profit reaches 500 points (half of the 1000-point TP), then a 200-point trailing stop that ratchets only in the favorable direction. Optional break-even and profit-lock modules are wired but disabled by default.

Stop Loss

Fixed stop of 500 points from entry, normalized to the broker's minimum stop distance. The 20% total-drawdown kill switch (latched on g_ddKillSwitch) blocks every new entry once equity drops 20% from the session start balance.

Take Profit

Fixed take-profit of 1000 points from entry, giving a 2:1 R:R that comfortably clears the 1.2 minimum-R:R confirm gate. A 50% partial close fires at 500 points profit, leaving the remainder to run to TP or to the trailing stop.

Best For

Minimum recommended balance: $100. Best fit is XAUUSD M5 with a low-spread broker (50-point cap rejects wide spreads on gold) during London 08:00–16:30 GMT and New York 13:00–21:00 GMT; Asia is blocked by default. The fixed 500/1000 stop and take-profit distances are sized for XAUUSD's typical pip value, so on FX majors reduce both proportionally or the risk-per-trade calc will over-size the position. Conservative 1% risk, 30-minute cooldown after a loss, 5%/9% daily/weekly caps, and a 20% drawdown kill switch make this suitable for traders who want a regime-aware system with hard safety rails. Allow at least 6 months of forward testing on the target symbol before any live deployment.

Strategy Logic

Pipsgrowth EX01002 Adaptive — Strategy Logic Analysis (from .mq5 source)

Family: Adaptive Magic: 22201002 Version: 4.00

BRIEF: An adaptive, robust, and production-ready Expert Advisor using Moving Average crossover with ATR volatility filtering. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • andle_ama
  • andle_atr
  • andle_adx
  • andle_htf_ema

KEY FUNCTIONS:

  • RegimeName()
  • IsPartialDone()
  • SetPartialDone()
  • CleanupPartialStates()
  • LogDebug()
  • DetectGMTOffset()
  • DayStart()
  • WeekStart()
  • EffectiveCapital()
  • NormalizePrice()
  • CalcLotByRisk()
  • NormalizeLot()
  • ...and 21 more

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (62 total across 11 groups):

  • [=== Identity ===] EA_Name = "AdaptiveEA" // EA Name
  • [=== Identity ===] MagicNumber = 22201002 // Magic Number [10000000-99999999, step 1]
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_01002" // Trade Comment
  • [=== Identity ===] InpTimeframe = 3 // Timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1 [1-9, step 1]
  • [=== Identity ===] InpEnableLogging = true // Enable logging to journal
  • [=== Risk / Sizing ===] RiskPerTradePercent = 1.0 // Risk per trade, % of effective capital [0.1-5.0, step 0.1]
  • [=== Risk / Sizing ===] FixedLotSize = 0.01 // Fixed lot size (if RiskPerTradePercent=0) [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]
  • [=== 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 Limits ===] InpDailyLossPct = 5.0 // Max daily loss, % of effective capital [0.5-20.0, step 0.5]
  • [=== Daily / Weekly Limits ===] InpWeeklyLossPct = 9.0 // Max weekly loss, % of effective capital [1.0-50.0, step 0.5]
  • [=== Daily / Weekly Limits ===] InpMaxDailyTrades = 5 // Max new entries per day [1-50, step 1]
  • [=== Daily / Weekly Limits ===] InpCooldownMin = 30 // Cooldown minutes after a loss [0-1440, step 1]
  • [=== Daily / Weekly Limits ===] InpMaxConsecLosses = 3 // Max consecutive losses before halt (0=disable) [0-20, step 1]
  • [=== Signal ===] AdaptiveMAPeriod = 20 // Adaptive Moving Average Period [2-500, step 1]
  • [=== Signal ===] AdaptiveMAMethod = MODE_SMA // Adaptive Moving Average Method
  • [=== Signal ===] AdaptiveMAPrice = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Adaptive Moving Average Price
  • [=== Regime Thresholds ===] InpADX_Period = 14 // ADX period [2-100, step 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 ===] InpATR_Period = 14 // ATR period [2-100, step 1]
  • [=== Regime Thresholds ===] InpATRMinPips = 1.0 // Absolute minimum ATR in pips (0 disables) [0-100, step 0.1]
  • [=== Regime Thresholds ===] InpATRMaxPips = 0.0 // Absolute maximum ATR in pips (0 disables) [0-200, 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]
  • [=== Exit ===] InpEnableTrailingStop = true // Enable trailing stop
  • [=== Exit ===] StopLossPips = 500 // Stop Loss in points [10-10000, step 10]
  • [=== Exit ===] TakeProfitPips = 1000 // Take Profit in points [10-20000, step 10]
  • [=== Exit ===] TrailingStopPips = 200 // Trailing Stop in points [10-5000, step 10]
  • [=== Exit ===] InpEnableBreakEven = false // Enable break-even
  • [=== Exit ===] BreakEvenTriggerPips = 100 // Profit trigger to activate BE (in points) [10-5000, step 10]
  • [=== Exit ===] BreakEvenOffsetPips = 2 // Offset from entry to lock (in points) [0-500, step 1]
  • [=== Exit ===] InpEnableProfitLock = false // Lock profits in incremental steps
  • [=== Exit ===] ProfitLockIncrement = 50 // Lock every X points of profit [10-2000, step 10]
  • [=== Exit ===] ProfitLockStep = 20 // Distance behind current price (in points) [1-500, step 1]
  • [=== Exit ===] InpPartial_TP_Ratio = 0.5 // Partial TP close ratio at TP1 [0.1-0.9, step 0.05]
  • [=== Exit ===] InpMax_Hours_In_Trade = 240 // Max hours in trade (time-based exit) [1-2000, step 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 ===] InpMaxOpenPositions = 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 [-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]
  • [=== Safety Caps ===] InpMaxDDPct = 20.0 // Max total drawdown % before kill switch (0=disable) [0-90, step 1]
  • [=== Safety Caps ===] InpKillSwitch = false // Manual kill switch — stops all new entries
  • [=== Safety Caps ===] InpDryRun = false // Dry-run mode: log signals without trading
  • [=== Safety Caps ===] InpMaxLot = 100.0 // Maximum lot size cap [0.01-10000, step 0.01]
Pseudocode
// Pipsgrowth EX01002 Adaptive — Execution Flow (from source analysis)
// Family: Adaptive
// An adaptive, robust, and production-ready Expert Advisor using Moving Average crossover with ATR volatility filtering. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

ON_INIT:
    Create indicator handles: andle_ama, andle_atr, andle_adx, andle_htf_ema
    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:
M5H1

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
EA_Name"AdaptiveEA"EA Name
MagicNumber22201002Magic Number [10000000-99999999, step 1]
InpTradeComment"Psgrowth.com Expert_01002"Trade Comment
InpTimeframe3Timeframe: 1=M1,2=M3,3=M5,4=M10,5=M15,6=M30,7=H1,8=H4,9=D1 [1-9, step 1]
InpEnableLoggingtrueEnable logging to journal
RiskPerTradePercent1.0Risk per trade, % of effective capital [0.1-5.0, step 0.1]
FixedLotSize0.01Fixed lot size (if RiskPerTradePercent=0) [0.01-100.0, step 0.01]
InpSignalOnBarClosetrueEvaluate signals only on bar close
InpMaxSpread50Max allowed spread in points (0=disable) [0-200, step 1]
InpCapAmount0.0Real-money capital cap, account currency [10-100000, step 10]
InpCapFloor50.0Floor below which new entries blocked [1-10000, step 1]
InpDailyLossPct5.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]
InpMaxDailyTrades5Max 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]
AdaptiveMAPeriod20Adaptive Moving Average Period [2-500, step 1]
AdaptiveMAMethodMODE_SMAAdaptive Moving Average Method
AdaptiveMAPrice1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Adaptive Moving Average Price
InpADX_Period14ADX period [2-100, step 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]
InpATR_Period14ATR period [2-100, step 1]
InpATRMinPips1.0Absolute minimum ATR in pips (0 disables) [0-100, step 0.1]
InpATRMaxPips0.0Absolute maximum ATR in pips (0 disables) [0-200, 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]
InpEnableTrailingStoptrueEnable trailing stop
StopLossPips500Stop Loss in points [10-10000, step 10]
TakeProfitPips1000Take Profit in points [10-20000, step 10]
TrailingStopPips200Trailing Stop in points [10-5000, step 10]
InpEnableBreakEvenfalseEnable break-even
BreakEvenTriggerPips100Profit trigger to activate BE (in points) [10-5000, step 10]
BreakEvenOffsetPips2Offset from entry to lock (in points) [0-500, step 1]
InpEnableProfitLockfalseLock profits in incremental steps
ProfitLockIncrement50Lock every X points of profit [10-2000, step 10]
ProfitLockStep20Distance behind current price (in points) [1-500, step 1]
InpPartial_TP_Ratio0.5Partial TP close ratio at TP1 [0.1-0.9, step 0.05]
InpMax_Hours_In_Trade240Max hours in trade (time-based exit) [1-2000, step 1]
InpPyramidGateModePyramidGate_OffPyramid gate mode
InpProfitGatePoints10.0Minimum profit (points) per trade for pyramid [1-1000, step 1]
InpMaxOpenPositions3Max concurrent positions (this symbol+magic) [1-20, step 1]
InpUseSessionFiltertrueEnable session time filter
InpServerGMTOffset0Broker server GMT offset (hours). 0=auto-detect [-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]
InpMaxDDPct20.0Max total drawdown % before kill switch (0=disable) [0-90, step 1]
InpKillSwitchfalseManual kill switch — stops all new entries
InpDryRunfalseDry-run mode: log signals without trading
InpMaxLot100.0Maximum lot size cap [0.01-10000, step 0.01]
Source Code (.mq5)Open Source
Pipsgrowth_com_EX01002.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "4.00"
#property strict
#property description "Pipsgrowth.com EX01002 AdaptiveEA — adaptive MA crossover with ATR volatility filtering, regime dispatch, GMT session filter, HTF confirmation, capital cap, trailing/BE/profit-lock, pyramid gate, spread filter, new-bar gate."
#include <Trade\Trade.mqh>
#include <Trade/PositionInfo.mqh>
#include <Trade/SymbolInfo.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
};

//--- regime enum
enum ENUM_REGIME
{
   REGIME_NEUTRAL=0,
   REGIME_STRONG_TREND,
   REGIME_WEAK_TREND,
   REGIME_RANGE,
   REGIME_BREAKOUT,
   REGIME_CHOPPY
};

//--- 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_M5;
   }
}

string RegimeName(ENUM_REGIME r)
{
   switch(r)
   {
      case REGIME_STRONG_TREND: return "STRONG_TREND";
      case REGIME_WEAK_TREND:   return "WEAK_TREND";
      case REGIME_RANGE:        return "RANGE";
      case REGIME_BREAKOUT:     return "BREAKOUT";
      case REGIME_CHOPPY:       return "CHOPPY";
      default:                  return "NEUTRAL";
   }
}

//--- Input Parameters ---

Full source code available on download

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

Tags:ex01002adaptivepipsgrowthfreemt5xauusd

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_EX01002.mq5
File Size58.0 KB
Versionv4.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyOther
Risk LevelMedium Risk
Timeframes
M5H1
Currency Pairs
XAUUSD
Min. Deposit$100