Pipsgrowth EX16055 Trend
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX16055 new1 -- Momentum Structure Breakout with Donchian, RSI, HMA, full 12-layer stack.
Overview
Pipsgrowth EX16055 Trend is a four-engine, indicator-pluggable breakout system built around a 4,400-line source file that lets the trader pick which of four signal families actually fires orders. The four engines are Momentum + Structure Breakout (MBS), Donchian Channel (DC), RSI, and Hull Moving Average (HMA); each engine exposes three boolean toggles for entry, confirmation, and exit, plus its own indicator parameter block, so the same EA can run as a pure MBS structure trader, a Donchian breakout system, an RSI reversal system, an HMA trend follower, or any hybrid of the four. Out of the box, only MBS_EntrySignal_BUY and MBS_EntrySignal_SELL are true, so the default behaviour is what the file header calls 'Momentum + Structure Breakout' on the chart's own timeframe. The other engines sit dormant in the input list, ready to be promoted to entry, confirmation, or exit duty by flipping their bools.
The headline MBS engine treats every potential setup as a four-part vote. First it scans the previous MBS_LookbackBars (default 20) and draws a horizontal resistance at the highest high and a horizontal support at the lowest low inside that window. Then it checks whether the current bar closes beyond that band while the previous bar was on the inside — the textbook 'previous bar inside, current bar outside' breakout. Third, it counts the prior MBS_ConfirmationBars (default 2) closes and refuses the signal unless at least 60% of them confirm the breakout side; that is its anti-whipsaw guard. Fourth, it overlays three filters: a volume spike check that demands current tick volume be at least 1.5x the trimmed average of the lookback (with the top and bottom 10% of values stripped out) and at least 1.2x the previous bar's volume; an EMA(21) trend filter that requires price to be on the correct side of the EMA with a 2-point minimum distance; and a momentum-score check that requires at least 60% of the last few bars to have closed bullish (or bearish). The ATR(14) on the MBS timeframe runs a separate volatility gate: the current ATR divided by the previous ATR must stay below MBS_VolatilityFilter (default 1.5), with the threshold widening to 1.8x when the structure range is large (5x ATR) and tightening to 1.2x when the structure is tight (under 2x ATR). All nine of these sub-tests are AND-gated — missing any one of them returns NO_SIGNAL.
The other three engines follow the same skeleton but with different guts. DonchianChannel_Decision() takes the highest high and lowest low over DC_ChannelPeriod (default 20) and waits for the current bar's close to clear that band with a minimum DC_MinBreakoutPoints (default 10) size; a DC_MinPullbackPoints anti-fakeout test (default 5 points) demands that the market has retreated from the band edge in the recent DC_ConfirmationBars before the breakout counts; DC_MinRangePoints (default 20) rejects breakouts in narrow channels. RSI_Decision() reads iRSI(RSI_Period, default 14) and demands a cross through RSI_Oversold (30) for buys and RSI_Overbought (70) for sells, plus a three-bar momentum confirmation and a 5-point RSI_MinRange to keep the EA from trading in dead zones. HMA_Decision() builds a full Hull Moving Average by hand — it computes WMA(period/2), WMA(period), forms 2*WMA(n/2) - WMA(n), then smooths the result with WMA(sqrt(period)) — and reads slope, momentum in points, and 70% smoothness across HMA_SmoothingBars before it will return a signal. The manual HMA math is the slowest path in the file, so the function caches its last 10 values in a rolling buffer and only recomputes when the bar changes.
The OnTick orchestrator at line 1706 is the heart of the file and follows a strict nine-step ladder. Step 1 calls IsBasicTradeConditionsMet(), which fails the tick if the spread is above MaxSpread (20 points), the terminal is disconnected, the symbol is in close-only mode, free margin is below 200% of the new-trade requirement, or the equity ratio has fallen below 50%. Step 2 runs ManageExistingPositions() to apply trailing/profit-lock and process exit signals. Step 3 polls the four engines in entry mode and sets main_signal the moment ANY enabled engine returns a BUY (or SELL) string; the rest of the engines are not consulted, so this is OR logic. Step 4 then runs every enabled confirmation engine and demands that ALL of them agree — this is the AND gate. Step 5 optionally runs an N-bar stability filter that holds the signal until it has been observed for BarDelay bars in a row. Step 6 calls ShouldOpenAdditionalPosition(), which performs a full portfolio risk audit (max 20% exposure per direction, max 50% margin usage, max 5% single-trade loss, max 15% drawdown) before allowing a new order. Step 7 calls CheckAdditionalPositionConfirmation(), a priority chain (DC > MBS > RSI > HMA) that overrides on a passing DC vote. Step 8 computes HardSL_Points=15 and TP_Points=3000, giving the default an extreme 1:200 reward-to-risk ratio. Step 9 sends the market order with the magic 22216055 and the comment 'Psgrowth.com Expert_16055'.
The trailing/profit-lock logic in ManageExistingPositions() only fires once the position is at least LockProfitEvery_X_Points (30) points in profit; it then ratchets the stop to current_price minus LockMinusBuffer (15) for buys, with a minimum 10-point lock above the open price. Exit signals flow through a four-engine priority chain (DC > MBS > RSI > HMA), but the file refuses to act on any exit whose absolute profit is below 5 points or whose position is younger than 30 minutes, which keeps noise from churning the account. The retry helper at the end of the file (TryClose_EX16055 / TryClosePartial_EX16055 / TryModify_EX16055) wraps each CTrade call in a three-attempt loop with a 100–200 ms Sleep on REQUOTE / TIMEOUT / PRICE_OFF / PRICE_CHANGED, but TryClosePartial is dead code — no partial-close path calls it. InitializeBuffers() and ValidateAndSyncBuffers() handle all the global price/indicator arrays with a success-rate check that drops the buffer size to half and flags emergency mode if fewer than 80% of the resizes succeed. With 97 inputs, 15 functions, and 5 native indicator handles (iRSI + iMA + 3x iATR), EX16055 is a framework file: a trader who wants to A/B test MBS against DC against HMA on the same chart only needs to flip the bools, not recompile.
In backtest on XAUUSD M5 the EA behaves like a momentum breakout system: most days produce zero or one signal because the MBS engine's combined filter stack is strict, and the 1:200 default reward-to-risk is set up to be paid on the occasional big trend day rather than every chop session. Users trading tighter timeframes or lower-volatility symbols should drop TP_Points substantially (the 3000-point default will never fill on EURUSD H1) and consider enabling DC_Confirm_BUY/SELL as a second-pass confirmation to cut the MBS-only false breakouts. Standard account balances of $500+ comfortably support the 1.0-lot default, but the multi-position system with MaxOpenTrades=5 can quickly pyramid exposure, so EnableDynamicLockProfit should be left at its true default and the 20% per-direction exposure cap inside ShouldOpenAdditionalPosition is the most important number to monitor on a live account.
Strategy Deep Dive
Each tick the file runs IsBasicTradeConditionsMet() first, which fails the tick when spread exceeds MaxSpread=20 points, the terminal is offline, free margin is below 200% of the next-trade requirement, or equity has fallen below 50% of balance. ManageExistingPositions() then walks every open position, applies the LockProfitEvery_X_Points=30 / LockMinusBuffer=15 ratchet once a position is 30+ points in profit, and polls the four engines (DC > MBS > RSI > HMA) in exit mode. Entry detection then queries whichever engines have their EntrySignal toggles set: by default only MBS is on, and it requires a 20-bar swing-high/low band break with 60% confirmation across 2 bars, a 1.5x volume spike, an EMA(21) trend with 2-point minimum distance, a 60% bullish-bar momentum score, and an ATR(14) volatility ratio below 1.5. Once any engine fires, every enabled Confirmation engine must agree, the N-bar delay filter optionally waits BarDelay bars, ShouldOpenAdditionalPosition() audits the portfolio for the 20% exposure and 15% drawdown caps, CheckAdditionalPositionConfirmation() runs the same priority chain for the new trade, and only then does the EA compute price/SL/TP and send trade.Buy() or trade.Sell() with magic 22216055 and comment 'Psgrowth.com Expert_16055'.
Entry is governed by whichever of four pluggable engines is enabled, with MBS (Momentum + Structure Breakout) on by default: it scans the last MBS_LookbackBars=20 for a horizontal resistance/support band, demands a 'previous bar inside, current bar outside' close beyond that band, requires 60% of the last MBS_ConfirmationBars=2 to confirm the breakout side, and overlays AND-gated filters for volume spike (>=1.5x trimmed avg), EMA(21) trend with a 2-point minimum distance, a 60% bullish-bearish-bar momentum score, and an ATR(14) volatility ratio below MBS_VolatilityFilter=1.5. If DC, RSI, or HMA is promoted to entry duty, that engine alone is sufficient to fire; the rest of the engines are not consulted for the signal, then all enabled confirmations must agree before the order is placed.
Exits run on a four-engine priority chain (DC > MBS > RSI > HMA) inside ManageExistingPositions(), but the EA filters out any exit whose absolute profit is below 5 points or whose position is younger than 30 minutes to suppress noise, and TryClose_EX16055 retries each CTrade close three times on REQUOTE/TIMEOUT/PRICE_OFF/PRICE_CHANGED with 200ms Sleep between attempts. A simple reverse-signal logic is also implicit: if the opposite-side engine triggers while a position is open, the file's exit pipeline closes the position the same way it closes a regular exit-signal position.
HardSL_Points=15 by default, placed 15 points from entry on every order; once a position reaches LockProfitEvery_X_Points=30 in profit, ManageExistingPositions() ratchets the stop to current_price minus LockMinusBuffer=15 points (for buys) with a guaranteed 10-point lock above the open price to keep the trade at minimum break-even after the first profit milestone. There is no per-position trailing beyond this one ratchet and no break-even function in the file.
TP_Points=3000 by default, which is an unusually wide 1:200 reward-to-risk against the 15-point SL and is intended to be paid only on large breakout days, not every trade; the TP is set as a broker-side limit on the entry order and is not actively managed by the EA once the position is open.
Designed for XAUUSD M5 with a $100 minimum deposit (a $500+ balance is more honest given the 1.0-lot default and the multi-position system can pyramid to 5 concurrent trades), MEDIUM risk, and a standard or ECN broker with low spread since MaxSpread=20 points is a hard gate. The strategy is trend-following breakout, so London and New York sessions provide the cleanest MBS signals; Asian-session breakouts on gold will frequently fail the 60% confirmation requirement and produce noise. Users trading FX majors or anything with a 4–5 digit point value should drop TP_Points from 3000 to a sane level (50–200) before any live test.
Strategy Logic
Pipsgrowth EX16055 Trend — Strategy Logic Analysis (from .mq5 source)
Family: Trend
Magic: 22216055
Version: 2.00
BRIEF:
Momentum + Structure Breakout EA combining Donchian Channel, RSI and Hull Moving Average with adaptive buffer management and delay filters for trend-following breakout entries. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
InitializeBuffers()ValidateAndSyncBuffers()CleanupBuffers()IsBasicTradeConditionsMet()ManageExistingPositions()IsSignalStable()DonchianChannel_Decision()RSI_Decision()MBS_Decision()HMA_Decision()ShouldOpenAdditionalPosition()CheckAdditionalPositionConfirmation()- ...and 3 more
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (97 total across 8 groups):
- [=== Trade Settings ===]
InpMagic=22216055//EAMagic Number - [=== Trade Settings ===]
InpTradeComment= "Psgrowth.com Expert_16055" // 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 - [=== Trade Settings ===]
EntryDelayBars= 1 // wait this many full new bars before placing a new entry - [=== Trade Settings ===]
EnableDelayFilter=false// Enable N-bar delay confirmation filter - [=== Trade Settings ===]
BarDelay= 1 // Number of bars delay required for signal confirmation - [=== TP/SL Settings ===]
HardSL_Points= 15 // Stop Loss in points - [=== TP/SL Settings ===] TP_Points = 3000 // Take Profit in points
- [=== TP/SL Settings ===]
LockProfitEvery_X_Points=30.0// Step: every X points profit - [=== TP/SL Settings ===]
LockMinusBuffer=15.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=20.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 =
false// Enable Donchian ChannelBUYentry signal - [=== Donchian Channel Settings ===] DC_EntrySignal_SELL =
false// 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 DonchianChannel(M1-D1) - [=== Donchian Channel Settings ===] DC_ChannelPeriod = 20 // Lookback period for channel (10,5,60)
- [=== Donchian Channel Settings ===] DC_ConfirmationBars = 2 // Bars needed for confirmation (1,1,5 or 20)
- [=== Donchian Channel Settings ===] DC_MinBreakoutPoints = 10 // Minimum breakout size in points (1,5,100) my
- [=== Donchian Channel Settings ===] DC_ATRMultiplier =
1.0//ATRmultiplier for volatility filter (0.5,0.25,2.0) my (0.5,0.25,2) - [=== Donchian Channel Settings ===] DC_ATRPeriod = 14 //
ATRperiod for volatility (5,1,30) my (5,1,50) - [=== Donchian Channel Settings ===] DC_RequireVolumeSpike =
false// Require volume spike confirmation - [=== Donchian Channel Settings ===] DC_VolumeMultiplier =
1.5// Volume spike multiplier range:1.0…3.0step0.5(my 1,0.15,5) - [=== Donchian Channel Settings ===] DC_MinPullbackPoints = 5 // Minimum pullback before breakout (anti-fakeout) – range: 0 … 20 step 2 my : 0,1,50
- [=== Donchian Channel Settings ===] DC_MinRangePoints = 20 // Minimum channel range to avoid chop – range: 10 … 100 step 10 , my 5-10,100
- [===
RSISettings ===] RSI_EntrySignal_BUY =false// EnableRSIBUYentry signal - [===
RSISettings ===] RSI_EntrySignal_SELL =false// 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 =false// EnableHMABUYentry signal - [=== Hull Moving
Average(HMA) Settings ===] HMA_EntrySignal_SELL =false// 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 EX16055 Trend — Execution Flow (from source analysis)
// Family: Trend
// Momentum + Structure Breakout EA combining Donchian Channel, RSI and Hull Moving Average with adaptive buffer management and delay filters for trend-following breakout entries. 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 | 22216055 | EA Magic Number |
| InpTradeComment | "Psgrowth.com Expert_16055" | 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 |
| EntryDelayBars | 1 | wait this many full new bars before placing a new entry |
| EnableDelayFilter | false | Enable N-bar delay confirmation filter |
| BarDelay | 1 | Number of bars delay required for signal confirmation |
| HardSL_Points | 15 | Stop Loss in points |
| TP_Points | 3000 | Take Profit in points |
| LockProfitEvery_X_Points | 30.0 | Step: every X points profit |
| LockMinusBuffer | 15.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 | 20.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 | false | Enable Donchian Channel BUY entry signal |
| DC_EntrySignal_SELL | false | 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 (M1-D1) |
| DC_ChannelPeriod | 20 | Lookback period for channel (10,5,60) |
| DC_ConfirmationBars | 2 | Bars needed for confirmation (1,1,5 or 20) |
| DC_MinBreakoutPoints | 10 | Minimum breakout size in points (1,5,100) my |
| DC_ATRMultiplier | 1.0 | ATR multiplier for volatility filter (0.5,0.25,2.0) my (0.5,0.25,2) |
| DC_ATRPeriod | 14 | ATR period for volatility (5,1,30) my (5,1,50) |
| DC_RequireVolumeSpike | false | Require volume spike confirmation |
| DC_VolumeMultiplier | 1.5 | Volume spike multiplier range: 1.0 … 3.0 step 0.5 (my 1,0.15,5) |
| DC_MinPullbackPoints | 5 | Minimum pullback before breakout (anti-fakeout) – range: 0 … 20 step 2 my : 0,1,50 |
| DC_MinRangePoints | 20 | Minimum channel range to avoid chop – range: 10 … 100 step 10 , my 5-10,100 |
| RSI_EntrySignal_BUY | false | Enable RSI BUY entry signal |
| RSI_EntrySignal_SELL | false | 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 | false | Enable HMA BUY entry signal |
| HMA_EntrySignal_SELL | false | 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 EX16055 new1 -- Momentum Structure Breakout with Donchian, RSI, HMA, full 12-layer stack."
#include <Trade\Trade.mqh>
CTrade trade;
//--- Globally cached handles and buffers with enhanced validation
int hRSI = INVALID_HANDLE, hMBS_EMA = INVALID_HANDLE, hMBS_ATR = INVALID_HANDLE;
int hDC_ATR = INVALID_HANDLE, hHMA_ATR = INVALID_HANDLE;
// Dynamic buffer arrays with memory optimization
double rsi_buf[];
double mbs_high[], mbs_low[], mbs_close[], mbs_ema[], mbs_atr[];
long mbs_vol[];
double dc_high[], dc_low[], dc_close[], dc_atr[];
long dc_vol[];
double hma_high[], hma_low[], hma_close[], hma_atr[], hma_values[];
// Adaptive buffer sizing with performance tracking
int maxBars = 50; // Optimized default minimum bars needed
static int last_calculated_maxBars = 0;
static bool buffers_initialized = false;
// HMA calculation optimization
datetime last_hma_calc = 0;
static double hma_cache[10]; // Rolling cache for HMA values
static int hma_cache_index = 0;
static bool hma_cache_initialized = false;
// Buffer synchronization and validation
struct BufferState
{
bool rsi_ready;
bool mbs_ready;
bool dc_ready;
bool hma_ready;
datetime last_sync;
int sync_failures;
} buffer_state = {false, false, false, false, 0, 0};
// Memory management and error recovery
struct MemoryManager
{
int total_arrays;
int successful_resizes;
int failed_resizes;
datetime last_cleanup;
bool emergency_mode;
} memory_mgr = {0, 0, 0, 0, false};
////////////////
//+------------------------------------------------------------------+
//| Add these global safety monitoring variables at the top |
//+------------------------------------------------------------------+
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.