Pipsgrowth EX18049 TrendFollow
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX18049 HHHH -- T3+HeikinAshi trend-follow, full 12-layer stack.
Overview
Traders seeking closed-bar price candle + inlined tillson t3 (zero-lag, gd-form from ema(price,n) chain e1..e6) slope confirmation plus inlined heikin-ashi close smoothing. 12 mandatory layers wired into ontick: regime, signal (ha+t3), entry, confirm, no-trade, capital-allocation-cap, risk, sizing, manage/exit (be + atr trail + partial tp + regime-change + opposite-signal + time), scaling (pyramid off, capped), exec, ontester custom criterion. 12 layers: regime, signal, entry, confirm, no-trade, capital cap, risk, sizing, manage, exit, scaling, ontester will find Pipsgrowth EX18049 TrendFollow a complete, transparent MT5 Expert Advisor. Optimized for XAUUSD on M5, the EA includes full source code — no compiled-only black boxes, no hidden logic.
Pipsgrowth.com
EX18049HHHH-- T3+HeikinAshitrend-follow, full 12-layer stack.
No-Trade Gate
The EA blocks new entries when: market is closed, spread exceeds maximum, cooldown is active after losses, consecutive loss limit is reached, kill switch is enabled, or drawdown exceeds the hard threshold.
Session and safety parameters:
_SESSION_LONDON_START= 8 — London session start hour_SESSION_LONDON_END= 16 — London session end hour (exclusive)_SESSION_NY_START= 13 — New York session start hour_SESSION_NY_END= 21 — New York session end hour (exclusive)InpCooldownMinutes(default: 240) — Cooldown minutes after N consecutive losses (min)
Signal Generation Logic
Closed-bar price candle + inlined Tillson T3 (zero-lag, GD-form from EMA(price,N) chain e1..e6) slope confirmation plus inlined Heikin-Ashi close smoothing. 12 mandatory layers wired into OnTick: REGIME, SIGNAL (HA+T3), ENTRY, CONFIRM, NO-TRADE, CAPITAL-ALLOCATION-CAP, RISK, SIZING, MANAGE/EXIT (BE + ATR trail + partial TP + regime-change + opposite-signal + time), SCALING (pyramid off, capped), EXEC, OnTester custom criterion. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester.
The signal engine is configured via 18 internal constants:
_ATR_REG_PERIOD= 50 —ATRlookback for volatility-percentile rank_BB_PERIOD= 20 — Bollinger period (regime width detection)_BB_DEV=2.0— Bollinger deviation (standard 2-sigma)_RSI_PERIOD= 14 —RSIperiod (confirm OB/OS sanity)_HTF_EMA_PERIOD= 50 — Higher-timeframeEMAperiod for trend agreement_ADX_STRONG_MIN=22.0—ADXfloor forStrongTrendregime_ADX_WEAK_RATIO=0.7—ADXfloor forWeakTrendregime (×StrongMin)_ATR_PCT_STRONG=60.0—ATRpercentile floor forStrongTrend- ...and 10 more
User-adjustable signal parameters:
InpATRPeriod(default: 14) —ATRperiod (bars)InpADXPeriod(default: 14) —ADXperiod (bars)InpATRSLmult(default:2.0) —ATRmultiplier forSL(ratio)InpATRTPmult(default:4.0) —ATRmultiplier forTP(ratio)InpATRTrailMult(default:2.5) —ATRmultiplier for trailing stop (ratio)
Technical Architecture
The EA is built on a 12-layer architecture: Regime Detection, Signal Generation, Entry Dispatch, Confirmation, No-Trade Gate, Capital Allocation Cap, Risk Management, Position Sizing, Trade Management, Exit Logic, Scaling Gate, and OnTester fitness optimization. The source code defines 47 tunable constants and exposes 20 input parameters across 6 groups. Key indicator handles include standard MT5 indicators. The codebase implements 32 custom functions including PointSize(), TickSize(), TickValue(), StopsLevelPts(), FreezeLevelPts() and others.
Risk Management
Position sizing uses a medium risk profile. Default risk is 0.5% of effective capital per trade. Daily loss is capped at 3.0%. Weekly loss limit: 6.0%.
Key risk parameters from source:
InpRiskPercent(default:0.5) — Risk per trade (% of effective capital) (%)InpMaxLot(default:1.0) — Hard ceiling on lot size (lots)InpDailyLossLimitPct(default:3.0) — Max daily loss (% of effective capital) (%)InpWeeklyLossLimitPct(default:6.0) — Max weekly loss (% of effective capital) (%)InpMaxConcurrent(default: 1) — Max concurrent positions (count)InpCapitalCapAmount(default:0.0) — Cap on real-money equity ($)
Trade Management
The EA manages positions using these hardcoded rules:
_PARTIAL_TP_R=1.0— R multiple for partial TP trigger_PARTIAL_TP_FRACTION=0.5— Fraction of position to close atTP1_EXIT_OPP_SIGNAL=true— Exit on opposite signal_EXIT_REGIME_CHOPPY=true— Exit when regime degrades to choppy_USE_PARTIAL_TP=true— Enable partial TP_NEWS_BLOCK_MINUTES= 30 — Manual news blackout window (each side)
User-configurable exit parameters:
InpCooldownMinutes(default: 240) — Cooldown minutes after N consecutive losses (min)InpATRTrailMult(default:2.5) —ATRmultiplier for trailing stop (ratio)
Optimized For
- Pairs:
XAUUSD - Timeframes:
M5 - Recommended Brokers: Exness, IC Markets
- Minimum Deposit: $100
- Risk Level:
MEDIUM - Magic Number:
22218049 - Source Code:
Pipsgrowth_com_EX18049.mq5(20 inputs, 47 constants)
Download This MT5 Expert Advisor
This EA provides complete, open-source .mq5 code — no DLLs, no account restrictions, no hidden logic. Read every line of the TrendFollow strategy, modify parameters, and optimize for your broker. Test in the MT5 Strategy Tester before going live.
⚠️ Risk Warning: Trading forex and CFDs involves significant risk. 74-89% of retail investor accounts lose money. This
EAis for educational purposes only. Test thoroughly before any live use.
Strategy Deep Dive
Pipsgrowth EX18049 TrendFollow (EX18049) is an open-source MT5 Expert Advisor built for XAUUSD on M5. The strategy runs on 20 configurable input parameters with 32 custom functions in the source code. According to the source code header: Closed-bar price candle + inlined Tillson T3 (zero-lag, GD-form from EMA(price,N) chain e1..e6) slope confirmation plus inlined Heikin-Ashi close smoothing. 12 mandatory layers wired into OnTick: REGIME, SIGNAL (HA+T3), ENTRY, CONFIRM, NO-TRADE, CAPITAL-ALLOCATION-CAP, RISK, SIZING, MANAGE/EXIT (BE + ATR trail + partial TP + regime-change + opposite-signal + time), SCALING (pyramid off, capped), EXEC, OnTester custom criterion. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester. The EA operates on a 12-layer architecture: regime detection, signal generation, entry dispatch, confirmation, no-trade gate, capital allocation cap, risk management, position sizing, trade management, exit logic, scaling gate, and OnTester fitness optimization. Cooldown and consecutive loss limits prevent overtrading after drawdowns. All strategy logic is visible in the downloadable .mq5 source file.
Long when the fast EMA crosses above the slow EMA and ADX reads above 14 to confirm trend strength. Short on the reverse with ADX validation. Entries use closed-bar (shift=1) to prevent signal repainting.
Exit when the opposite EMA crossover fires (trend reversal signal) or when the trailing stop catches the trade after the trend exhausts. No fixed take-profit — the philosophy is to let winners run until momentum dies. The trailing stop is ATR-based and adjusts with each new swing high/low.
Initial stop placed below the last significant swing low for longs (or above the last swing high for shorts). The stop distance is calculated from ATR — typically 1.5–2× the 14-period ATR on the entry timeframe. Once in profit, the stop trails behind price to lock in gains without cutting the trend short.
No fixed take-profit — the EA uses a trailing stop to capture the full trend movement. The trailing stop uses a chandelier exit — it trails 2–3× ATR behind price. Trend EAs are designed to catch large moves (50–200+ pips) with a few large wins offsetting many small losses.
Works best on H4 and Daily timeframes with trending conditions. Top pairs: EUR/USD, GBP/USD, USD/JPY, XAU/USD. Medium risk profile with moderate drawdown tolerance. Minimum recommended: $500.
Strategy Logic
Pipsgrowth EX18049 TrendFollow — Strategy Logic Analysis (from .mq5 source)
Family: TrendFollow
Magic: 22218049
Version: 2.00
BRIEF:
Closed-bar price candle + inlined Tillson T3 (zero-lag, GD-form from EMA(price,N) chain e1..e6) slope confirmation plus inlined Heikin-Ashi close smoothing. 12 mandatory layers wired into OnTick: REGIME, SIGNAL (HA+T3), ENTRY, CONFIRM, NO-TRADE, CAPITAL-ALLOCATION-CAP, RISK, SIZING, MANAGE/EXIT (BE + ATR trail + partial TP + regime-change + opposite-signal + time), SCALING (pyramid off, capped), EXEC, OnTester custom criterion. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
PointSize()TickSize()TickValue()StopsLevelPts()FreezeLevelPts()NormPrice()EffectiveCapital()RealizedPnLTodayForMagic()DebugLog()CopyBufSafe()RegimeAllowsEntry()RegimeName()- ...and 20 more
INTERNAL CONSTANTS (47 total):
- _ATR_REG_PERIOD = 50 //
ATRlookback for volatility-percentile rank - _BB_PERIOD = 20 // Bollinger period (regime width detection)
- _BB_DEV =
2.0// Bollinger deviation (standard 2-sigma) - _RSI_PERIOD = 14 //
RSIperiod (confirm OB/OS sanity) - _HTF_EMA_PERIOD = 50 // Higher-timeframe
EMAperiod for trend agreement - _ADX_STRONG_MIN =
22.0//ADXfloor forStrongTrendregime - _ADX_WEAK_RATIO =
0.7//ADXfloor forWeakTrendregime (×StrongMin) - _ATR_PCT_STRONG =
60.0//ATRpercentile floor forStrongTrend - _ATR_PCT_BREAKOUT =
75.0//ATRpercentile floor for Breakout - _ATR_PCT_RANGE =
25.0//ATRpercentile ceiling for Range - _BB_EXPAND_RATIO =
1.20//BBwidth ratio for Expand regime - _BB_COMPRESS_RATIO =
0.85//BBwidth ratio for Compress regime - _HTF_TIMEFRAME =
PERIOD_H1// Higher timeframe for trendEMAconfirm - _SIGNAL_TIMEFRAME =
PERIOD_CURRENT// Signal timeframe (chart) - _RSI_OB_CEILING = 80 //
RSIceiling blocking long entries - ...and 32 more
INPUT PARAMETERS (20 total across 6 groups):
- [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_18049" // Trade comment (string) - [=== Identity ===]
InpMagicNumber=22218049// Magic number (int) - [=== Identity ===]
InpDryRun=true// Dry-run: skip actual order sends (bool) - [=== Identity ===]
InpKillSwitch=false// Kill switch: stop trading immediately (bool) - [=== Risk & Sizing ===]
InpRiskPercent=0.5// Risk per trade (% of effective capital) (%) - [=== Risk & Sizing ===]
InpMaxLot=1.0// Hard ceiling on lot size (lots) - [=== Risk & Sizing ===]
InpDailyLossLimitPct=3.0// Max daily loss (% of effective capital) (%) - [=== Risk & Sizing ===]
InpWeeklyLossLimitPct=6.0// Max weekly loss (% of effective capital) (%) - [=== Risk & Sizing ===]
InpMaxConcurrent= 1 // Max concurrent positions (count) - [=== Risk & Sizing ===]
InpCooldownMinutes= 240 // Cooldown minutes after N consecutive losses (min) - [=== Capital Allocation Cap ===]
InpCapitalCapAmount=0.0// Cap on real-money equity ($) - [=== Capital Allocation Cap ===]
InpCapitalCapFloor=50.0// Floor below which new entries are blocked ($) - [=== Signal ===]
InpT3Period= 14 // T3 Tillson period (bars) - [=== Signal ===]
InpT3HotFactor=0.7// T3 hot coefficient / volume factor (0..1) - [=== Regime / Confirm ===]
InpATRPeriod= 14 //ATRperiod (bars) - [=== Regime / Confirm ===]
InpADXPeriod= 14 //ADXperiod (bars) - [=== Regime / Confirm ===]
InpMinRR=1.5// Minimum reward:risk ratio (ratio) - [=== Exit / Manage ===]
InpATRSLmult=2.0//ATRmultiplier forSL(ratio) - [=== Exit / Manage ===]
InpATRTPmult=4.0//ATRmultiplier forTP(ratio) - [=== Exit / Manage ===]
InpATRTrailMult=2.5//ATRmultiplier for trailing stop (ratio)
// Pipsgrowth EX18049 TrendFollow — Execution Flow (from source analysis)
// Family: TrendFollow
// Closed-bar price candle + inlined Tillson T3 (zero-lag, GD-form from EMA(price,N) chain e1..e6) slope confirmation plus inlined Heikin-Ashi close smoothing. 12 mandatory layers wired into OnTick: REGIME, SIGNAL (HA+T3), ENTRY, CONFIRM, NO-TRADE, CAPITAL-ALLOCATION-CAP, RISK, SIZING, MANAGE/EXIT (BE + ATR trail + partial TP + regime-change + opposite-signal + time), SCALING (pyramid off, capped), EXEC, OnTester custom criterion. 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 |
|---|---|---|
| InpTradeComment | "Psgrowth.com Expert_18049" | Trade comment (string) |
| InpMagicNumber | 22218049 | Magic number (int) |
| InpDryRun | true | Dry-run: skip actual order sends (bool) |
| InpKillSwitch | false | Kill switch: stop trading immediately (bool) |
| InpRiskPercent | 0.5 | Risk per trade (% of effective capital) (%) |
| InpMaxLot | 1.0 | Hard ceiling on lot size (lots) |
| InpDailyLossLimitPct | 3.0 | Max daily loss (% of effective capital) (%) |
| InpWeeklyLossLimitPct | 6.0 | Max weekly loss (% of effective capital) (%) |
| InpMaxConcurrent | 1 | Max concurrent positions (count) |
| InpCooldownMinutes | 240 | Cooldown minutes after N consecutive losses (min) |
| InpCapitalCapAmount | 0.0 | Cap on real-money equity ($) |
| InpCapitalCapFloor | 50.0 | Floor below which new entries are blocked ($) |
| InpT3Period | 14 | T3 Tillson period (bars) |
| InpT3HotFactor | 0.7 | T3 hot coefficient / volume factor (0..1) |
| InpATRPeriod | 14 | ATR period (bars) |
| InpADXPeriod | 14 | ADX period (bars) |
| InpMinRR | 1.5 | Minimum reward:risk ratio (ratio) |
| InpATRSLmult | 2.0 | ATR multiplier for SL (ratio) |
| InpATRTPmult | 4.0 | ATR multiplier for TP (ratio) |
| InpATRTrailMult | 2.5 | ATR multiplier for trailing stop (ratio) |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX18049 HHHH -- T3+HeikinAshi trend-follow, 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>
//================== TUNABLE CONSTANTS (#define, not inputs) ==================
// NOTE: T3 period/hot and ATR/ADX periods are operator-tunable via inputs (InpT3Period,
// InpT3HotFactor, InpATRPeriod, InpADXPeriod). All other tunables are compile-time below.
#define _ATR_REG_PERIOD 50 // ATR lookback for volatility-percentile rank
#define _BB_PERIOD 20 // Bollinger period (regime width detection)
#define _BB_DEV 2.0 // Bollinger deviation (standard 2-sigma)
#define _RSI_PERIOD 14 // RSI period (confirm OB/OS sanity)
#define _HTF_EMA_PERIOD 50 // Higher-timeframe EMA period for trend agreement
// Regime thresholds
#define _ADX_STRONG_MIN 22.0 // ADX floor for StrongTrend regime
#define _ADX_WEAK_RATIO 0.7 // ADX floor for WeakTrend regime (×StrongMin)
#define _ATR_PCT_STRONG 60.0 // ATR percentile floor for StrongTrend
#define _ATR_PCT_BREAKOUT 75.0 // ATR percentile floor for Breakout
#define _ATR_PCT_RANGE 25.0 // ATR percentile ceiling for Range
#define _BB_EXPAND_RATIO 1.20 // BB width ratio for Expand regime
#define _BB_COMPRESS_RATIO 0.85 // BB width ratio for Compress regime
// Signal confirmation gates
#define _HTF_TIMEFRAME PERIOD_H1 // Higher timeframe for trend EMA confirm
#define _SIGNAL_TIMEFRAME PERIOD_CURRENT // Signal timeframe (chart)
#define _RSI_OB_CEILING 80 // RSI ceiling blocking long entries
#define _RSI_OS_FLOOR 20 // RSI floor blocking short entries
#define _SIGNAL_TOL_POINTS 5 // Tolerance points for slope/close tests
// Sessions (broker server time hours, 0-23)
#define _SESSION_LONDON_START 8 // London session start hour
#define _SESSION_LONDON_END 16 // London session end hour (exclusive)
#define _SESSION_NY_START 13 // New York session start hour
#define _SESSION_NY_END 21 // New York session end hour (exclusive)
#define _SESSION_ASIA_START 0 // Asian session start hour
#define _SESSION_ASIA_END 8 // Asian session end hour (exclusive)
#define _TRADE_LONDON true // Trade London session
#define _TRADE_NY true // Trade NY session
#define _TRADE_ASIA false // Trade Asian session
#define _ALLOW_LONG true // Allow long entries
#define _ALLOW_SHORT true // Allow short entries
// Exit / management tunables
#define _BE_ACTIVATE_R 1.0 // R multiples to activate break-even
#define _BE_OFFSET_POINTS 10 // Lock-in offset at BE (points)
#define _PARTIAL_TP_R 1.0 // R multiple for partial TP trigger
#define _PARTIAL_TP_FRACTION 0.5 // Fraction of position to close at TP1
#define _EXIT_OPP_SIGNAL true // Exit on opposite signal
#define _EXIT_REGIME_CHOPPY true // Exit when regime degrades to choppy
#define _MAX_BARS_HOLD 500 // Time-based exit ceiling (bars)
#define _USE_BREAK_EVEN true // Enable break-even management
#define _USE_PARTIAL_TP true // Enable partial TPFull 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.