P
PipsGrowth
Trend FollowingOpen Source – Free

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 Signal

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.

Exit Signal

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.

Stop Loss

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.

Take Profit

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.

Best For

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 MT5 indicators

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 // EA Magic 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 // Allow BUY trades
  • [=== Trade Settings ===] AllowSellTrades = true // Allow SELL trades
  • [=== 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 // Enable MBS BUY entry signal
  • [=== Momentum + Structure Breakout Settings ===] MBS_EntrySignal_SELL = true // Enable MBS SELL entry signal
  • [=== Momentum + Structure Breakout Settings ===] MBS_Confirm_BUY = false // Require MBS BUY confirmation
  • [=== Momentum + Structure Breakout Settings ===] MBS_Confirm_SELL = false // Require MBS SELL confirmation
  • [=== Momentum + Structure Breakout Settings ===] MBS_ExitTrigger_BUY = false // Enable MBS BUY exit trigger
  • [=== Momentum + Structure Breakout Settings ===] MBS_ExitTrigger_SELL = false // Enable MBS SELL exit trigger
  • [=== Momentum + Structure Breakout Settings ===] MBS_ExitConfirm_BUY = false // Require MBS BUY exit confirmation
  • [=== Momentum + Structure Breakout Settings ===] MBS_ExitConfirm_SELL = false // Require MBS SELL exit 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 // ATR period for volatility
  • [=== Momentum + Structure Breakout Settings ===] MBS_ATRMultiplier = 1.0 // ATR multiplier for breakout validation
  • [=== Momentum + Structure Breakout Settings ===] MBS_EMAPeriod = 21 // EMA period 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 Channel BUY entry signal
  • [=== Donchian Channel Settings ===] DC_EntrySignal_SELL = false // Enable Donchian Channel SELL entry signal
  • [=== Donchian Channel Settings ===] DC_Confirm_BUY = false // Require Donchian Channel BUY confirmation
  • [=== Donchian Channel Settings ===] DC_Confirm_SELL = false // Require Donchian Channel SELL confirmation
  • [=== Donchian Channel Settings ===] DC_ExitTrigger_BUY = false // Enable Donchian Channel BUY exit trigger
  • [=== Donchian Channel Settings ===] DC_ExitTrigger_SELL = false // Enable Donchian Channel SELL exit trigger
  • [=== Donchian Channel Settings ===] DC_ExitConfirm_BUY = false // Require Donchian Channel BUY exit confirmation
  • [=== Donchian Channel Settings ===] DC_ExitConfirm_SELL = false // Require Donchian Channel SELL exit 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 (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 // ATR multiplier for volatility filter (0.5,0.25,2.0) my (0.5,0.25,2)
  • [=== Donchian Channel Settings ===] DC_ATRPeriod = 14 // ATR period 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.03.0 step 0.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
  • [=== RSI Settings ===] RSI_EntrySignal_BUY = false // Enable RSI BUY entry signal
  • [=== RSI Settings ===] RSI_EntrySignal_SELL = false // Enable RSI SELL entry signal
  • [=== RSI Settings ===] RSI_Confirm_BUY = false // Require RSI BUY confirmation
  • [=== RSI Settings ===] RSI_Confirm_SELL = false // Require RSI SELL confirmation
  • [=== RSI Settings ===] RSI_ExitTrigger_BUY = false // Enable RSI BUY exit trigger
  • [=== RSI Settings ===] RSI_ExitTrigger_SELL = false // Enable RSI SELL exit trigger
  • [=== RSI Settings ===] RSI_ExitConfirm_BUY = false // Require RSI BUY exit confirmation
  • [=== RSI Settings ===] RSI_ExitConfirm_SELL = false // Require RSI SELL exit confirmation
  • [=== RSI Settings ===] RSI_TF = 0 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for RSI
  • [=== RSI Settings ===] RSI_Period = 14 // RSI period
  • [=== RSI Settings ===] RSI_Price = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Applied price for RSI
  • [=== RSI Settings ===] RSI_Overbought = 70 // Overbought level for RSI
  • [=== RSI Settings ===] RSI_Oversold = 30 // Oversold level for RSI
  • [=== RSI Settings ===] RSI_SignalShift = 0 // Shift for RSI signal line
  • [=== RSI Settings ===] RSI_Midline = 50 // RSI midline level
  • [=== RSI Settings ===] RSI_ExtremeBuffer = 5 // Buffer for extreme levels (anti-whipsaw)
  • [=== RSI Settings ===] RSI_MinRange = 5.0 // Minimum RSI range for valid signal
  • [=== RSI Settings ===] RSI_MinVolatility = 2.0 // Minimum volatility threshold
  • [=== RSI Settings ===] RSI_MomentumBars = 3 // Bars for momentum confirmation
  • [=== RSI Settings ===] RSI_DeadZoneSize = 5.0 // Dead zone around midline
  • [=== Hull Moving Average (HMA) Settings ===] HMA_EntrySignal_BUY = false // Enable HMA BUY entry signal
  • [=== Hull Moving Average (HMA) Settings ===] HMA_EntrySignal_SELL = false // Enable HMA SELL entry signal
  • [=== Hull Moving Average (HMA) Settings ===] HMA_Confirm_BUY = false // Require HMA BUY confirmation
  • [=== Hull Moving Average (HMA) Settings ===] HMA_Confirm_SELL = false // Require HMA SELL confirmation
  • [=== Hull Moving Average (HMA) Settings ===] HMA_ExitTrigger_BUY = false // Enable HMA BUY exit trigger
  • [=== Hull Moving Average (HMA) Settings ===] HMA_ExitTrigger_SELL = false // Enable HMA SELL exit trigger
  • [=== Hull Moving Average (HMA) Settings ===] HMA_ExitConfirm_BUY = false // Require HMA BUY exit confirmation
  • [=== Hull Moving Average (HMA) Settings ===] HMA_ExitConfirm_SELL = false // Require HMA SELL exit 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 for HMA analysis
  • [=== Hull Moving Average (HMA) Settings ===] HMA_Period = 21 // HMA period
  • [=== 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 above HMA for buy
  • [=== Hull Moving Average (HMA) Settings ===] HMA_RequirePriceBelow = true // Require price below HMA for sell
  • [=== Hull Moving Average (HMA) Settings ===] HMA_FilterATRMultiplier = 1.5 // ATR multiplier for noise filter
  • [=== Hull Moving Average (HMA) Settings ===] HMA_FilterATRPeriod = 14 // ATR period 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 for HMA smoothing validation
  • [=== Hull Moving Average (HMA) Settings ===] HMA_MinPriceDistance = 2 // Minimum distance from HMA in points
Pseudocode
// 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

Optimized Brokers:
ExnessIC Markets
Optimized Symbols:
XAUUSD
Optimized Timeframes:
M5H1

How to Install This EA on MT5

  1. 1Download the .mq5 file using the button above
  2. 2Open MetaTrader 5 on your computer
  3. 3Click File → Open Data Folder in the top menu
  4. 4Navigate to MQL5 → Experts and paste the .mq5 file there
  5. 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
  6. 6Drag the EA onto an H4 or Daily chart for best results
  7. 7Configure EMA periods, ADX threshold, and lot size in the dialog
  8. 8Enable Allow Algo Trading and click OK

EA Parameters

ParameterDefaultDescription
InpMagic22216055EA Magic Number
InpTradeComment"Psgrowth.com Expert_16055"Trade comment
Lots1.0Lot size for trades
MaxSpread20Maximum spread in points
Slippage3Maximum slippage in points
AllowBuyTradestrueAllow BUY trades
AllowSellTradestrueAllow SELL trades
EntryDelayBars1wait this many full new bars before placing a new entry
EnableDelayFilterfalseEnable N-bar delay confirmation filter
BarDelay1Number of bars delay required for signal confirmation
HardSL_Points15Stop Loss in points
TP_Points3000Take Profit in points
LockProfitEvery_X_Points30.0Step: every X points profit
LockMinusBuffer15.0Lock profit minus X point buffer
MaxOpenTrades5Maximum allowed open trades at the same time in all directions
AllowOnlyProfitableAdditionstrueOnly allow adding positions if existing trades are profitable
MinProfitInPointsPerTradeToAdd20.0Minimum profit required per existing trade in points
EnableDebugfalseEnable debug logging
MBS_EntrySignal_BUYtrueEnable MBS BUY entry signal
MBS_EntrySignal_SELLtrueEnable MBS SELL entry signal
MBS_Confirm_BUYfalseRequire MBS BUY confirmation
MBS_Confirm_SELLfalseRequire MBS SELL confirmation
MBS_ExitTrigger_BUYfalseEnable MBS BUY exit trigger
MBS_ExitTrigger_SELLfalseEnable MBS SELL exit trigger
MBS_ExitConfirm_BUYfalseRequire MBS BUY exit confirmation
MBS_ExitConfirm_SELLfalseRequire MBS SELL exit confirmation
MBS_Timeframe0Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for analysis
MBS_LookbackBars20Lookback period for structure analysis
MBS_MinBreakoutSize50Minimum breakout size in points
MBS_MomentumThreshold0.7Momentum strength threshold (0-1)
MBS_ConfirmationBars2Bars needed for confirmation
MBS_VolatilityFilter1.5Volatility filter multiplier
MBS_TrendStrengthMin0.6Minimum trend strength (0-1)
MBS_RequireVolumeSpiketrueRequire volume confirmation
MBS_VolumeMultiplier1.5Volume spike multiplier
MBS_ATRPeriod14ATR period for volatility
MBS_ATRMultiplier1.0ATR multiplier for breakout validation
MBS_EMAPeriod21EMA period for trend direction
MBS_MinPriceMovement0.0001Minimum price movement for signal
DC_EntrySignal_BUYfalseEnable Donchian Channel BUY entry signal
DC_EntrySignal_SELLfalseEnable Donchian Channel SELL entry signal
DC_Confirm_BUYfalseRequire Donchian Channel BUY confirmation
DC_Confirm_SELLfalseRequire Donchian Channel SELL confirmation
DC_ExitTrigger_BUYfalseEnable Donchian Channel BUY exit trigger
DC_ExitTrigger_SELLfalseEnable Donchian Channel SELL exit trigger
DC_ExitConfirm_BUYfalseRequire Donchian Channel BUY exit confirmation
DC_ExitConfirm_SELLfalseRequire Donchian Channel SELL exit confirmation
DC_Timeframe0Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for Donchian Channel (M1-D1)
DC_ChannelPeriod20Lookback period for channel (10,5,60)
DC_ConfirmationBars2Bars needed for confirmation (1,1,5 or 20)
DC_MinBreakoutPoints10Minimum breakout size in points (1,5,100) my
DC_ATRMultiplier1.0ATR multiplier for volatility filter (0.5,0.25,2.0) my (0.5,0.25,2)
DC_ATRPeriod14ATR period for volatility (5,1,30) my (5,1,50)
DC_RequireVolumeSpikefalseRequire volume spike confirmation
DC_VolumeMultiplier1.5Volume spike multiplier range: 1.0 … 3.0 step 0.5 (my 1,0.15,5)
DC_MinPullbackPoints5Minimum pullback before breakout (anti-fakeout) – range: 0 … 20 step 2 my : 0,1,50
DC_MinRangePoints20Minimum channel range to avoid chop – range: 10 … 100 step 10 , my 5-10,100
RSI_EntrySignal_BUYfalseEnable RSI BUY entry signal
RSI_EntrySignal_SELLfalseEnable RSI SELL entry signal
RSI_Confirm_BUYfalseRequire RSI BUY confirmation
RSI_Confirm_SELLfalseRequire RSI SELL confirmation
RSI_ExitTrigger_BUYfalseEnable RSI BUY exit trigger
RSI_ExitTrigger_SELLfalseEnable RSI SELL exit trigger
RSI_ExitConfirm_BUYfalseRequire RSI BUY exit confirmation
RSI_ExitConfirm_SELLfalseRequire RSI SELL exit confirmation
RSI_TF0Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for RSI
RSI_Period14RSI period
RSI_Price1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // Applied price for RSI
RSI_Overbought70Overbought level for RSI
RSI_Oversold30Oversold level for RSI
RSI_SignalShift0Shift for RSI signal line
RSI_Midline50RSI midline level
RSI_ExtremeBuffer5Buffer for extreme levels (anti-whipsaw)
RSI_MinRange5.0Minimum RSI range for valid signal
RSI_MinVolatility2.0Minimum volatility threshold
RSI_MomentumBars3Bars for momentum confirmation
RSI_DeadZoneSize5.0Dead zone around midline
HMA_EntrySignal_BUYfalseEnable HMA BUY entry signal
HMA_EntrySignal_SELLfalseEnable HMA SELL entry signal
HMA_Confirm_BUYfalseRequire HMA BUY confirmation
HMA_Confirm_SELLfalseRequire HMA SELL confirmation
HMA_ExitTrigger_BUYfalseEnable HMA BUY exit trigger
HMA_ExitTrigger_SELLfalseEnable HMA SELL exit trigger
HMA_ExitConfirm_BUYfalseRequire HMA BUY exit confirmation
HMA_ExitConfirm_SELLfalseRequire HMA SELL exit confirmation
HMA_Timeframe0Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for HMA analysis
HMA_Period21HMA period
HMA_ConfirmationBars2Bars needed for confirmation
HMA_MinSlopeAngle0.0001Minimum slope angle for trend detection
HMA_MinMomentumPoints5Minimum momentum in points
HMA_RequirePriceAbovetrueRequire price above HMA for buy
HMA_RequirePriceBelowtrueRequire price below HMA for sell
HMA_FilterATRMultiplier1.5ATR multiplier for noise filter
HMA_FilterATRPeriod14ATR period for volatility filter
HMA_TrendStrengthMin0.7Minimum trend strength (0-1)
HMA_SmoothingBars3Bars for HMA smoothing validation
HMA_MinPriceDistance2Minimum distance from HMA in points
Source Code (.mq5)Open Source
Pipsgrowth_com_EX16055.mq5
#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.

Tags:ex16055trendpipsgrowthfreemt5xauusd

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

Community

Sign in to contributeSign In

Educational purposes only. Do NOT use with real money. Test on demo accounts only.

File NamePipsgrowth_com_EX16055.mq5
File Size173.9 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyTrend Following
Risk LevelMedium Risk
Timeframes
M5H1
Currency Pairs
XAUUSD
Min. Deposit$100