Pipsgrowth EX16109 Trend
MT5 Expert Advisor (Open Source) · XAGUSD · M5
Pipsgrowth.com EX16109 HP_Diamond_XAGUSD_M5 — High Probability Diamond EMA stack + SuperTrend flip, full 12-layer stack.
Overview
Pipsgrowth EX16109 is a single-pair, single-timeframe trend-following EA tuned for the XAGUSD M5 chart, the silver contract's most liquid intraday window. The strategy it implements is the HP Diamond pattern: three independent conditions must line up on a closed bar before a position is opened, and the EA does not pyramid or add to a losing trade, so the inventory at any moment is either one long, one short, or flat. That is the diamond shape in the name — a clean, rare, multi-criteria trigger rather than a continuous signal stream.
The first condition is the EMA stack. On each new bar the EA copies the latest values of four exponential moving averages — 20, 50, 100, and 200 — and requires that they be ordered monotonically. A long setup needs EMA20 above EMA50 above EMA100 above EMA200; a short setup needs the exact reverse. Anything in between is rejected, which means the EA only fires in established trend regimes and sits out of the chop that forms the bulk of silver's intraday action. There is no gradual progression of weights; the four EMAs either nest or they don't.
The second condition is a SuperTrend flip. The SuperTrend in this EA is built from a 10-period ATR and a 1.5 multiplier (InpSuperTrendATR = 10, InpSuperTrendMult = 1.5), recomputed bar by bar from local high-low midpoint plus the band. The EA keeps a direction buffer that holds +1 when close is above the trailing SuperTrend line and -1 when below. A long trigger requires the direction to flip from ≤0 to +1, and a short trigger requires the opposite flip. The flip is the freshest part of the diamond: the EMA stack tells you the regime, the flip tells you a new leg has just started.
The third condition is a momentum confirmation. For a long, the EA requires the closed bar to be a green candle (close > open) AND the current close to be above the close five bars back. For a short, the same logic inverts. The lookback-5 component is short enough to react but long enough to filter out one-bar noise, and combined with the color test it eliminates the false-flip trades that often occur when SuperTrend whipsaws inside a range.
Risk parameters are ATR-anchored. The stop loss is 1.0 × the 14-period ATR and the take profit is 1.0 × the same ATR, producing a deliberate 1:1 reward-to-risk ratio. Position sizing is in LOT_MODE_RISK by default, with 0.5% of account balance risked per trade and a 0.5-lot ceiling, falling back to a 0.01 fixed lot if the symbol's tick data is missing. Margin is checked before the order is sent, and the trade request is retried up to 3 times on requotes, price changes, price-off errors, or timeouts (100 ms between attempts), then abandoned.
The aggressive breakeven is the risk-management centerpiece and is also the most important practical detail for live deployment. Once price moves 0.5 × ATR in the trade's favor — verified by reading the high/low of the forming bar, not just the last tick — the stop is ratcheted to entry + 50 points (or entry − 50 for shorts). The 50-point offset is the 5-pip buffer the source code comment references. From that moment the trade is risk-free, and any subsequent outcome is either breakeven-plus or a scratch. The BE check is direction-monotonic: it only moves the stop forward, never backward, so it cannot widen risk on a position that has already been protected.
After a fill the EA enters a 20-bar cooldown during which GetSignal() returns 0 unconditionally. This prevents the strategy from re-entering the same direction on every pullback of the same trend leg. Combined with the no-pyramiding rule, the maximum open exposure is one trade per symbol at any time, which is what makes the strategy survivable on the minimum recommended deposit of $100.
Drawdown protection runs continuously. If account balance drops 3% from the start-of-day balance, or if current equity drops 10% from the running peak equity, the EA flags a DD-limit state, raises an Alert, optionally closes every open position (InpCloseOnDDLimit = true by default), and blocks new entries until the next trading day. The daily tracker resets at the first tick of a new server day via CheckNewDay().
The time filter is opt-in: InpUseTimeFilter is false by default, so the EA trades around the clock when no time filter is enabled. If the operator turns it on, trading is restricted to a server-time window (default 8:00–20:00), with Friday closed after 20:00 and Saturday/Sunday flat. The spread filter accepts up to 30 points — relatively loose because silver spreads are tighter than gold's — and slippage tolerance is 30 points. The info panel displays the magic, current spread, open-position counts, floating P/L, cooldown counter, and DD status in the upper-left corner of the chart.
What the EA does not do: it does not hedge, it does not grid, it does not average down, it does not run a martingale, and it does not hold over the weekend by default. Every entry is a fresh trigger meeting all three conditions; every exit is SL, TP, breakeven, or session close. The HP Diamond pattern is essentially a quality-over-quantity trend system, and the code is structured to make the discipline automatic.
Strategy Deep Dive
On every tick, EX16109 first clears three guards: spread ≤ 30 points, optional time window (default off, otherwise 8:00–20:00 server with a Friday 20:00 flatten), and the drawdown-limit check that compares account balance to start-of-day and equity to running peak. If any guard fails, OnTick() returns and no signal processing happens. On a new bar, g_cooldownCounter is decremented and SuperTrend is recomputed from a 10-period ATR with a 1.5× band, producing a +1/-1 direction buffer across the last three bars. GetSignal() then reads the four EMAs (20/50/100/200) and the SuperTrend direction plus a 5-bar momentum window, and emits a long or short only when the EMA stack, the SuperTrend flip, and the momentum candle all line up in the same direction. Order execution routes through a retry loop that handles requotes and price-off errors with 100 ms between attempts, while ManageOpenPositions() walks every open position each tick and ratchets the stop to entry ± 50 points once the forming bar's high or low has reached entry ± 0.5 × ATR. The info panel repaints on every tick with spread, position counts, floating P/L, cooldown, and DD status.
Triggers a long when the four EMAs are stacked bullishly (20 > 50 > 100 > 200), the locally computed SuperTrend (ATR 10, mult 1.5) flips from ≤0 to +1, and the closed bar is green with its close above the close five bars back. Shorts are the mirror image. A 20-bar cooldown blocks re-entry after every fill, and only one buy or one sell may be open at a time.
Exits at the 1.0×ATR take profit, the 1.0×ATR stop loss, or the session close. The breakeven ratchet — triggered when price moves 0.5×ATR in favor and verified against the bar's high/low — moves the stop to entry ± 50 points and turns the trade into a scratch-or-win from that point. The DD-limit guard can also force-close every position on a 3% daily loss or 10% equity drawdown, and the Friday-close rule flattens at 20:00 server.
Hard stop at 1.0 × 14-period ATR from the entry price, set in OpenPosition() before the order is sent. Once price has moved 0.5 × ATR in favor (confirmed by the forming bar's high or low), the stop is ratcheted to entry + 50 points for longs or entry − 50 for shorts and never moved backward afterward.
Take profit at 1.0 × 14-period ATR from the entry price, producing a 1:1 reward-to-risk ratio against the stop. TP is sent with the original order; there is no partial-close or scaling-out logic, and the 1.0 × ATR TP is the only profit target.
Minimum recommended balance $100 on a low-spread XAGUSD broker, M5 chart only, with the EA attached to the silver contract (XAGUSD or any SILVER-tickered symbol). The 1:1 R:R, the 0.5% per-trade risk, the 30-point spread filter, and the 3%/10% DD guards make this a fit for traders who want a disciplined single-position trend system rather than a martingale or grid. Best deployed on an ECN account with tight silver spreads (silver's tighter spreads are why the default MaxSpread is set explicitly higher than gold's typical setup), with optional use of the time filter to keep the EA inside the London–New York overlap when that overlap is the most active window for XAGUSD.
Strategy Logic
Pipsgrowth EX16109 Trend — Strategy Logic Analysis (from .mq5 source)
Family: Trend
Magic: 22216109
Version: 2.00
BRIEF:
High Probability Diamond strategy for XAGUSD M5 using EMA stack alignment (20/50/100/200) plus SuperTrend flip and momentum confirmation. Aggressive breakeven at 0.5x ATR protects trades. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
SetProperFillingMode()UpdateSuperTrend()GetSignal()CheckSpread()CheckTimeFilter()CheckDrawdownLimits()CheckNewDay()CalculateLotSize()NormalizeLot()OpenPosition()ManageOpenPositions()CountPositions()- ...and 7 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (30 total across 7 groups):
- [=== Trade Execution ===]
InpMagicNumber=22216109// Magic Number - [=== Trade Execution ===]
InpSlippage= 30 // MaxSlippage(points) - [=== Trade Execution ===]
InpMaxSpread= 30 // MaxSpread(points, 0=off) - Silver has tighter spreads - [=== Trade Execution ===]
InpMaxRetries= 3 // Order Retry Attempts - [=== Trade Execution ===]
InpTradeComment= "Psgrowth.com Expert_16109" // TradeComment - [=== Money Management ===]
InpLotMode=LOT_MODE_RISK// Lot Sizing Mode - [=== Money Management ===]
InpFixedLotSize=0.01// Fixed Lot Size - [=== Money Management ===]
InpRiskPercent=0.5// RiskPercent(%) - [=== Money Management ===]
InpMaxLotSize=0.5// Maximum Lot Size - [=== Strategy Parameters ===]
InpATRPeriod= 14 //ATRPeriod(for SL/TP) - [=== Strategy Parameters ===]
InpSLMultiplier=1.0// StopLoss(ATRMultiplier) - [=== Strategy Parameters ===]
InpTPMultiplier=1.0// TakeProfit(ATRMultiplier) - [=== Strategy Parameters ===]
InpSuperTrendATR= 10 //SuperTrendATRPeriod - [=== Strategy Parameters ===]
InpSuperTrendMult=1.5//SuperTrendMultiplier - [=== Strategy Parameters ===]
InpCooldownBars= 20 // Cooldown Bars Between Signals - [=== Breakeven Settings ===]
InpUseBreakeven=true// Enable Breakeven - [=== Breakeven Settings ===]
InpBEATRMult=0.5// BETrigger(ATRMultiplier) - [=== Breakeven Settings ===]
InpBEOffsetPoints= 50 // BEOffset(points above entry) - [=== Time Filter ===]
InpUseTimeFilter=false// Enable Time Filter - [=== Time Filter ===]
InpStartHour= 8 // StartHour(Server Time) - [=== Time Filter ===]
InpEndHour= 20 // EndHour(Server Time) - [=== Time Filter ===]
InpTradeFriday=true// Trade on Friday - [=== Time Filter ===]
InpFridayCloseHour= 20 // Friday: Close All After Hour - [=== Drawdown Protection ===]
InpUseDDProtection=true// Enable Drawdown Protection - [=== Drawdown Protection ===]
InpMaxDailyLoss=3.0// Max Daily Loss % (0=disabled) - [=== Drawdown Protection ===]
InpMaxEquityLoss=10.0// Max Equity Loss % from Peak - [=== Drawdown Protection ===]
InpCloseOnDDLimit=true// Close All When DD Limit Hit - [=== Display Settings ===]
InpShowPanel=true// Show Info Panel - [=== Display Settings ===]
InpPanelX= 10 // Panel X Position - [=== Display Settings ===]
InpPanelY= 30 // Panel Y Position
// Pipsgrowth EX16109 Trend — Execution Flow (from source analysis)
// Family: Trend
// High Probability Diamond strategy for XAGUSD M5 using EMA stack alignment (20/50/100/200) plus SuperTrend flip and momentum confirmation. Aggressive breakeven at 0.5x ATR protects trades. 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 |
|---|---|---|
| InpMagicNumber | 22216109 | Magic Number |
| InpSlippage | 30 | Max Slippage (points) |
| InpMaxSpread | 30 | Max Spread (points, 0=off) - Silver has tighter spreads |
| InpMaxRetries | 3 | Order Retry Attempts |
| InpTradeComment | "Psgrowth.com Expert_16109" | Trade Comment |
| InpLotMode | LOT_MODE_RISK | Lot Sizing Mode |
| InpFixedLotSize | 0.01 | Fixed Lot Size |
| InpRiskPercent | 0.5 | Risk Percent (%) |
| InpMaxLotSize | 0.5 | Maximum Lot Size |
| InpATRPeriod | 14 | ATR Period (for SL/TP) |
| InpSLMultiplier | 1.0 | Stop Loss (ATR Multiplier) |
| InpTPMultiplier | 1.0 | Take Profit (ATR Multiplier) |
| InpSuperTrendATR | 10 | SuperTrend ATR Period |
| InpSuperTrendMult | 1.5 | SuperTrend Multiplier |
| InpCooldownBars | 20 | Cooldown Bars Between Signals |
| InpUseBreakeven | true | Enable Breakeven |
| InpBEATRMult | 0.5 | BE Trigger (ATR Multiplier) |
| InpBEOffsetPoints | 50 | BE Offset (points above entry) |
| InpUseTimeFilter | false | Enable Time Filter |
| InpStartHour | 8 | Start Hour (Server Time) |
| InpEndHour | 20 | End Hour (Server Time) |
| InpTradeFriday | true | Trade on Friday |
| InpFridayCloseHour | 20 | Friday: Close All After Hour |
| InpUseDDProtection | true | Enable Drawdown Protection |
| InpMaxDailyLoss | 3.0 | Max Daily Loss % (0=disabled) |
| InpMaxEquityLoss | 10.0 | Max Equity Loss % from Peak |
| InpCloseOnDDLimit | true | Close All When DD Limit Hit |
| InpShowPanel | true | Show Info Panel |
| InpPanelX | 10 | Panel X Position |
| InpPanelY | 30 | Panel Y Position |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX16109 HP_Diamond_XAGUSD_M5 — High Probability Diamond EMA stack + SuperTrend flip, full 12-layer stack."
//+------------------------------------------------------------------+
//| INCLUDES |
//+------------------------------------------------------------------+
#include <Trade\Trade.mqh>
//+------------------------------------------------------------------+
//| ENUMS |
//+------------------------------------------------------------------+
enum ENUM_LOT_MODE
{
LOT_MODE_FIXED = 0, // Fixed Lot Size
LOT_MODE_RISK = 1 // Risk % of Balance
};
//+------------------------------------------------------------------+
//| INPUT GROUP: Trade Execution |
//+------------------------------------------------------------------+
input group "=== Trade Execution ==="
input int InpMagicNumber = 22216109; // Magic Number
input int InpSlippage = 30; // Max Slippage (points)
input int InpMaxSpread = 30; // Max Spread (points, 0=off) - Silver has tighter spreads
input int InpMaxRetries = 3; // Order Retry Attempts
input string InpTradeComment = "Psgrowth.com Expert_16109"; // Trade Comment
//+------------------------------------------------------------------+
//| INPUT GROUP: Money Management |
//+------------------------------------------------------------------+
input group "=== Money Management ==="
input ENUM_LOT_MODE InpLotMode = LOT_MODE_RISK; // Lot Sizing Mode
input double InpFixedLotSize = 0.01; // Fixed Lot Size
input double InpRiskPercent = 0.5; // Risk Percent (%)
input double InpMaxLotSize = 0.5; // Maximum Lot Size
//+------------------------------------------------------------------+
//| INPUT GROUP: Strategy Parameters (OPTIMIZED) |
//+------------------------------------------------------------------+
input group "=== Strategy Parameters ==="
input int InpATRPeriod = 14; // ATR Period (for SL/TP)
input double InpSLMultiplier = 1.0; // Stop Loss (ATR Multiplier)
input double InpTPMultiplier = 1.0; // Take Profit (ATR Multiplier)
input int InpSuperTrendATR = 10; // SuperTrend ATR Period
input double InpSuperTrendMult = 1.5; // SuperTrend Multiplier
input int InpCooldownBars = 20; // Cooldown Bars Between Signals
//+------------------------------------------------------------------+
//| INPUT GROUP: Breakeven Settings (KEY TO 98.5% EFF WIN RATE) |
//+------------------------------------------------------------------+
input group "=== Breakeven Settings ==="
input bool InpUseBreakeven = true; // Enable Breakeven
input double InpBEATRMult = 0.5; // BE Trigger (ATR Multiplier)
input int InpBEOffsetPoints = 50; // BE Offset (points above entry)
//+------------------------------------------------------------------+
//| INPUT GROUP: Time Filter |
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.