Pipsgrowth EX18062 TrendFollow
MT5 Expert Advisor (Open Source) · XAUUSD · M15
Pipsgrowth.com EX18062 HullTest_Fast — Inline MTF Hull-MA consensus + ADX gate, full 12-layer stack.
Overview
Pipsgrowth EX18062 TrendFollow (HullTest_Fast) is a multi-timeframe Hull Moving Average consensus EA built around an unusual premise: instead of trusting a single Hull-MA on one chart, it asks three independent Hull calculations on three different timeframes to vote on direction, and only fires when a configurable majority agrees. The three H1/M30/M15 Hull periods are 300, 200, and 130 respectively, which is far longer than the typical 20/55 or 34/89 windows used elsewhere in this family. Those long periods are deliberate — the EA is not trying to scalp or catch the early stages of a swing. It is designed to ride the body of trends that have already been running for hours on the H1 chart and to filter out almost everything that does not align with that body.
The signal path is a five-stage filter. First, each timeframe computes its own Hull value inline from LWMA primitives — CalcHullValue() builds the standard 2×WMA(period/2) − WMA(period) formula and the EA never calls iCustom. The slope check is strict: the EA requires three consecutive rising or falling Hull values plus a closed bar that closes on the correct side of the Hull line. If that test fails on any of the three timeframes, that timeframe abstains. Second, each timeframe's vote is independently gated by its own ADX(14) reading using a 24.0 threshold (InpHullAdxThresh). Timeframes whose ADX is below 24 are silenced — they abstain instead of voting against. Third, a MinHullsAgree of 2 of 3 (the default) is required for the consensus to fire; a 1-1-1 split yields no trade. Fourth, the H1 EMA(50) trend direction is fetched through HtfEmaSide() and the EA refuses to take a signal that disagrees with the EMA — for example, a long vote on the lower timeframes is killed if the H1 EMA is sloping down with price below it. Fifth, the regime classifier has to approve: STRONG_TREND, WEAK_TREND, BREAKOUT, and EXPAND are all permitted, but CHOPPY, RANGE, and COMPRESS block entries.
Regime classification itself uses three M15 indicators: an ATR(14) with a 100-bar percentile lookback, Bollinger Bands(20, 2.0) with a 100-bar width percentile, and an ADX(14) for trend strength. The thresholds are split out in the code: ADX ≥30 with ATR pctile ≥70 reads as STRONG_TREND, ADX ≥22 alone is WEAK_TREND, width percentile ≤20 is COMPRESS, width percentile ≥80 combined with ATR pctile ≥60 is BREAKOUT, ATR pctile ≥70 without an ADX spike is EXPAND, and ADX <18 with ATR pctile <40 is RANGE. Anything that falls through all the buckets ends up as CHOPPY. The fact that COMPRESS and RANGE are blocked alongside CHOPPY means the EA sits on its hands during low-volatility consolidations and during quiet ranging hours — the only environments it really likes are persistent trends and the expansion phase that comes out of a quiet base.
The risk module is conservative for a 130/200/300-period trend system. Default risk per trade is 0.75% of effective capital, daily loss is capped at 3.0%, weekly at 6.0%, and an effective-capital floor of $50 blocks new entries when the account is depleted. InpCapitalCapAmount is 0.0 by default — the cap is opt-in. The EA also has a hard cooldown: after 3 consecutive losses, new entries are blocked until a profitable close resets the counter. The session filter is one of the most distinctive choices in the file: IsSessionAllowed() returns true only between broker hours 0 and 12, which targets the Asian and London sessions and skips the entire New York window. This is paired with an end-of-day close at 20:00 broker time (EOD_HOUR) that liquidates everything before the rollover, including positions that have not hit their stops or targets. The 0-12 window means the EA does not see US economic releases at all — that is by design, not a limitation.
Trade management runs the standard toolbox. A one-shot break-even at 25 points of profit moves the stop to entry + 5 points. A 50% partial close at 1R (PARTIAL_TP1_R_MULT=1.0, PARTIAL_TP1_PCT=50) banked half the position size once the trade reaches the SL distance. From that point, a 3.0×ATR(14) trailing stop activates and ratchets forward, gated to only move in the favorable direction. A volatility-spike exit is layered on top: when current ATR is more than 2.2× the 50-bar ATR average, the EA closes the position regardless of whether the spike is in the trade's favor. The fixed take-profit is 180 points with a 40-point stop, which is 4.5:1 — the widest fixed R:R in this family. The InpMinRR=1.2 sanity gate just confirms the configured TP/SL ratio is reasonable, not that the trade itself hit 1.2R. The opposite-signal exit is built into CloseOpposite() and fires before a new entry is opened in the reverse direction.
Execution is broker-portable. All seven indicator handles (three ADX TFs, ATR, regime ADX, BB, HTF EMA) are created in OnInit, and SetDeviationInPoints(30) plus SetTypeFillingBySymbol() are called up front. Three retry helpers — TryClose_EX18062, TryClosePartial_EX18062, and TryModify_EX18062 — handle requotes, timeouts, and price changes with 200ms and 100ms backoffs before giving up. Slippage tolerance is 30 points. OrderCalcMargin() is called before every entry, and the order is refused if required margin exceeds free margin. By default, InpDryRun=true — the EA logs the trades it would have taken but does not send them; the user has to flip the switch to go live.
For backtest selection, OnTester() returns (net × pf) / (1 + dd) with a 30-trade minimum, which strongly rewards strategies with high profit factor and low relative drawdown. Inputs that matter for tuning: the three Hull periods (raise them to make the EA slower, lower them to make it faster), InpHullAdxThresh (raise it to demand stronger trends per timeframe), InpMinHullsAgree (raise to 3 to require unanimous consensus, drop to 1 to weaken the filter), the SL and TP points (must keep TP/SL ≥1.2 per InpMinRR), and the session window defined by SESSION_START_HOUR=0 and SESSION_END_HOUR=12 in the define block. Be aware that the vol-spike exit, partial close, BE, and trail all stack on the same position — the partial close runs at 1R, the BE at 25 points, and the trail starts once profit exceeds 1.0× the SL distance. On a 40-point SL, the trail begins around 40 points of profit, which is the same point the partial fires; the trail takes over managing the remaining half.
A practical note on the H1 EMA filter: the EA only blocks signals that disagree with the EMA — a long vote with the H1 EMA flat is allowed through. If the operator wants a stricter filter that blocks flat-EMA signals too, that has to be patched into HtfEmaSide() directly. Also, the M15 signal operates on closed bars only, so the EA does not repaint on intra-bar ticks. The default InpDryRun=true state means the chart will show trade logs but no positions; flip it to false to go live.
Strategy Deep Dive
Each new M15 bar recomputes three independent inline Hull-MA values on M15/M30/H1 (periods 130/200/300) using the standard 2×WMA(period/2) − WMA(period) formula, and HullDir() returns +1/-1/0 only when three consecutive Hull values are monotonically rising or falling and the closed bar closes on the correct side of the Hull line. Each vote is independently filtered by its own ADX(14) reading against a 24.0 threshold, so a timeframe whose ADX is too low abstains instead of voting. The consensus requires at least 2 of 3 timeframes to agree (InpMinHullsAgree=2 default), then HtfEmaSide() confirms the H1 EMA(50) slope is not contradicting the vote. The M15 regime classifier — built from ATR(14) 100-bar percentile, Bollinger(20,2.0) width percentile, and ADX(14) — assigns one of seven states and blocks CHOPPY, RANGE, and COMPRESS. Risk is 0.75% of effective capital per trade with 3% daily / 6% weekly loss caps, a $50 effective-capital floor, and a 3-consecutive-loss cooldown. The trade window is broker hours 0-12 (Asian + London only, no New York) and EOD close at 20:00 liquidates open positions. InpDryRun=true is the default — flip to false to go live.
Triggers a long or short entry on M15 bar close when at least 2 of 3 timeframes (M15/H1 with Hull periods 130/200/300) vote in the same direction, each vote individually gated by ADX(14) ≥ 24.0 on its own timeframe. A long signal additionally requires the H1 EMA(50) to slope up with price above it (or be flat), and the M15 regime classifier to be in STRONG_TREND, WEAK_TREND, BREAKOUT, or EXPAND — CHOPPY, RANGE, and COMPRESS block entries. The duplicate-entry guard prevents more than one entry per M15 bar.
Exits through a layered stack: a one-shot break-even at 25 points of profit moves the stop to entry + 5 points, a 50% partial close fires at 1R (40 points), and a 3.0×ATR(14) trailing stop activates and ratchets forward once profit exceeds 1.0× the SL distance. A volatility-spike exit closes the position when current ATR is more than 2.2× the 50-bar ATR average. An opposite-signal close runs in CloseOpposite() before any new entry in the reverse direction. End-of-day at 20:00 broker time liquidates everything still open (InpCloseEOD=true).
Fixed 40-point stop loss (InpSLPoints=40.0), enforced with a one-shot break-even at 25 points of profit to entry + 5 points. The break-even fires once and only once per position, then the 3.0×ATR(14) trailing stop takes over from 1R onward.
Fixed 180-point take-profit (InpTPPoints=180.0), giving a 4.5:1 reward-to-risk ratio against the 40-point stop. Half the position is banked at 1R (50% partial) and the trailing stop manages the rest; InpMinRR=1.2 is a sanity gate that refuses entries if the configured TP/SL ratio falls below 1.2.
Traders running XAUUSD on M15 with a $100+ account who prefer slow Hull-based trend systems with the discipline to stay flat during New York. Best paired with a low-spread broker that respects the 50-point maximum spread cap and offers 0.01-lot micro sizing for capital caps near the $50 floor. The Asian + London session window (0-12 broker time) means the EA is well-suited to servers set to UTC+0, +1, +2, or +3 — anything that puts the New York cash session outside the 0-12 window.
Strategy Logic
Pipsgrowth EX18062 TrendFollow — Strategy Logic Analysis (from .mq5 source)
Family: TrendFollow
Magic: 22218062
Version: 2.00
BRIEF:
Inline Hull-MA (LWMA primitives) on M15/M30/H1 each gated by an ADX threshold. A consensus of >=N timeframes agreeing direction produces a +1/-1 signal. ENTRY on closed-bar consensus; CONFIRM via HTF EMA(50,H1) side + ADX regime + spread; NOTRADE blocks abnormal spread, off-session, choppy regime, daily loss, cap. RISK/SIZING off effective_capital. MANAGE/EXIT: BE, partial TP1, ATR-trail, vol-spike exit, opposite-signal exit, EOD close. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
ADX_M15ADX_M30ADX_H1ATR- ADXrg
BB- EMAhtf
KEY FUNCTIONS:
NormPrice()ClampStops()NormLot()PointsToPrice()ComputeTodayRealized()CalcLWMA()CalcHullValue()HullDir()HtfEmaSide()IsSessionAllowed()SpreadOK()UpdateSpreadHist()- ...and 13 more
INTERNAL CONSTANTS (18 total):
ATR_REGIME_PERIOD= 14 //ATRperiod for regime + vol-spikeATR_PCTILE_LOOKBACK= 100 // Lookback forATRpercentileBB_REGIME_PERIOD= 20 // Bollinger period for width regimeBB_REGIME_DEV=2.0// Bollinger deviationADX_REGIME_PERIOD= 14 //ADXperiod for regime gateHTF_EMA_PERIOD= 50 //HTFEMAagreement periodHTF_TIMEFRAME=PERIOD_H1// --- Hull engineHULL_CLOSE_BARS_EXTRA= 12 // Extra bars safety for Hull mathHULL_SLOPE_BARS= 3 // Consecutive rising/falling bars for hull dirVOL_ATR_AVG_PERIOD= 50 // --- Partial / trail (operator-tunable kept lean via defines)TRAIL_ACTIVATE_R=1.0// --- Break-Even defaults (move to define;InpEnableBEretained)BE_OFFSET_PTS=5.0// ---EOD/ sessionsEOD_HOUR= 20 // --- ExecSPREAD_MULT_AVG_CAP=3.0// max spread vs rolling avgSPREAD_AVG_LOOKBACK= 50 // --- Daily/weekly management- ...and 3 more
INPUT PARAMETERS (21 total across 6 groups):
- [=== Identity ===]
InpMagic=22218062// Magic number - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_18062" // Trade comment - [=== Identity ===]
InpVersion= "2.00" // Version tag - [=== Identity ===]
InpDryRun=true// Dry-run (no live orders) - [=== Risk & Sizing ===]
InpRiskPercent=0.75// Risk per trade (% of effective capital) - [=== Risk & Sizing ===]
InpDailyLossLimitPct=3.0// Daily loss limit (% of effective capital) - [=== Risk & Sizing ===]
InpWeeklyLossLimitPct=6.0// Weekly loss limit (% of effective capital) - [=== Risk & Sizing ===]
InpKillSwitch=false// Kill switch (block all new entries) - [=== Capital Allocation Cap ===]
InpCapitalCapAmount=0.0// Capital cap amount ($ real money) - [=== Capital Allocation Cap ===]
InpCapitalCapFloor=50.0// Capital cap floor (block new below) - [=== Hull
MTFConsensus(Signal) ===]InpHull1Period= 130 // Hull1 period (M15) - [=== Hull
MTFConsensus(Signal) ===]InpHull2Period= 200 // Hull2 period (M30) - [=== Hull
MTFConsensus(Signal) ===]InpHull3Period= 300 // Hull3 period (H1) - [=== Hull
MTFConsensus(Signal) ===]InpHullAdxThresh=24.0// Hull-ADXmin threshold (applied per TF) - [=== Hull
MTFConsensus(Signal) ===]InpMinHullsAgree= 2 // Min Hulls agreeing (of 3) - [=== Regime & Confirm ===]
InpMinRR=1.2// Min reward/risk ratio - [=== Regime & Confirm ===]
InpMaxSpreadPts=50.0// Max allowed spread (points) - [=== Entry / Exit ===]
InpSLPoints=40.0// Stop-loss distance (points) - [=== Entry / Exit ===]
InpTPPoints=180.0// Take-profit distance (points) - [=== Entry / Exit ===]
InpEnableBE=true// Enable break-even (one-shot) - [=== Entry / Exit ===]
InpCloseEOD=true// Close all atEOD
// Pipsgrowth EX18062 TrendFollow — Execution Flow (from source analysis)
// Family: TrendFollow
// Inline Hull-MA (LWMA primitives) on M15/M30/H1 each gated by an ADX threshold. A consensus of >=N timeframes agreeing direction produces a +1/-1 signal. ENTRY on closed-bar consensus; CONFIRM via HTF EMA(50,H1) side + ADX regime + spread; NOTRADE blocks abnormal spread, off-session, choppy regime, daily loss, cap. RISK/SIZING off effective_capital. MANAGE/EXIT: BE, partial TP1, ATR-trail, vol-spike exit, opposite-signal exit, EOD close. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
ON_INIT:
Create indicator handles: ADX_M15, ADX_M30, ADX_H1, ATR, ADXrg, BB, EMAhtf
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 |
|---|---|---|
| InpMagic | 22218062 | Magic number |
| InpTradeComment | "Psgrowth.com Expert_18062" | Trade comment |
| InpVersion | "2.00" | Version tag |
| InpDryRun | true | Dry-run (no live orders) |
| InpRiskPercent | 0.75 | Risk per trade (% of effective capital) |
| InpDailyLossLimitPct | 3.0 | Daily loss limit (% of effective capital) |
| InpWeeklyLossLimitPct | 6.0 | Weekly loss limit (% of effective capital) |
| InpKillSwitch | false | Kill switch (block all new entries) |
| InpCapitalCapAmount | 0.0 | Capital cap amount ($ real money) |
| InpCapitalCapFloor | 50.0 | Capital cap floor (block new below) |
| InpHull1Period | 130 | Hull1 period (M15) |
| InpHull2Period | 200 | Hull2 period (M30) |
| InpHull3Period | 300 | Hull3 period (H1) |
| InpHullAdxThresh | 24.0 | Hull-ADX min threshold (applied per TF) |
| InpMinHullsAgree | 2 | Min Hulls agreeing (of 3) |
| InpMinRR | 1.2 | Min reward/risk ratio |
| InpMaxSpreadPts | 50.0 | Max allowed spread (points) |
| InpSLPoints | 40.0 | Stop-loss distance (points) |
| InpTPPoints | 180.0 | Take-profit distance (points) |
| InpEnableBE | true | Enable break-even (one-shot) |
| InpCloseEOD | true | Close all at EOD |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX18062 HullTest_Fast — Inline MTF Hull-MA consensus + ADX gate, full 12-layer stack."
#include <Trade\Trade.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
#include <Trade\OrderInfo.mqh>
#include <Trade\DealInfo.mqh>
//=========================== DEFINES (non-input tunables) ===========
//--- Regime / confirm primitives
#define ATR_REGIME_PERIOD 14 // ATR period for regime + vol-spike
#define ATR_PCTILE_LOOKBACK 100 // Lookback for ATR percentile
#define BB_REGIME_PERIOD 20 // Bollinger period for width regime
#define BB_REGIME_DEV 2.0 // Bollinger deviation
#define ADX_REGIME_PERIOD 14 // ADX period for regime gate
#define HTF_EMA_PERIOD 50 // HTF EMA agreement period
#define HTF_TIMEFRAME PERIOD_H1
//--- Hull engine
#define HULL_CLOSE_BARS_EXTRA 12 // Extra bars safety for Hull math
#define HULL_SLOPE_BARS 3 // Consecutive rising/falling bars for hull dir
//--- Stoch / Volatility exit (operator-tunable kept lean via defines)
#define STOCH_K_PERIOD 45
#define STOCH_D_PERIOD 28
#define STOCH_SLOWING 23
#define STOCH_OB 80.0
#define STOCH_OS 20.0
#define STOCH_MIN_PROFIT_PTS 15.0
#define VOL_SPIKE_MULT 2.2
#define VOL_ATR_AVG_PERIOD 50
//--- Partial / trail (operator-tunable kept lean via defines)
#define PARTIAL_TP1_R_MULT 1.0
#define PARTIAL_TP1_PCT 50
#define TRAIL_ATR_MULT 3.0
#define TRAIL_ACTIVATE_R 1.0
//--- Break-Even defaults (move to define; InpEnableBE retained)
#define BE_TRIGGER_PTS 25.0
#define BE_OFFSET_PTS 5.0
//--- EOD / sessions
#define EOD_HOUR 20
//--- Exec
#define MAX_SLIPPAGE_POINTS 30
#define SPREAD_MULT_AVG_CAP 3.0 // max spread vs rolling avg
#define SPREAD_AVG_LOOKBACK 50
//--- Daily/weekly management
#define MAX_BARS_IN_TRADE 0 // 0 = disabled
#define SESSION_START_HOUR 0
#define SESSION_END_HOUR 22
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.