Guardrail Breakout
- Experts
- Versione: 1.1
- Attivazioni: 5
Guardrail Breakout
Let the move prove itself.
Guardrail Breakout is a MetaTrader 5 Expert Advisor designed to filter false breakouts and control exposure. It assesses the setup before entry, observes price behaviour after the trigger, and sizes the position from its actual initial stop distance.
A price touching a level is only the beginning. Trend, momentum, volatility, trading costs and post-trigger behaviour help determine whether a setup becomes a trade.
How it works
- Find a structure. Four models look for standing support or resistance levels, volatility-box breaks, opening-range breaks and squeeze releases.
- Assess the conditions. The EA evaluates completed signal candles, directional indicators, volatility and spread, then scores eligible setups.
- Watch the breakout. A triggered setup is observed for up to 15 seconds by default. Directional progress, persistence, path efficiency and adverse movement determine whether it qualifies.
- Control the position. The EA calculates volume from the actual stop, submits a broker-side stop and manages the trade with profit-protection, trailing and time-based exit rules.
Controls built into the strategy
- Stop-based sizing: the default target risk is 0.50% of current equity before costs and execution differences. Volume is rounded down; a trade is skipped if the broker's minimum lot exceeds the budget.
- One position per symbol: the default setup also limits this instance to one concurrent position and one virtual setup.
- Adaptive initial stops: volatility and recent completed one-minute structure determine stop placement. An excessively wide required stop leads to a skipped setup.
- Spread controls: entries are checked against volatility, the confirmation reference distance and a recent spread baseline.
- Equity thresholds: default daily and overall thresholds are 2% and 5% of reference capital. A breach locks new entries and, with emergency flattening enabled, requests closure of this EA's positions.
- Defined pacing: session hours, a daily entry limit, a loss-streak cooldown and one reduced-risk second chance limit repeated entry attempts.
- Broker checks: new orders are screened for volume, available margin and stop requirements; profit-stop updates are checked against stop and freeze levels.
These controls do not make trading loss-free. Gaps, slippage, costs, disconnections and execution failures can cause losses beyond configured thresholds.
Documented setup
Use XAUUSD with an M15 signal timeframe. Leave InpSymbol1 blank to use the broker's chart symbol, including any suffix. The signal timeframe is independent of the displayed chart timeframe. The initial test evidence uses hedging accounts, USD 10,000 and 1:100 leverage; those are test conditions, not a minimum-deposit or return promise.
Default entry hours are 15:00 to 23:00 in broker-server time, with no new entries from 19:00 on Friday. The opening range starts at 16:30 and lasts 30 minutes. Check these times against your broker before use.
Start with one instance on an isolated demo account. Keep MetaTrader running and connected for software-managed exits. An accepted broker-side stop remains subject to broker execution. Avoid sharing the same symbol with another strategy on a netting account.
Testing and demonstration
Use the Market's built-in Strategy Tester demonstration with your broker's history, spreads and costs. The gallery identifies historical tests and their real-tick coverage. Historical results are not a live track record and do not predict future returns.
Understanding the inputs
Defaults are listed below. ATR is the volatility measure used by the strategy. R in confirmation, targets and trailing settings means the original signal reference distance, normally at least 0.35 ATR; it is separate from the wider adaptive stop used to calculate position size. The equity thresholds are account-equity triggers, while forced closures affect positions carrying this EA's identifier.
Account-control settings use a recorded initial-capital reference. Changing accounts, moving terminals, cash transfers or running several strategies requires checking that reference and the daily control period. Diagnostic CSV files are created locally by the EA; no external data file or DLL is required. Use broker reports for complete performance accounting.
Main settings
- InpMagic (26110502): Identifier used to recognise this EA's orders and positions.
- InpRiskPct (0.50): Target percentage of current equity risked at the actual initial stop, before costs and slippage.
- InpMaxPortfolioRiskPct (0.50): Entry allowance based on this instance's positions and setup slots multiplied by the configured risk percentage.
- InpSRScoreMin (40.0): Minimum score for a support or resistance breakout setup.
- InpVolScoreMin (40.0): Minimum score for a volatility breakout setup.
- InpORBScoreMin (40.0): Minimum score for an opening-range breakout setup.
- InpSQZScoreMin (40.0): Minimum score for a squeeze-release setup.
- InpEnableHUD (false): Show the on-chart status panel and indicative trade statistics.
- InpUseSessionFilter (true): Apply the configured hourly entry window; weekend and Friday cut-offs still apply when off.
- InpMaxConcurrentPositions (1): Maximum positions managed by this instance; the strategy also allows only one position per symbol.
- InpMaxPendingSetups (1): Maximum pending or virtual setup slots.
- InpMaxNewOrdersPerScan (1): Maximum new setups accepted during a scan.
Opportunity flow
- InpUseOpportunityFlow (true): Enable idle rescans and replacement of eligible untriggered setups.
- InpIdleRescanSeconds (60): Minimum seconds between idle rescans using the last closed signal candle.
- InpRotateMinAgeSeconds (300): Minimum age in seconds before an untouched setup can be replaced.
- InpRotateNearTriggerATR (0.20): Keep the current setup when its trigger is this close, measured in ATR units.
- InpRotateMaxDistanceATR (0.75): Maximum distance to the proposed replacement trigger, in ATR units.
- InpRotateMinCloserATR (0.25): Minimum improvement in trigger distance required for a replacement.
- InpRotateScoreGain (2.0): Minimum score improvement required for a replacement setup.
- InpExtraEntryScoreMargin (5.0): Additional score required for extra or replacement entries.
- InpBaseTradesPerDay (6): Entry count after which the additional quality requirement applies.
Setup revalidation
- InpUseTriggerRevalidation (true): Recheck an aged support or resistance setup near its trigger.
- InpRevalNearTriggerATR (0.20): Distance from the trigger within which revalidation can occur.
- InpRevalStaleSeconds (900): Minimum setup age in seconds before revalidation.
- InpRevalSRDropPoints (18.0): Score deterioration required for the stale-setup rejection rule.
- InpRevalRequireSecondFlag (true): Require an additional price-action or score warning before rejecting the aged setup.
- InpSQZExtraConfirmATR (0.00): Additional squeeze-entry confirmation distance in ATR units; zero retains the base trigger.
- InpRevalDebug (false): Print additional setup-revalidation messages.
Adaptive loss stop
- InpUseAdaptiveLossStop (true): Build the initial stop from volatility, breakout structure and recent completed M1 candles.
- InpLossMinATR (1.10): Minimum actual stop distance in units of the volatility basis.
- InpLossSlowATRFloor (0.75): Fraction of slow ATR used as a floor for the volatility basis.
- InpLossMaxATR (2.50): Maximum permitted stop distance; setups requiring a wider stop are skipped.
- InpLossStructureM1Bars (5): Number of completed M1 candles used to assess nearby structure.
- InpLossStructureBufferATR (0.15): Additional structural stop buffer in ATR units.
- InpLossSpreadBufferMultiple (2.00): Minimum structural buffer as a multiple of the current spread.
- InpLossUseConfirmedExit (true): Enable the early loss exit based on completed M1 closes.
- InpLossGraceSeconds (120): Seconds after entry before the confirmed-loss exit can act; the broker stop remains active.
- InpLossConfirmM1Closes (2): Consecutive completed post-entry M1 closes required beyond the loss boundary.
- InpLossConfirmFraction (0.65): Loss boundary as a fraction of the original actual stop distance.
Legacy acceptance exit
- InpUseBreakoutAcceptance (true): Enable the legacy early-failure exit when adaptive loss stops are switched off.
- InpAcceptGraceSeconds (10): Initial grace period in seconds for the legacy acceptance exit.
- InpAcceptWindowSeconds (90): Duration in seconds of the legacy acceptance assessment.
- InpAcceptProofR (0.28): Favourable excursion needed to prove legacy acceptance, in reference R units.
- InpAcceptFailR (0.22): Adverse movement that can trigger a legacy failure exit, in reference R units.
- InpAcceptDebug (false): Print additional legacy-acceptance messages.
Diagnostics
- InpFlightRecorder (true): Write detailed execution and management events to a generated local CSV file.
- InpFlightVerboseWindow (true): Record detailed management evaluations during the initial acceptance window.
- InpFlightPrintCritical (true): Print selected entry-block and exit events in the Experts log.
Entry spread controls
- InpEntrySpreadGuard (true): Enable the final spread checks immediately before a market entry.
- InpEntryMaxSpreadRiskR (0.15): Maximum spread as a fraction of the entry-confirmation reference distance.
- InpEntrySpreadSpikeGuard (true): Check the current spread against the preceding spread-sample median.
- InpEntrySpreadSpikeMultiple (1.75): Maximum multiple of the preceding median spread.
- InpEntrySpreadWarmupSamples (8): Distinct fresh-quote seconds required before the spread baseline is ready.
- InpEntryBlockDuringWarmup (true): Block entries while the spread baseline is warming up.
- InpEntrySpreadResetGapSec (120): Quote inactivity in seconds that resets the spread baseline.
Post-trigger confirmation
- InpBehaveMaxSeconds (15): Maximum observation time after price touches a setup trigger.
- InpBehaveFastMinSeconds (2): Earliest time in seconds at which fast confirmation can enter.
- InpBehaveNormalMinSeconds (4): Earliest time in seconds for normal confirmation.
- InpBehaveFastFavR (0.10): Minimum favourable excursion for fast confirmation.
- InpBehaveFastMaxAdvR (0.025): Maximum adverse excursion permitted for fast confirmation.
- InpBehaveFastMinDirR (0.12): Minimum current directional progress for fast confirmation.
- InpBehaveFastMinEfficiency (0.45): Minimum directional path efficiency for fast confirmation.
- InpBehaveAcceptFavR (0.08): Minimum favourable excursion for normal confirmation.
- InpBehaveMaxAdvR (0.08): Maximum adverse excursion for normal confirmation.
- InpBehaveMinPersistence (0.70): Minimum fraction of observed fresh quotes remaining beyond the trigger.
- InpBehaveMinEfficiency (0.22): Minimum directional path efficiency for normal confirmation.
- InpBehaveRejectR (0.12): Immediate adverse-excursion threshold for rejecting an unfilled setup.
- InpBehaveExpireMinFavR (0.04): Minimum favourable progress required by the timeout acceptance rule.
- InpUseSecondChanceRetry (true): Allow one eligible reduced-risk retry after a rejected setup resets.
- InpRetryResetR (0.10): Required reset distance before the second-chance sequence.
- InpRetryMaxMinutes (15): Maximum lifetime in minutes of a second-chance opportunity.
- InpRetryRiskFraction (0.40): Fraction of normal risk used by a retry; 0.40 means 40% of the normal risk budget.
Account equity controls
- InpPropMode (true): Enable account-equity thresholds, daily entry limits and loss-streak cooldowns.
- InpPropInitialCapital (0.0): Reference capital for the equity thresholds; zero records the starting balance automatically.
- InpPropSoftDailyLossPct (2.0): Daily equity-loss threshold as a percentage of reference capital, below the reconstructed day-start balance.
- InpPropSoftOverallLossPct (5.0): Overall equity-loss threshold below the recorded reference capital.
- InpPropResetHourServer (1): Broker-server hour at which the daily control period resets.
- InpPropMaxTradesPerDay (8): Maximum matching entry deals during the control day.
- InpPropMaxConsecutiveLosses (3): Consecutive losing exit deals that activate the cooldown rule.
- InpPropCooldownMinutes (180): Cooldown duration in minutes after the loss-streak trigger.
- InpPropEmergencyFlatten (true): Request closure of this EA's positions when a daily or overall equity lock is active.
- InpPropRiskBufferMoney (0.0): Additional account-currency buffer above the internal equity floors.
Symbol and signal filters
- InpSymbol1 (blank): Trading symbol; blank uses the attached chart symbol, including the broker's suffix.
- InpSignalTF (PERIOD_M15): Timeframe used to build signals, independently of the displayed chart timeframe.
- InpConfluenceATR (0.35): Distance within which model levels can receive a confluence score bonus.
- InpFastEMA (20): Fast exponential moving-average period.
- InpSlowEMA (50): Slow exponential moving-average period.
- InpADXPeriod (14): Period for the directional-strength indicator.
- InpMinADX (18.0): Minimum directional-strength threshold.
- InpRSIPeriod (14): Period for the momentum indicator.
- InpLongRSIMin (51.5): Minimum RSI reading used for long-side momentum.
- InpShortRSIMax (48.5): Maximum RSI reading used for short-side momentum.
- InpATRPeriod (14): Period for the main volatility measure.
- InpATRSlowPeriod (100): Period for the slow volatility reference.
- InpMinATRRatio (0.75): Minimum ratio of current ATR to slow ATR for setup filtering.
- InpMaxATRRatio (1.80): Maximum ratio of current ATR to slow ATR for setup filtering.
- InpMinBodyFrac (0.45): Minimum directional candle-body fraction used by the relevant price-action filters.
- InpCloseEdgeFrac (0.30): Maximum distance from the directional candle edge, as a fraction of candle range.
- InpEntryBufferATR (0.03): Distance beyond a model level used to set its trigger, in ATR units.
Targets and profit protection
- InpHybridBaseStopPrice (0.00): Absolute price-distance floor for the reference unit; zero uses the ATR floor alone.
- InpHybridMinStopATR (0.35): ATR multiple used for the entry and profit-management reference distance.
- InpHybridTargetR (12.0): Distant target measured in reference R units, separate from the adaptive stop-risk distance.
- InpHybridBETriggerR (0.18): Favourable progress at which the initial protective stop move can activate.
- InpHybridBELockR (0.05): Requested profit-lock distance from entry for the initial protective move.
- InpHybridTrailStartR (0.35): Favourable progress at which trailing can begin.
- InpHybridEarlyTrailR (0.10): Trailing distance during the early trade period.
- InpHybridMidTrailR (0.08): Trailing distance after the early period.
- InpHybridRunnerTrailR (0.06): Trailing distance once the runner threshold is reached.
- InpHybridRunnerAtR (1.50): Favourable progress required for the runner trailing stage.
- InpHybridEarlySeconds (90): Duration in seconds of the early trailing period.
- InpHybridMinTrailLockR (0.25): Requested minimum profit-lock distance once trailing starts, subject to broker stop constraints.
- InpHybridTrailDebug (false): Print additional trailing-stop messages.
- InpMaxHoldMinutes (180): Maximum holding time in minutes before a close request.
Session and direction
- InpMaxSpreadATR (0.08): Maximum spread relative to ATR for setup and entry checks.
- InpSessionStartHour (15): Start of the entry window in broker-server time.
- InpSessionEndHour (23): End of the entry window, exclusive, in broker-server time.
- InpAllowLong (true): Allow long setups.
- InpAllowShort (true): Allow short setups.
Model selection
- InpEnableSR (true): Enable standing support and resistance breakouts.
- InpEnableVolatility (true): Enable volatility-box breakouts.
- InpEnableORB (true): Enable opening-range breakouts.
- InpEnableSqueezeRelease (true): Enable compression and squeeze-release breakouts.
Support, resistance and volatility setup timing
- InpSRPendingMaxMinutes (1440): Maximum lifetime in minutes of a support or resistance setup.
- InpVolLookback (8): Completed bars used to define the volatility box.
- InpVolMaxBoxATR (2.50): Maximum volatility-box width in ATR units.
- InpVolATRExpansion (1.03): Minimum ATR expansion ratio for the volatility model.
- InpVolSignalMinATR (0.70): Minimum signal-candle range in ATR units for the volatility model.
- InpVolEdgeFrac (0.35): Directional close-location threshold for the volatility model.
- InpVolPendingMaxMinutes (720): Maximum lifetime in minutes of a volatility setup.
Opening range
- InpORBStartHour (16): Opening-range start hour in broker-server time.
- InpORBStartMinute (30): Opening-range start minute.
- InpORBDurationMinutes (30): Length of the opening-range measurement window in minutes.
- InpORBOneSetupPerDay (true): Restrict the opening-range model to one setup per day.
- InpORBPendingMaxMinutes (600): Maximum lifetime in minutes of an opening-range setup.
Squeeze release
- InpSqzShortWindow (6): Number of bars in the recent compression window.
- InpSqzRefWindow (20): Number of bars in the preceding reference regime.
- InpSqzCompressionRatio (0.72): Maximum compressed average range relative to the reference range.
- InpSqzExpansionRatio (1.35): Minimum release-candle range relative to the compressed average range.
- InpSqzPendingMaxMinutes (180): Maximum lifetime in minutes of a squeeze-release setup.
Support
Use the product comments or MQL5 messaging for setup support. Include the product version, symbol, signal timeframe, broker-server time, relevant inputs and the Experts or Journal message when reporting an issue.
