Pipsgrowth EX16054 Trend
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX16054 new1 -- Momentum Structure Breakout with Donchian, RSI, HMA, full 12-layer stack.
Overview
Four-signal trend-following EA on XAUUSD that runs Donchian Channel, an EMA-plus-momentum MBS module, RSI and a hand-rolled Hull Moving Average in a strict priority order on every new tick. The header advertises a 12-layer stack — REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester — but reading the .mq5 honestly only the SIGNAL through SCALING layers are actually wired in. There is no regime classifier, no equity-curve capital cap, and no OnTester pass.
Signals are evaluated in a fixed cascade inside OnTick. DonchianChannel_Decision is checked first, then MBS_Decision, then RSI_Decision, then HMA_Decision. The first indicator that returns a non-empty string wins, and the others are not even consulted on that bar. Each of the four indicators has its own 4-toggle configuration block (EntrySignal_BUY, EntrySignal_SELL, Confirm_BUY, Confirm_SELL, ExitTrigger_BUY, ExitTrigger_SELL, ExitConfirm_BUY, ExitConfirm_SELL) so the user can promote any indicator from a primary entry to a confirmation to an exit trigger or disable it entirely. All four confirm toggles default to false, which means the default behaviour is single-indicator entries with no confirmation gate.
The Donchian channel uses a 20-bar high/low band with a 2-bar confirmation window, a 10-point minimum breakout size, a 5-point minimum pullback from the channel edge, and a 20-point minimum channel range to filter chop. It calls iATR(14) locally to gate volatility — current ATR must be ≤ 1.5× the prior bar's ATR — and CopyTickVolume to compare current tick volume against a 20-bar average when DC_RequireVolumeSpike is enabled (it is off by default). The pullback filter is the anti-fakeout element: price must have retreated at least 5 points from the channel edge in the prior DC_ConfirmationBars+1 bars before a fresh breakout can fire.
The MBS module is the most parameter-rich of the four. It copies 22 bars of high/low/close plus 14-bar ATR and 21-bar EMA, then computes a 20-bar resistance/support range via ArrayMaximum and ArrayMinimum. Breakout detection is straightforward — current high above the 20-bar max or current low below the 20-bar min — but the gating stack is heavy: breakout size must clear MBS_MinBreakoutSize=50 points, average per-bar momentum over the last 2 bars must reach MBS_MomentumThreshold=0.7 in absolute terms, at least 60% of the last MBS_ConfirmationBars bars must agree with EMA direction for trend_strength, current ATR must be ≤ 1.5× the average ATR, and if MBS_RequireVolumeSpike is on (default) current tick volume must be ≥ 1.5× the 20-bar average. The minimum price movement gate is 0.0001 — essentially a noise filter that rejects signals where close has not moved at all over the confirmation window.
RSI is a vanilla 14-period RSI on the user-selected timeframe (default H1) with applied price from the RSI_Price enum (1=close default). BUY fires when RSI current ≤ Oversold=30 but not in the extreme-oversold zone (≤ 25, set by the 5-point ExtremeBuffer), the last 3 bars are monotonically rising, the range across those 3 bars is ≥ 5 points, the average bar-to-bar move is ≥ 2 points, and RSI is not inside the ±5 dead zone around the 50 midline. SELL is the mirror. The momentum-bars-and-range construction is meant to reject whipsaw signals in flat regimes.
HMA is the unusual one because the EA does not use a native handle — it computes the indicator manually inside HMA_Decision from raw close prices. The formula is the canonical HMA = WMA(2×WMA(n/2) − WMA(n), sqrt(n)) with n=21 by default, half_period=11, sqrt_period=5. From this it derives hma_slope, hma_momentum in points, and a 2-bar bullish/bearish bar count. BUY requires hma_slope > 0.0001, hma_momentum ≥ 5 points, monotonically rising HMA over HMA_SmoothingBars=3 bars, price strictly above the HMA line, price distance from HMA ≥ 2 points, trend strength ≥ 0.7, and ATR(14) ≤ 1.5× the prior bar. The price-above/below requirement is gated by HMA_RequirePriceAbove and HMA_RequirePriceBelow booleans, both true by default, which makes HMA a price-relative-to-trendline signal rather than a pure slope signal.
Once a BUY or SELL string is produced by the cascade and the optional confirmation filters pass, ShouldOpenAdditionalPosition enforces the multi-position rules. If there are no positions, the trade goes through. If there are already MaxOpenTrades=5 positions, the trade is rejected. Otherwise every existing position on the symbol must individually have profit ≥ MinProfitInPointsPerTradeToAdd=500 points AND the average profit per existing trade must also clear 500 points when AllowOnlyProfitableAdditions is true (default). This is a "stack only on strength" rule, not a grid — losers are not averaged into.
ManageExistingPositions is the trailing-stop engine and runs on every tick. For each open position on the symbol it calculates profit in points, then if EnableDynamicLockProfit is true (default) and profit ≥ LockProfitEvery_X_Points=200, it ratchets the stop to current_price − LockMinusBuffer=100 for longs (or +100 for shorts), but only if the new stop is above the current stop (or below for shorts). The 200/100 spacing means the EA locks in roughly 100 points of profit for every 200 points of favourable move — a 50% retention trail that never tightens. There is no break-even step, no ATR-adaptive trail, and no per-position trailing offset; the LockMinusBuffer is global. If the indicator exit toggles (DC_ExitTrigger_, MBS_ExitTrigger_, RSI_ExitTrigger_*) are enabled for a side, an Exit Buy or Exit Sell string from any of them closes the position via TryClose_EX16054.
IsBasicTradeConditionsMet is the only no-trade filter. It requires positive ASK/BID prices, current spread ≤ MaxSpread=20 points, TERMINAL_TRADE_ALLOWED, and SYMBOL_TRADE_MODE ≠ 0. There is no session filter, no day-of-week filter, no news filter, no daily P&L cap, no max-drawdown cap, and no min-balance guard.
The retry helpers TryClose_EX16054, TryClosePartial_EX16054 and TryModify_EX16054 all follow the same 3-attempt shape with 100-200ms Sleep on TRADE_RETCODE_REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED. TryClose is wired into ManageExistingPositions; TryModify is wired into the dynamic-lock section; TryClosePartial is defined but never called — the EA has no partial-close path.
OnInit validates Lots > 0, MaxSpread > 0, and HardSL_Points / TP_Points ≥ 0, then returns INIT_SUCCEEDED. OnDeinit is empty. There are no module-level indicator handles — every iATR, iRSI, and iMA is created inside its respective decision function on each call and never explicitly released, which is wasteful but does not break correctness. The source also has an unusual amount of internal duplication: MapTimeframeInt and MapAppliedPriceInt are defined six times in the file and the same five global ENUM variables (g_MBS_Timeframe, g_DC_Timeframe, g_RSI_TF, g_HMA_Timeframe, g_RSI_Price) are redeclared alongside them. MQL5 silently keeps the first definition and ignores the rest, so it compiles, but it is a clear sign the file was concatenated from several drafts.
Defaults worth knowing for backtesting: 1.0 fixed lot, 200-point SL, 3000-point TP, 3-point slippage, FOK filling, magic 22216054, comment "Psgrowth.com Expert_16054", XAUUSD M5/H1, no lot multiplier, no risk-percent sizing, no recovery mode. The 3000-point TP is large compared to the 200-point SL — a 1:15 reward-to-risk ratio that depends almost entirely on the dynamic profit lock trailing to keep winners from being given back. Most realistic backtest behaviour on a 1.0-lot XAUUSD M5 chart will see frequent 100-200 point winners with the lock engaging, occasional larger runners that trend through, and a small number of full 200-point losers when the dynamic lock never gets a chance to engage before the SL hits. The MEDIUM risk label reflects that the trailing lock takes the sting out of most breakouts, but a 1.0-lot default on a $100 minimum deposit leaves very thin margin for error if the user does not increase the deposit to at least $1,000 before going live.
Strategy Deep Dive
Each tick, IsBasicTradeConditionsMet rejects quotes with bad ASK/BID, spread above MaxSpread=20 points, terminal trade disabled, or symbol trade mode off. ManageExistingPositions then walks open positions, calculating profit in points and ratcheting the stop to current_price ± 100 points each time profit advances by 200 points (the LockProfitEvery_X_Points/LockMinusBuffer pair), while also checking any enabled DC/MBS/RSI exit triggers. The entry cascade Donchian → MBS → RSI → HMA fires the first non-empty string, and the optional per-indicator confirmation toggles (all off by default) can veto it. ShouldOpenAdditionalPosition then enforces MaxOpenTrades=5 plus the 500-points-per-position profitable-additions gate. trade.Buy or trade.Sell is sent with the 200/3000 SL/TP, magic 22216054, and the user-set Lots.
A BUY or SELL string is produced by a fixed priority cascade inside OnTick — DonchianChannel_Decision first, then MBS_Decision, then RSI_Decision, then HMA_Decision. Donchian requires a 20-bar high/low breakout with a 5-point pullback, ATR(14) ≤ 1.5× the prior bar, and breakout size ≥ 10 points. MBS requires a 20-bar resistance/support break ≥ 50 points, 2-bar average momentum ≥ 0.7 in absolute terms, 60% EMA agreement, and current ATR ≤ 1.5× average. RSI requires the 14-period RSI in the OB/OS zone with monotonic 3-bar momentum and sufficient range. HMA requires a hand-computed 21-period Hull line with positive slope, ≥ 5 points of momentum, and price above the line.
Exits come from three paths. The broker hits the fixed 200-point SL or 3000-point TP. The dynamic profit lock in ManageExistingPositions ratchets the stop to current_price ± LockMinusBuffer=100 points every time profit advances by LockProfitEvery_X_Points=200 points, so a 50% retention trail engages after each 200-point move. If any of the indicator exit toggles (DC_ExitTrigger_, MBS_ExitTrigger_, RSI_ExitTrigger_*) is enabled for the open side, an Exit Buy or Exit Sell string from that indicator closes the position via TryClose_EX16054 with 3 retries on REQUOTE/TIMEOUT/PRICE_OFF/PRICE_CHANGED.
HardSL_Points=200 is sent to the broker as a fixed per-trade stop. The dynamic profit lock in ManageExistingPositions overrides that SL on every tick once profit clears 200 points, ratcheting the stop to current_price − 100 (longs) or + 100 (shorts) every additional 200 points of favourable move. There is no break-even step, no ATR-adaptive trail, and no max-drawdown account cap.
TP_Points=3000 is sent to the broker as the take-profit target — a 1:15 reward-to-risk ratio against the 200-point SL. In practice the dynamic profit lock engages well before TP is reached on most trades, so the effective TP for the majority of winners is the ratcheted stop at 100 points of locked profit plus whatever additional run the lock allows.
Recommended for XAUUSD M5 or H1 charts on a low-spread ECN or RAW broker, with a minimum balance of $1,000 even though the EA's stated minimum is $100 — the 1.0-lot default on gold can produce 200-point full-loss hits that would be unrecoverable on a smaller account. Best deployed during the London and New York sessions when gold volatility and the 14-period RSI, 20-bar Donchian channel, and 21-period HMA all have enough range to fire; quieter Asian-session hours will produce few signals. The MEDIUM risk label assumes the 200/100 dynamic profit lock is doing its job — turn off EnableDynamicLockProfit only if you understand you are giving back the trailing-stop protection.
Strategy Logic
Pipsgrowth EX16054 Trend — Strategy Logic Analysis (from .mq5 source)
Family: Trend
Magic: 22216054
Version: 2.00
BRIEF:
Momentum + Structure Breakout EA combining Donchian Channel, RSI and Hull Moving Average for trend-following breakout entries with dynamic profit locking. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
DonchianChannel_Decision()MBS_Decision()HMA_Decision()ShouldOpenAdditionalPosition()CheckAdditionalPositionConfirmation()IsBasicTradeConditionsMet()ManageExistingPositions()RSI_Decision()TryClose_EX16054()TryClosePartial_EX16054()TryModify_EX16054()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (94 total across 8 groups):
- [=== Trade Settings ===]
InpMagic=22216054//EAMagic Number - [=== Trade Settings ===]
InpTradeComment= "Psgrowth.com Expert_16054" // Trade comment - [=== Trade Settings ===] Lots =
1.0// Lot size for trades - [=== Trade Settings ===]
MaxSpread= 20 // Maximum spread in points - [=== Trade Settings ===] Slippage = 3 // Maximum slippage in points
- [=== Trade Settings ===]
AllowBuyTrades=true// AllowBUYtrades - [=== Trade Settings ===]
AllowSellTrades=true// AllowSELLtrades - [=== TP/SL Settings ===]
HardSL_Points= 200 // Stop Loss in points - [=== TP/SL Settings ===] TP_Points = 3000 // Take Profit in points
- [=== TP/SL Settings ===]
LockProfitEvery_X_Points=200.0// Step: every X points profit - [=== TP/SL Settings ===]
LockMinusBuffer=100.0// Lock profit minus X point buffer - [=== Additional Positions Management Settings ===]
MaxOpenTrades= 5 // Maximum allowed open trades at the same time in all directions - [=== Additional Positions Management Settings ===]
AllowOnlyProfitableAdditions=true// Only allow adding positions if existing trades are profitable - [=== Additional Positions Management Settings ===]
MinProfitInPointsPerTradeToAdd=500.0// Minimum profit required per existing trade in points - [=== Debug ===]
EnableDebug=false// Enable debug logging - [=== Momentum + Structure Breakout Settings ===] MBS_EntrySignal_BUY =
true// EnableMBSBUYentry signal - [=== Momentum + Structure Breakout Settings ===] MBS_EntrySignal_SELL =
true// EnableMBSSELLentry signal - [=== Momentum + Structure Breakout Settings ===] MBS_Confirm_BUY =
false// RequireMBSBUYconfirmation - [=== Momentum + Structure Breakout Settings ===] MBS_Confirm_SELL =
false// RequireMBSSELLconfirmation - [=== Momentum + Structure Breakout Settings ===] MBS_ExitTrigger_BUY =
false// EnableMBSBUYexit trigger - [=== Momentum + Structure Breakout Settings ===] MBS_ExitTrigger_SELL =
false// EnableMBSSELLexit trigger - [=== Momentum + Structure Breakout Settings ===] MBS_ExitConfirm_BUY =
false// RequireMBSBUYexit confirmation - [=== Momentum + Structure Breakout Settings ===] MBS_ExitConfirm_SELL =
false// RequireMBSSELLexit confirmation - [=== Momentum + Structure Breakout Settings ===] MBS_Timeframe = 0 //
Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for analysis - [=== Momentum + Structure Breakout Settings ===] MBS_LookbackBars = 20 // Lookback period for structure analysis
- [=== Momentum + Structure Breakout Settings ===] MBS_MinBreakoutSize = 50 // Minimum breakout size in points
- [=== Momentum + Structure Breakout Settings ===] MBS_MomentumThreshold =
0.7// Momentum strength threshold (0-1) - [=== Momentum + Structure Breakout Settings ===] MBS_ConfirmationBars = 2 // Bars needed for confirmation
- [=== Momentum + Structure Breakout Settings ===] MBS_VolatilityFilter =
1.5// Volatility filter multiplier - [=== Momentum + Structure Breakout Settings ===] MBS_TrendStrengthMin =
0.6// Minimum trend strength (0-1) - [=== Momentum + Structure Breakout Settings ===] MBS_RequireVolumeSpike =
true// Require volume confirmation - [=== Momentum + Structure Breakout Settings ===] MBS_VolumeMultiplier =
1.5// Volume spike multiplier - [=== Momentum + Structure Breakout Settings ===] MBS_ATRPeriod = 14 //
ATRperiod for volatility - [=== Momentum + Structure Breakout Settings ===] MBS_ATRMultiplier =
1.0//ATRmultiplier for breakout validation - [=== Momentum + Structure Breakout Settings ===] MBS_EMAPeriod = 21 //
EMAperiod for trend direction - [=== Momentum + Structure Breakout Settings ===] MBS_MinPriceMovement =
0.0001// Minimum price movement for signal - [=== Donchian Channel Settings ===] DC_EntrySignal_BUY =
true// Enable Donchian ChannelBUYentry signal - [=== Donchian Channel Settings ===] DC_EntrySignal_SELL =
true// Enable Donchian ChannelSELLentry signal - [=== Donchian Channel Settings ===] DC_Confirm_BUY =
false// Require Donchian ChannelBUYconfirmation - [=== Donchian Channel Settings ===] DC_Confirm_SELL =
false// Require Donchian ChannelSELLconfirmation - [=== Donchian Channel Settings ===] DC_ExitTrigger_BUY =
false// Enable Donchian ChannelBUYexit trigger - [=== Donchian Channel Settings ===] DC_ExitTrigger_SELL =
false// Enable Donchian ChannelSELLexit trigger - [=== Donchian Channel Settings ===] DC_ExitConfirm_BUY =
false// Require Donchian ChannelBUYexit confirmation - [=== Donchian Channel Settings ===] DC_ExitConfirm_SELL =
false// Require Donchian ChannelSELLexit confirmation - [=== Donchian Channel Settings ===] DC_Timeframe = 0 //
Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for Donchian Channel - [=== Donchian Channel Settings ===] DC_ChannelPeriod = 20 // Lookback period for channel
- [=== Donchian Channel Settings ===] DC_ConfirmationBars = 2 // Bars needed for confirmation
- [=== Donchian Channel Settings ===] DC_MinBreakoutPoints = 10 // Minimum breakout size in points
- [=== Donchian Channel Settings ===] DC_ATRMultiplier =
1.0//ATRmultiplier for volatility filter - [=== Donchian Channel Settings ===] DC_ATRPeriod = 14 //
ATRperiod for volatility - [=== Donchian Channel Settings ===] DC_RequireVolumeSpike =
false// Require volume spike confirmation - [=== Donchian Channel Settings ===] DC_VolumeMultiplier =
1.5// Volume spike multiplier - [=== Donchian Channel Settings ===] DC_MinPullbackPoints = 5 // Minimum pullback before breakout (anti-fakeout)
- [=== Donchian Channel Settings ===] DC_MinRangePoints = 20 // Minimum channel range to avoid chop
- [===
RSISettings ===] RSI_EntrySignal_BUY =true// EnableRSIBUYentry signal - [===
RSISettings ===] RSI_EntrySignal_SELL =true// EnableRSISELLentry signal - [===
RSISettings ===] RSI_Confirm_BUY =false// RequireRSIBUYconfirmation - [===
RSISettings ===] RSI_Confirm_SELL =false// RequireRSISELLconfirmation - [===
RSISettings ===] RSI_ExitTrigger_BUY =false// EnableRSIBUYexit trigger - [===
RSISettings ===] RSI_ExitTrigger_SELL =false// EnableRSISELLexit trigger - [===
RSISettings ===] RSI_ExitConfirm_BUY =false// RequireRSIBUYexit confirmation - [===
RSISettings ===] RSI_ExitConfirm_SELL =false// RequireRSISELLexit confirmation - [===
RSISettings ===]RSI_TF= 0 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe forRSI - [===
RSISettings ===] RSI_Period = 14 //RSIperiod - [===
RSISettings ===] RSI_Price = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Applied price forRSI - [===
RSISettings ===] RSI_Overbought = 70 // OverboughtlevelforRSI - [===
RSISettings ===] RSI_Oversold = 30 // OversoldlevelforRSI - [===
RSISettings ===] RSI_SignalShift = 0 // Shift forRSIsignal line - [===
RSISettings ===] RSI_Midline = 50 //RSImidlinelevel - [===
RSISettings ===] RSI_ExtremeBuffer = 5 // Buffer for extreme levels (anti-whipsaw) - [===
RSISettings ===] RSI_MinRange =5.0// MinimumRSIrange for valid signal - [===
RSISettings ===] RSI_MinVolatility =2.0// Minimum volatility threshold - [===
RSISettings ===] RSI_MomentumBars = 3 // Bars for momentum confirmation - [===
RSISettings ===] RSI_DeadZoneSize =5.0// Dead zone around midline - [=== Hull Moving
Average(HMA) Settings ===] HMA_EntrySignal_BUY =true// EnableHMABUYentry signal - [=== Hull Moving
Average(HMA) Settings ===] HMA_EntrySignal_SELL =true// EnableHMASELLentry signal - [=== Hull Moving
Average(HMA) Settings ===] HMA_Confirm_BUY =false// RequireHMABUYconfirmation - [=== Hull Moving
Average(HMA) Settings ===] HMA_Confirm_SELL =false// RequireHMASELLconfirmation - [=== Hull Moving
Average(HMA) Settings ===] HMA_ExitTrigger_BUY =false// EnableHMABUYexit trigger - [=== Hull Moving
Average(HMA) Settings ===] HMA_ExitTrigger_SELL =false// EnableHMASELLexit trigger - [=== Hull Moving
Average(HMA) Settings ===] HMA_ExitConfirm_BUY =false// RequireHMABUYexit confirmation - [=== Hull Moving
Average(HMA) Settings ===] HMA_ExitConfirm_SELL =false// RequireHMASELLexit confirmation - [=== Hull Moving
Average(HMA) Settings ===] HMA_Timeframe = 0 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe forHMAanalysis - [=== Hull Moving
Average(HMA) Settings ===] HMA_Period = 21 //HMAperiod - [=== Hull Moving
Average(HMA) Settings ===] HMA_ConfirmationBars = 2 // Bars needed for confirmation - [=== Hull Moving
Average(HMA) Settings ===] HMA_MinSlopeAngle =0.0001// Minimum slope angle for trend detection - [=== Hull Moving
Average(HMA) Settings ===] HMA_MinMomentumPoints = 5 // Minimum momentum in points - [=== Hull Moving
Average(HMA) Settings ===] HMA_RequirePriceAbove =true// Require price aboveHMAfor buy - [=== Hull Moving
Average(HMA) Settings ===] HMA_RequirePriceBelow =true// Require price belowHMAfor sell - [=== Hull Moving
Average(HMA) Settings ===] HMA_FilterATRMultiplier =1.5//ATRmultiplier for noise filter - [=== Hull Moving
Average(HMA) Settings ===] HMA_FilterATRPeriod = 14 //ATRperiod for volatility filter - [=== Hull Moving
Average(HMA) Settings ===] HMA_TrendStrengthMin =0.7// Minimum trend strength (0-1) - [=== Hull Moving
Average(HMA) Settings ===] HMA_SmoothingBars = 3 // Bars forHMAsmoothing validation - [=== Hull Moving
Average(HMA) Settings ===] HMA_MinPriceDistance = 2 // Minimum distance fromHMAin points
// Pipsgrowth EX16054 Trend — Execution Flow (from source analysis)
// Family: Trend
// Momentum + Structure Breakout EA combining Donchian Channel, RSI and Hull Moving Average for trend-following breakout entries with dynamic profit locking. 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 |
|---|---|---|
| InpMagic | 22216054 | EA Magic Number |
| InpTradeComment | "Psgrowth.com Expert_16054" | Trade comment |
| Lots | 1.0 | Lot size for trades |
| MaxSpread | 20 | Maximum spread in points |
| Slippage | 3 | Maximum slippage in points |
| AllowBuyTrades | true | Allow BUY trades |
| AllowSellTrades | true | Allow SELL trades |
| HardSL_Points | 200 | Stop Loss in points |
| TP_Points | 3000 | Take Profit in points |
| LockProfitEvery_X_Points | 200.0 | Step: every X points profit |
| LockMinusBuffer | 100.0 | Lock profit minus X point buffer |
| MaxOpenTrades | 5 | Maximum allowed open trades at the same time in all directions |
| AllowOnlyProfitableAdditions | true | Only allow adding positions if existing trades are profitable |
| MinProfitInPointsPerTradeToAdd | 500.0 | Minimum profit required per existing trade in points |
| EnableDebug | false | Enable debug logging |
| MBS_EntrySignal_BUY | true | Enable MBS BUY entry signal |
| MBS_EntrySignal_SELL | true | Enable MBS SELL entry signal |
| MBS_Confirm_BUY | false | Require MBS BUY confirmation |
| MBS_Confirm_SELL | false | Require MBS SELL confirmation |
| MBS_ExitTrigger_BUY | false | Enable MBS BUY exit trigger |
| MBS_ExitTrigger_SELL | false | Enable MBS SELL exit trigger |
| MBS_ExitConfirm_BUY | false | Require MBS BUY exit confirmation |
| MBS_ExitConfirm_SELL | false | Require MBS SELL exit confirmation |
| MBS_Timeframe | 0 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for analysis |
| MBS_LookbackBars | 20 | Lookback period for structure analysis |
| MBS_MinBreakoutSize | 50 | Minimum breakout size in points |
| MBS_MomentumThreshold | 0.7 | Momentum strength threshold (0-1) |
| MBS_ConfirmationBars | 2 | Bars needed for confirmation |
| MBS_VolatilityFilter | 1.5 | Volatility filter multiplier |
| MBS_TrendStrengthMin | 0.6 | Minimum trend strength (0-1) |
| MBS_RequireVolumeSpike | true | Require volume confirmation |
| MBS_VolumeMultiplier | 1.5 | Volume spike multiplier |
| MBS_ATRPeriod | 14 | ATR period for volatility |
| MBS_ATRMultiplier | 1.0 | ATR multiplier for breakout validation |
| MBS_EMAPeriod | 21 | EMA period for trend direction |
| MBS_MinPriceMovement | 0.0001 | Minimum price movement for signal |
| DC_EntrySignal_BUY | true | Enable Donchian Channel BUY entry signal |
| DC_EntrySignal_SELL | true | Enable Donchian Channel SELL entry signal |
| DC_Confirm_BUY | false | Require Donchian Channel BUY confirmation |
| DC_Confirm_SELL | false | Require Donchian Channel SELL confirmation |
| DC_ExitTrigger_BUY | false | Enable Donchian Channel BUY exit trigger |
| DC_ExitTrigger_SELL | false | Enable Donchian Channel SELL exit trigger |
| DC_ExitConfirm_BUY | false | Require Donchian Channel BUY exit confirmation |
| DC_ExitConfirm_SELL | false | Require Donchian Channel SELL exit confirmation |
| DC_Timeframe | 0 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for Donchian Channel |
| DC_ChannelPeriod | 20 | Lookback period for channel |
| DC_ConfirmationBars | 2 | Bars needed for confirmation |
| DC_MinBreakoutPoints | 10 | Minimum breakout size in points |
| DC_ATRMultiplier | 1.0 | ATR multiplier for volatility filter |
| DC_ATRPeriod | 14 | ATR period for volatility |
| DC_RequireVolumeSpike | false | Require volume spike confirmation |
| DC_VolumeMultiplier | 1.5 | Volume spike multiplier |
| DC_MinPullbackPoints | 5 | Minimum pullback before breakout (anti-fakeout) |
| DC_MinRangePoints | 20 | Minimum channel range to avoid chop |
| RSI_EntrySignal_BUY | true | Enable RSI BUY entry signal |
| RSI_EntrySignal_SELL | true | Enable RSI SELL entry signal |
| RSI_Confirm_BUY | false | Require RSI BUY confirmation |
| RSI_Confirm_SELL | false | Require RSI SELL confirmation |
| RSI_ExitTrigger_BUY | false | Enable RSI BUY exit trigger |
| RSI_ExitTrigger_SELL | false | Enable RSI SELL exit trigger |
| RSI_ExitConfirm_BUY | false | Require RSI BUY exit confirmation |
| RSI_ExitConfirm_SELL | false | Require RSI SELL exit confirmation |
| RSI_TF | 0 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for RSI |
| RSI_Period | 14 | RSI period |
| RSI_Price | 1 | Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Applied price for RSI |
| RSI_Overbought | 70 | Overbought level for RSI |
| RSI_Oversold | 30 | Oversold level for RSI |
| RSI_SignalShift | 0 | Shift for RSI signal line |
| RSI_Midline | 50 | RSI midline level |
| RSI_ExtremeBuffer | 5 | Buffer for extreme levels (anti-whipsaw) |
| RSI_MinRange | 5.0 | Minimum RSI range for valid signal |
| RSI_MinVolatility | 2.0 | Minimum volatility threshold |
| RSI_MomentumBars | 3 | Bars for momentum confirmation |
| RSI_DeadZoneSize | 5.0 | Dead zone around midline |
| HMA_EntrySignal_BUY | true | Enable HMA BUY entry signal |
| HMA_EntrySignal_SELL | true | Enable HMA SELL entry signal |
| HMA_Confirm_BUY | false | Require HMA BUY confirmation |
| HMA_Confirm_SELL | false | Require HMA SELL confirmation |
| HMA_ExitTrigger_BUY | false | Enable HMA BUY exit trigger |
| HMA_ExitTrigger_SELL | false | Enable HMA SELL exit trigger |
| HMA_ExitConfirm_BUY | false | Require HMA BUY exit confirmation |
| HMA_ExitConfirm_SELL | false | Require HMA SELL exit confirmation |
| HMA_Timeframe | 0 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for HMA analysis |
| HMA_Period | 21 | HMA period |
| HMA_ConfirmationBars | 2 | Bars needed for confirmation |
| HMA_MinSlopeAngle | 0.0001 | Minimum slope angle for trend detection |
| HMA_MinMomentumPoints | 5 | Minimum momentum in points |
| HMA_RequirePriceAbove | true | Require price above HMA for buy |
| HMA_RequirePriceBelow | true | Require price below HMA for sell |
| HMA_FilterATRMultiplier | 1.5 | ATR multiplier for noise filter |
| HMA_FilterATRPeriod | 14 | ATR period for volatility filter |
| HMA_TrendStrengthMin | 0.7 | Minimum trend strength (0-1) |
| HMA_SmoothingBars | 3 | Bars for HMA smoothing validation |
| HMA_MinPriceDistance | 2 | Minimum distance from HMA in points |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX16054 new1 -- Momentum Structure Breakout with Donchian, RSI, HMA, full 12-layer stack."
#include <Trade\Trade.mqh>
CTrade trade;
// === INPUT SETTINGS ===
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_MBS_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_DC_Timeframe = PERIOD_H1;
ENUM_TIMEFRAMES g_RSI_TF = PERIOD_H1;
ENUM_TIMEFRAMES g_HMA_Timeframe = PERIOD_H1;
ENUM_APPLIED_PRICE g_RSI_Price = PRICE_CLOSE;
input group "=== Trade Settings ===";
input ulong InpMagic = 22216054; // EA Magic Number
input string InpTradeComment = "Psgrowth.com Expert_16054"; // Trade comment
input double Lots = 1.0; // Lot size for trades
input double MaxSpread = 20; // Maximum spread in points
input double Slippage = 3; // Maximum slippage in points
input bool AllowBuyTrades = true; // Allow BUY trades
input bool AllowSellTrades = true; // Allow SELL trades
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M5;
case 3: return PERIOD_M15;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.