Pipsgrowth EX18107 TrendFollow
MT5 Expert Advisor (Open Source) · USDJPY, EURUSD, GBPUSD, XAUUSD · M5, H1
Pipsgrowth.com EX18107 newHullv1 — Adaptive Hull MA trend-follower, full 12-layer stack.
Overview
Pipsgrowth EX18107 is a single-symbol trend-rider that pairs a 34-period linear-weighted Hull moving average with a 14-period ADX to grade trend strength, then uses an adaptive ATR percentile band to filter entries that would fire during either flat or blow-off volatility. The Hull is built with MQL5's standard iMA(..., MODE_LWMA, PRICE_CLOSE) at the chart timeframe, not a custom indicator — the brief's references to a proprietary Hull file are stylistic; the actual calculation is the standard LWMA the platform ships with. Slope is read across InpTrendConfirmBars consecutive bars (default 2): long setups require hull[i] > hull[i+1] for every bar in the window, and short setups require the inverse. That two-bar agreement is what kills whipsaw entries when a single noisy close punches through the average. ADX then has to sit between 22 and 45 inclusive; sub-22 means the trend is too soft to commit, super-45 means the move is exhausted and reversion risk is high.
The adaptive ATR layer is the EA's first non-obvious design choice. Every new bar the UpdateAdaptiveATRState() function rolls a 120-bar lookback of ATR(14) values, divides each by the calibrated base ATR for the pair (set in CalibratePair() from the first 200 bars of history), and writes the result into a gATRState struct holding the P20 and P80 percentiles. Entry is permitted only when the live ATR ratio falls inside the resulting band, with hard floor 0.70 and hard cap 1.60 that the percentile band is clamped against so a freak calm or spike can't open the gate. InpATRSessionMultiplier (1.05 by default) widens the upper bound during the allowed session to reflect the JPY/USD volatility bias noted in the source comments. If the adaptive state isn't ready yet, the EA returns; aggressive mode is the only path that proceeds with raw ATR.
A higher-timeframe Hull (InpEnableHTFHullConfirm, default on) reads three consecutive bars from an LWMA(55) on the timeframe selected by InpHTFHullTimeframe (default 9 in the source comment, which is out of the 1-7 enum range and silently maps to PERIOD_H1 via MapTimeframeInt). Entries that disagree with the HTF slope are blocked unless aggressive mode overrides, or unless the local Hull slope is at least 0.25 ATR per bar strong and ADX already passed — that fallback is what lets the EA catch the start of a new leg before the higher timeframe has caught up.
Risk sizing uses InpRiskPercentPerTrade (0.75% default) divided by the configured number of pyramid slots, then converts dollars-to-tons via stopDistance * gPointValue (point value is calibrated per-symbol inside CalibratePair() — _Point is 0.0001 for major pairs, 0.01 for JPY, 0.01 for XAUUSD). volumeAdjustment then scales the lot up or down between 0.35x and 1.15x depending on a signalQuality score built from Hull slope magnitude (in ATR units) and ADX margin above the entry floor. The minimum is the broker's SYMBOL_VOLUME_MIN and the result is rounded to the symbol's volume step. The same risk math applies to the pyramid add, but the add can only fire once the original position has covered at least 40% of its TP distance and price has advanced between 1.3 and 2.5 ATR from the prior entry — that is the CanOpenPyramidPosition() gate. With InpMaxSimultaneousPositions at 2 the EA holds at most one base plus one add per direction.
Stop and take are ATR-anchored, not fixed-pip. Base SL multiplier is 2.2x ATR (range 1.8-3.2), base TP multiplier is 5.5x ATR (range 3.5-8.0). When regime detection is on, those multipliers are pushed to 1.25x in trending regimes and 0.85x in ranging regimes — trending gets more room to breathe, ranging gets tighter so the EA doesn't donate money to false breakouts. A minimum reward ratio of 1.3 is enforced before the order sends; if the regime adjustment would compress TP below that floor, TP is stretched up to stopMultiplier * 1.3 instead. Low signalQuality (<0.8) tightens SL/TP by another 10%; high quality (>1.5) widens TP up to 30%. The numbers are written into the server-side SL/TP brackets at open — there is no virtual-stop layer.
Position management is split across two functions. ApplyBreakevenLock() activates once profit clears the broker's stop-level × 2 OR InpPyramidSpacingATRMin × ATR (whichever is larger), then walks the stop to openPrice + 0.1 × ATR of buffer. The activation trigger is multiplied by 1.2 when the most recent pyramid leg is the one being evaluated, so the add gets a slightly larger head-start before its stop moves. ApplyTrailingStops() then takes over once profit clears InpTrailingActivationATR (2.0) and ratchets the stop each tick by InpTrailingDistanceBase (1.4 ATR, clamped 0.9-2.2). Both modify the open position through TryModify_EX18107(), which retries up to three times on requote/timeout.
Exits beyond the trailing logic are event-driven. The ManagePositions() loop checks two conditions every tick: a Hull slope flip against the position (over InpHullReversalBars bars, default 1) and an ADX weakness state (InpADXWeaknessThreshold 18 OR a 25% drop from the rolling peak). InpEnableMinProfitProtection (default on) means neither exit fires while the position is in net loss. HandleEmergencyControls() runs after that: if the live spread blows past InpSpreadMaxPoints × InpEmergencySpreadMultiplier (2.5), every open position is force-closed through TryClose_EX18107(). The news filter input is wired but the source ships with no data source; the function logs a one-shot warning and does nothing else — operators who want true NFP avoidance need to add a feed externally.
The adaptive spread filter is the last filter between the signal and the order ticket. On every new bar UpdateAdaptiveSpreadState() reads the most recent 100 bars' point-spread values, takes the P85, and multiplies by 1.3 to get the adaptive cap, with an absolute ceiling of 25 points from InpSpreadMaxPoints. Entries are rejected when current spread exceeds the cap. The same P85-derived value becomes the baseline for the emergency exit multiplier. If the user disables adaptive spread, the absolute 25-point cap remains as a fallback. Aggressive mode widens the cap by 1.20x.
Session gating comes from IsSessionAllowed(), which checks the server-time hour against three optional windows: Asian (00-08), London (07-17), and New York (13-23). Defaults are Asian + NY on, London off. Aggressive mode overrides a blocked session. There is no day-of-week filter; the EA trades Monday through Friday within those hours. Pairs the source comments flag as portable are USDJPY, EURUSD, GBPUSD, and XAUUSD. The pip multiplier is auto-detected from the symbol name (JPY and XAU get 100, others get 10000) and the per-symbol point value is recalculated at init from SYMBOL_TRADE_TICK_VALUE / SYMBOL_TRADE_TICK_SIZE so the risk math is correct on each instrument.
A few notes on the parts that look more impressive in the brief than in the code. The '12-layer architecture' header claim is mostly honoured — REGIME, SIGNAL, ENTRY, CONFIRM (HTF Hull), NO-TRADE (spread/ATR band/session/drawdown), RISK, SIZING, MANAGE, EXIT, and SCALING (pyramiding) all exist as distinct code paths. The two missing ones are CAPITAL CAP (the 15% drawdown cap is implemented as a flat entry block, not a hard stop-out of the account) and OnTester (no custom optimization criterion is defined — the EA uses MT5's standard tester scoring). The g_trade_wrappers_EX18107 object exists alongside gTrade purely so the TryClose_EX18107, TryClosePartial_EX18107, and TryModify_EX18107 retry helpers can reuse a 200ms/100ms retry loop; it is not a second trading path. The MapTimeframeInt and g_InpHTFHullTimeframe symbols are declared 12 times in the source — a copy-paste artifact of the per-section input blocks, which the MQL5 compiler absorbs without complaint.
Practical expectations: the EA trades a small number of high-conviction setups per week on M5 and fewer on H1. Backtest equity curves tend to be step-functions — long flat patches interrupted by 1-3 leg trends it captures cleanly, and small scratches during chop. The 15% max-drawdown input is a hard entry block, not an emergency close, so an open position can still push the account further into drawdown — operators who want a hard kill-switch should reduce InpRiskPercentPerTrade and InpMaxSimultaneousPositions together rather than rely on this gate alone.
Strategy Deep Dive
On OnInit the EA calls InitIndicators() to create four handles: a 34-period LWMA Hull on the chart timeframe, a 14-period ADX, a 14-period ATR, and a 55-period LWMA Hull on g_InpHTFHullTimeframe. CalibratePair() then walks the first 200 bars of history to compute the pair's base ATR and base ADX, sets a pip multiplier (100 for JPY/XAU, 10000 for majors), and derives gPointValue from SYMBOL_TRADE_TICK_VALUE / SYMBOL_TRADE_TICK_SIZE. Every new bar UpdateAdaptiveATRState() and UpdateAdaptiveSpreadState() refresh the percentile bands; on every tick DetectMarketRegime() classifies the market as TRENDING, RANGING, VOLATILE, or CONSOLIDATING from the latest ADX and ATR-ratio read. CheckForEntry() runs only on new bars and passes the signal through seven sequential gates — session, drawdown cap, margin, ATR band, ADX range, volume ratio, HTF Hull confirm — before computing ATR-scaled SL/TP, sizing by InpRiskPercentPerTrade, and calling gTrade.Buy or gTrade.Sell. ManagePositions() then runs every tick: it resyncs the open-position cache, calls ApplyBreakevenLock() and ApplyTrailingStops(), and fires the Hull-reversal and ADX-weakness exits if InpEnableMinProfitProtection permits. HandleEmergencyControls() watches for a spread spike > InpSpreadMaxPoints × InpEmergencySpreadMultiplier and force-closes everything via the TryClose_EX18107 retry helper. News-filter input is wired but ships without a data source, so the function only logs a one-shot warning.
A new-bar entry fires when the 34-period LWMA Hull slope is monotonically rising (or falling) for InpTrendConfirmBars consecutive bars, ADX(14) is in the [22, 45] range, the current ATR(14) ratio vs the pair's calibrated base ATR falls inside the adaptive P20-P80 band clamped to [0.70, 1.60], tick volume vs the 20-bar average sits in the [0.7, 2.0] ratio band, and the higher-timeframe LWMA(55) Hull agrees on direction. The session filter, the 15% max-drawdown gate, the per-slot pyramid cap, and the adaptive spread cap (P85 × 1.3 of the last 100 bars, hard-capped at 25 points) must all pass before gTrade.Buy or gTrade.Sell is invoked.
Three exit paths run together. Hull reversal (1-bar slope flip against the position, controlled by InpHullReversalBars) and ADX weakness (InpADXWeaknessThreshold 18 absolute OR a 25% drop from the running peak tracked in gAdxPeak) close through TryClose_EX18107(). The breakeven lock (ApplyBreakevenLock()) ratchets SL to entry+0.1×ATR once profit clears 2× the broker stop-level or InpPyramidSpacingATRMin×ATR; the trailing stop (ApplyTrailingStops()) then takes over after InpTrailingActivationATR×ATR profit and ratchets by InpTrailingDistanceBase×ATR per tick. HandleEmergencyControls() force-closes every open position when the live spread exceeds InpSpreadMaxPoints × InpEmergencySpreadMultiplier (2.5×). InpEnableMinProfitProtection blocks every close while a position is in net loss.
Server-side SL is written at open at Ask/Bid ± ATR(14) × stopMultiplier, where stopMultiplier is InpSLMultiplierBase (2.2 default) clamped to [1.8, 3.2] and further multiplied by 1.25 in trending regimes and 0.85 in ranging regimes when regime detection is on. Low signalQuality (<0.8) tightens it by another 10%. The stop then ratchets via ApplyBreakevenLock() (entry + 0.1×ATR once profit clears the activation threshold) and ApplyTrailingStops() (InpTrailingDistanceBase×ATR, default 1.4, range 0.9-2.2, after InpTrailingActivationATR×ATR profit, default 2.0). Per-symbol minimum stop distance is enforced before send.
Server-side TP is Ask/Bid ∓ ATR(14) × tpMultiplier, where tpMultiplier is InpTPMultiplierBase (5.5 default) clamped to [3.5, 8.0] with the same regime adjustment (1.25x trending, 0.85x ranging). A minimum reward ratio of 1.3 (TP distance / SL distance) is enforced; if the regime adjustment would push it below the floor, TP is stretched up to stopMultiplier × 1.3 instead. High signalQuality (>1.5) widens TP up to 30%. TP is held as a server-side bracket — there is no virtual-TP layer — and is restored via TryModify_EX18107() if it is ever lost during a server action.
Best deployed on M5 or H1 charts of USDJPY, EURUSD, GBPUSD, or XAUUSD with a $100 minimum account — the source calibrates per-symbol point value and pip multiplier automatically, so risk math stays correct across all four. The 0.75% default risk and 1+1 pyramid cap suit a $1,000-$10,000 account; aggressive mode (relaxed ADX band, expanded ATR and spread slack, session override, single-bar confirmation) trades more frequently and is appropriate for traders who want higher signal volume at the cost of more whipsaws. Session filter defaults to Asian + New York, which fits USDJPY and XAUUSD; operators on EURUSD/GBPUSD should enable London and disable Asian. A low-spread ECN broker is required — the adaptive spread filter rejects entries above the 25-point hard cap and force-closes above 2.5× that on existing positions. The 15% drawdown cap is an entry block, not a hard stop-out, so pair it with conservative InpRiskPercentPerTrade and InpMaxSimultaneousPositions settings if you need a real kill-switch. Do not enable the news filter without first wiring an external economic-calendar feed — the function logs a warning and does nothing else.
Strategy Logic
Pipsgrowth EX18107 TrendFollow — Strategy Logic Analysis (from .mq5 source)
Family: TrendFollow
Magic: 22218107
Version: 2.00
BRIEF:
Adaptive trend-following EA using Hull MA + ADX for trend detection, with adaptive ATR filtering, pyramiding, profit locks, trailing stops, regime detection, and session filters. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
InitPositionSlots()ClearPositionSlot()IsMarginLevelAcceptable()CanOpenPyramidPosition()ApplyBreakevenLock()GetMinimumStopDistance()UpdateAdaptiveATRState()UpdateAdaptiveSpreadState()CalculatePercentile()HandleEmergencyControls()InitIndicators()CopyIndicatorBufferWithRetry()- ...and 17 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (78 total across 12 groups):
- [=== Risk Management ===]
InpRiskPercentPerTrade=0.75// Risk % per trade (USDJPYtuned) - [=== Risk Management ===]
InpMaxSimultaneousPositions= 2 // Max pyramid positions - [=== Risk Management ===]
InpMaxDrawdownPercent=15.0// Max account drawdown % - [=== Risk Management ===]
InpEnableMarginGuard=false// Enforce minimum marginlevelbefore new trades - [=== Risk Management ===]
InpMinMarginLevelPerc=200.0// Minimum marginlevel(%) (100.0,1.0,1000.0) - [=== Trend Detection ===]
InpHullPeriod= 34 // Hull MA period (JPYsmoothing) - [=== Trend Detection ===]
InpADXPeriod= 14 //ADXperiod - [=== Trend Detection ===]
InpMinADXForEntry=22.0// MinimumADXfor entry - [=== Trend Detection ===]
InpMaxADXForEntry=45.0// MaximumADXfor entry - [=== Trend Detection ===]
InpTrendConfirmBars= 2 // Consecutive bars confirmation - [=== Trend Detection ===]
InpMinVolumeRatio=0.7// Min volume vs 20-bar avg - [=== Trend Detection ===]
InpMaxVolumeRatio=2.0// Max volume vs 20-bar avg - [=== Trend Detection ===]
InpShowHullOnChart=true// Display Hull MA on the chart - [=== Trend Detection ===]
InpEnableHTFHullConfirm=true// Confirm trades with higher timeframe Hull trend - [=== Trend Detection ===]
InpHTFHullTimeframe= 9 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher timeframe used for Hull confirmation - [=== Trend Detection ===]
InpHTFHullPeriod= 55 // Hull period on higher timeframe - [=== Trend Detection ===]
InpAggressiveEntryMode=false// Relax key filters to boost trade frequency - [=== Trend Detection ===]
InpAggressiveADXFloor=18.0//ADXminimum when aggressive (0 = keep current) - [=== Trend Detection ===]
InpAggressiveADXCeiling=55.0//ADXmaximum when aggressive (<=0 disables cap) - [=== Trend Detection ===]
InpShowHTFHullOnChart=false// DisplayHTFHull on the chart - [=== Adaptive
ATRFilter ===]InpEnableAdaptiveATR=true// Enable adaptiveATRfiltering - [=== Adaptive
ATRFilter ===]InpATRPeriod= 14 //ATRcalculation period - [=== Adaptive
ATRFilter ===]InpATRLookback= 120 // Lookback bars for percentiles - [=== Adaptive
ATRFilter ===]InpATRMinPercentile=0.20// Lower percentile (P20) - [=== Adaptive
ATRFilter ===]InpATRMaxPercentile=0.80// Upper percentile (P80) - [=== Adaptive
ATRFilter ===]InpATRHardMinRatio=0.70// Hard minimum ratio floor - [=== Adaptive
ATRFilter ===]InpATRHardMaxRatio=1.60// Hard maximum ratio ceiling - [=== Adaptive
ATRFilter ===]InpATRSessionMultiplier=1.05// Session multiplier (JPYvolatility bias) - [=== Adaptive
ATRFilter ===]InpAggressiveATRSlack=1.15// ExpandATRband when aggressive (>=1.0) - [=== Adaptive SL/TP ===]
InpEnableAdaptiveSLTP=true// Enable adaptive SL/TP - [=== Adaptive SL/TP ===]
InpSLMultiplierMin=1.8// SL: MinimumATRmultiplier - [=== Adaptive SL/TP ===]
InpSLMultiplierMax=3.2// SL: MaximumATRmultiplier - [=== Adaptive SL/TP ===]
InpSLMultiplierBase=2.2// SL: BaseATRmultiplier - [=== Adaptive SL/TP ===]
InpTPMultiplierMin=3.5// TP: MinimumATRmultiplier - [=== Adaptive SL/TP ===]
InpTPMultiplierMax=8.0// TP: MaximumATRmultiplier - [=== Adaptive SL/TP ===]
InpTPMultiplierBase=5.5// TP: BaseATRmultiplier - [=== Adaptive SL/TP ===]
InpEnableRegimeAdjustment=true// Adjust SL/TP by regime - [=== Adaptive SL/TP ===]
InpRegimeMultiplierTrending=1.25// Trending: widen SL/TP by % - [=== Adaptive SL/TP ===]
InpRegimeMultiplierRanging=0.85// Ranging: tighten SL/TP by % - [=== Pyramiding Rules ===]
InpMinProfitForPyramidPercent=40.0// Min profit % of TP before add - [=== Pyramiding Rules ===]
InpPyramidSpacingATRMin=1.3// Min spacing inATRunits - [=== Pyramiding Rules ===]
InpPyramidSpacingATRMax=2.5// Max spacing inATRunits - [=== Pyramiding Rules ===]
InpPyramidSpacingATRBase=1.8// Base spacing inATRunits - [=== Pyramiding Rules ===]
InpEnableBreakevenLock=true// Lock SL to breakeven on pyramid - [=== Trailing Stop ===]
InpEnableTrailing=true// Enable trailing stop - [=== Trailing Stop ===]
InpTrailingActivationATR=2.0// Activate trailing at X×ATRprofit - [=== Trailing Stop ===]
InpTrailingDistanceMin=0.9// Min trailing distance (ATR) - [=== Trailing Stop ===]
InpTrailingDistanceMax=2.2// Max trailing distance (ATR) - [=== Trailing Stop ===]
InpTrailingDistanceBase=1.4// Base trailing distance (ATR) - [=== Adaptive Spread Filter ===]
InpEnableAdaptiveSpread=true// Enable adaptive spread filter - [=== Adaptive Spread Filter ===]
InpSpreadLookback= 100 // Lookback bars for spread avg - [=== Adaptive Spread Filter ===]
InpSpreadPercentile=0.85// Percentile threshold (P85) - [=== Adaptive Spread Filter ===]
InpSpreadMultiplier=1.3// Multiplier on percentile - [=== Adaptive Spread Filter ===]
InpSpreadMaxPoints=25.0// Absolute maximum spread points - [=== Adaptive Spread Filter ===]
InpSpreadRejectOnWiden=true// Reject if spread > threshold - [=== Adaptive Spread Filter ===]
InpAggressiveSpreadSlack=1.20// Expand spread allowance when aggressive (>=1.0) - [=== Market Regime ===]
InpEnableRegimeDetection=true// Enable regime classification - [=== Market Regime ===]
InpADXTrendingThreshold=28.0//ADX> X = trending - [=== Market Regime ===]
InpADXRangingThreshold=18.0//ADX< X = ranging - [=== Market Regime ===]
InpATRVolatileThreshold=1.8//ATRratio > X = volatile - [=== Market Regime ===]
InpATRConsolidatingThreshold=0.7//ATRratio < X = consolidating - [=== Exit Strategy ===]
InpEnableHullReversalExit=true// Exit on Hull reversal - [=== Exit Strategy ===]
InpHullReversalBars= 1 // Bars to confirm reversal - [=== Exit Strategy ===]
InpEnableADXWeaknessExit=true// Exit whenADXweakens - [=== Exit Strategy ===]
InpADXWeaknessThreshold=18.0//ADXdrops below X - [=== Exit Strategy ===]
InpADXDeclinePercent=25.0// ORADXdeclines X% from peak - [=== Exit Strategy ===]
InpEnableMinProfitProtection=true// Don't exit until min profit - [=== Time Filters ===]
InpEnableSessionFilter=true// Enable session filtering - [=== Time Filters ===]
InpTradeAsianSession=true// Trade Asian session - [=== Time Filters ===]
InpTradeLondonSession=false// Trade London session - [=== Time Filters ===]
InpTradeNYSession=true// Trade New York session - [=== Emergency Controls ===]
InpEnableNewsFilter=true// Avoid major news (NFP/FOMC) - [=== Emergency Controls ===]
InpEnableEmergencyExit=true// Emergency exit on extreme conditions - [=== Emergency Controls ===]
InpEmergencySpreadMultiplier=2.5// Exit if spread > X × normal - [=== System ===]
InpMagicNumber=22218107// Magic number - [=== System ===]
InpTradeComment= "Psgrowth.com Expert_18107" // Trade comment - [=== System ===]
InpEnableLogging=true// Enable detailed logging - [=== System ===]
InpEnableDebugLogging=false// Extra diagnostics in log
// Pipsgrowth EX18107 TrendFollow — Execution Flow (from source analysis)
// Family: TrendFollow
// Adaptive trend-following EA using Hull MA + ADX for trend detection, with adaptive ATR filtering, pyramiding, profit locks, trailing stops, regime detection, and session filters. 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 an H4 or Daily chart for best results
- 7Configure EMA periods, ADX threshold, and lot size in the dialog
- 8Enable Allow Algo Trading and click OK
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| InpRiskPercentPerTrade | 0.75 | Risk % per trade (USDJPY tuned) |
| InpMaxSimultaneousPositions | 2 | Max pyramid positions |
| InpMaxDrawdownPercent | 15.0 | Max account drawdown % |
| InpEnableMarginGuard | false | Enforce minimum margin level before new trades |
| InpMinMarginLevelPerc | 200.0 | Minimum margin level (%) (100.0,1.0,1000.0) |
| InpHullPeriod | 34 | Hull MA period (JPY smoothing) |
| InpADXPeriod | 14 | ADX period |
| InpMinADXForEntry | 22.0 | Minimum ADX for entry |
| InpMaxADXForEntry | 45.0 | Maximum ADX for entry |
| InpTrendConfirmBars | 2 | Consecutive bars confirmation |
| InpMinVolumeRatio | 0.7 | Min volume vs 20-bar avg |
| InpMaxVolumeRatio | 2.0 | Max volume vs 20-bar avg |
| InpShowHullOnChart | true | Display Hull MA on the chart |
| InpEnableHTFHullConfirm | true | Confirm trades with higher timeframe Hull trend |
| InpHTFHullTimeframe | 9 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Higher timeframe used for Hull confirmation |
| InpHTFHullPeriod | 55 | Hull period on higher timeframe |
| InpAggressiveEntryMode | false | Relax key filters to boost trade frequency |
| InpAggressiveADXFloor | 18.0 | ADX minimum when aggressive (0 = keep current) |
| InpAggressiveADXCeiling | 55.0 | ADX maximum when aggressive (<=0 disables cap) |
| InpShowHTFHullOnChart | false | Display HTF Hull on the chart |
| InpEnableAdaptiveATR | true | Enable adaptive ATR filtering |
| InpATRPeriod | 14 | ATR calculation period |
| InpATRLookback | 120 | Lookback bars for percentiles |
| InpATRMinPercentile | 0.20 | Lower percentile (P20) |
| InpATRMaxPercentile | 0.80 | Upper percentile (P80) |
| InpATRHardMinRatio | 0.70 | Hard minimum ratio floor |
| InpATRHardMaxRatio | 1.60 | Hard maximum ratio ceiling |
| InpATRSessionMultiplier | 1.05 | Session multiplier (JPY volatility bias) |
| InpAggressiveATRSlack | 1.15 | Expand ATR band when aggressive (>=1.0) |
| InpEnableAdaptiveSLTP | true | Enable adaptive SL/TP |
| InpSLMultiplierMin | 1.8 | SL: Minimum ATR multiplier |
| InpSLMultiplierMax | 3.2 | SL: Maximum ATR multiplier |
| InpSLMultiplierBase | 2.2 | SL: Base ATR multiplier |
| InpTPMultiplierMin | 3.5 | TP: Minimum ATR multiplier |
| InpTPMultiplierMax | 8.0 | TP: Maximum ATR multiplier |
| InpTPMultiplierBase | 5.5 | TP: Base ATR multiplier |
| InpEnableRegimeAdjustment | true | Adjust SL/TP by regime |
| InpRegimeMultiplierTrending | 1.25 | Trending: widen SL/TP by % |
| InpRegimeMultiplierRanging | 0.85 | Ranging: tighten SL/TP by % |
| InpMinProfitForPyramidPercent | 40.0 | Min profit % of TP before add |
| InpPyramidSpacingATRMin | 1.3 | Min spacing in ATR units |
| InpPyramidSpacingATRMax | 2.5 | Max spacing in ATR units |
| InpPyramidSpacingATRBase | 1.8 | Base spacing in ATR units |
| InpEnableBreakevenLock | true | Lock SL to breakeven on pyramid |
| InpEnableTrailing | true | Enable trailing stop |
| InpTrailingActivationATR | 2.0 | Activate trailing at X×ATR profit |
| InpTrailingDistanceMin | 0.9 | Min trailing distance (ATR) |
| InpTrailingDistanceMax | 2.2 | Max trailing distance (ATR) |
| InpTrailingDistanceBase | 1.4 | Base trailing distance (ATR) |
| InpEnableAdaptiveSpread | true | Enable adaptive spread filter |
| InpSpreadLookback | 100 | Lookback bars for spread avg |
| InpSpreadPercentile | 0.85 | Percentile threshold (P85) |
| InpSpreadMultiplier | 1.3 | Multiplier on percentile |
| InpSpreadMaxPoints | 25.0 | Absolute maximum spread points |
| InpSpreadRejectOnWiden | true | Reject if spread > threshold |
| InpAggressiveSpreadSlack | 1.20 | Expand spread allowance when aggressive (>=1.0) |
| InpEnableRegimeDetection | true | Enable regime classification |
| InpADXTrendingThreshold | 28.0 | ADX > X = trending |
| InpADXRangingThreshold | 18.0 | ADX < X = ranging |
| InpATRVolatileThreshold | 1.8 | ATR ratio > X = volatile |
| InpATRConsolidatingThreshold | 0.7 | ATR ratio < X = consolidating |
| InpEnableHullReversalExit | true | Exit on Hull reversal |
| InpHullReversalBars | 1 | Bars to confirm reversal |
| InpEnableADXWeaknessExit | true | Exit when ADX weakens |
| InpADXWeaknessThreshold | 18.0 | ADX drops below X |
| InpADXDeclinePercent | 25.0 | OR ADX declines X% from peak |
| InpEnableMinProfitProtection | true | Don't exit until min profit |
| InpEnableSessionFilter | true | Enable session filtering |
| InpTradeAsianSession | true | Trade Asian session |
| InpTradeLondonSession | false | Trade London session |
| InpTradeNYSession | true | Trade New York session |
| InpEnableNewsFilter | true | Avoid major news (NFP/FOMC) |
| InpEnableEmergencyExit | true | Emergency exit on extreme conditions |
| InpEmergencySpreadMultiplier | 2.5 | Exit if spread > X × normal |
| InpMagicNumber | 22218107 | Magic number |
| InpTradeComment | "Psgrowth.com Expert_18107" | Trade comment |
| InpEnableLogging | true | Enable detailed logging |
| InpEnableDebugLogging | false | Extra diagnostics in log |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX18107 newHullv1 — Adaptive Hull MA trend-follower, full 12-layer stack."
#include <Trade/Trade.mqh>
#include <Trade/PositionInfo.mqh>
#include <Trade\Trade.mqh>
#ifndef ERR_NO_HISTORY_DATA
#define ERR_NO_HISTORY_DATA 4401
#endif
#ifndef ERR_INDICATOR_WORKING
#define ERR_INDICATOR_WORKING 4806
#endif
#ifndef ERR_HISTORY_WILL_UPDATED
#define ERR_HISTORY_WILL_UPDATED 4066
#endif
//+------------------------------------------------------------------+
//| INPUT PARAMETERS - 77 TOTAL (ORGANIZED IN 12 GROUPS) |
//+------------------------------------------------------------------+
//======================================================================================
// SECTION 1: RISK MANAGEMENT (6 inputs)
//======================================================================================
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_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
switch(ap)
{
case 1: return PRICE_CLOSE;
case 2: return PRICE_OPEN;
case 3: return PRICE_HIGH;
case 4: return PRICE_LOW;
case 5: return PRICE_MEDIAN;
case 6: return PRICE_TYPICAL;
case 7: return PRICE_WEIGHTED;
default: return PRICE_CLOSE;
}
}
ENUM_TIMEFRAMES g_InpHTFHullTimeframe = PERIOD_H1;
input group "=== Risk Management ==="
input double InpRiskPercentPerTrade = 0.75; // Risk % per trade (USDJPY tuned)
input int InpMaxSimultaneousPositions = 2; // Max pyramid positions
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 Trend Following strategy EAs from our library
Pipsgrowth EX16080 Trend
Pipsgrowth.com EX16080 EURUSDTrendFollower — triple-EMA H4 trend follower, full 12-layer stack.
Pipsgrowth EX16081 Trend
Pipsgrowth.com EX16081 GoldTrendEA — XAUUSD H4 EMA cross with Fib targets, full 12-layer stack.
Pipsgrowth EX16033 Trend
Pipsgrowth.com EX16033 EA_Price_Action — price-action grid scalper, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.