PatternGuard VWAP Trader User Guide MetaTrader 5 Expert Advisor, version 1.12 The EA can work on all trading symbols available from your broker. The recommended starting setup for configuration and testing is XAUUSD, H1. Before using the EA on a real account, always run optimization in the MetaTrader 5 Strategy Tester, validate the settings on historical data, and test the EA on a demo account. 1. Purpose of the EA PatternGuard VWAP Trader is a MetaTrader 5 Expert Advisor designed to look for trade entries after price leaves a dynamic NO TRADE uncertainty zone. The NO TRADE zone is based on VWAP and volatility bands. The EA does not open trades inside this zone. It waits until price exits the zone, then checks for candlestick pattern confirmation and trend direction. The main purpose of the EA is to avoid weak, noisy, or compressed market conditions and focus on situations where price leaves the uncertainty area and confirms directional movement. 2. How the strategy works PatternGuard VWAP Trader uses several filters: 1. NO TRADE zone. While price remains inside the VWAP zone, the EA does not open a new trade. 2. Exit from the zone. A signal is considered only after price exits the NO TRADE zone. 3. Candlestick pattern. The EA checks for a confirming Price Action pattern. 4. Trend filter. Trade direction must match the position of price relative to the moving average. 5. Position control. The EA manages one active position on the current symbol and Magic Number. After entry, the EA manages the position using Stop Loss, Take Profit, mandatory protective Stop Loss, and trailing stop logic. In version 1.12, an internal virtual trailing stop was added. If the broker or tester rejects broker-side SL modification, the EA can still close the position using its internal virtual level. 3. Installation in MetaTrader 5 1. Open MetaTrader 5. 2. Go to File -> Open Data Folder. 3. Open MQL5 -> Experts. 4. Copy the EA file into this folder. 5. If you have a .mq5 file, open it in MetaEditor and compile it. 6. If you have a .ex5 file, no compilation is required. 7. Restart MetaTrader 5 or click Refresh in the Navigator window. 8. Make sure the EA appears under Expert Advisors. If the EA is installed through MQL5 Market, use the standard installation procedure inside the terminal. After installation, the EA will be available in Navigator -> Market or Expert Advisors. 4. First launch on a chart 1. Open the chart of the required instrument. 2. For initial testing, XAUUSD on H1 is recommended. 3. Drag PatternGuard VWAP Trader from Navigator onto the chart. 4. In the Common tab, allow Algo Trading and trading operations. 5. In the Inputs tab, configure risk, SL/TP, trailing stop, and visualization settings. 6. Make sure the Algo Trading button is enabled in the terminal toolbar. 7. If InpShowVisuals = true, the EA visual elements will appear on the chart. 5. Recommended workflow Do not run the EA on a real account without preparation. Recommended workflow: 1. Select a symbol and timeframe. Recommended starting setup: XAUUSD, H1. 2. Run a single test in the Strategy Tester. Make sure trades open and close correctly. 3. Disable visualization to speed up backtesting: InpShowVisuals = false 4. Optimize the parameters for the selected symbol, spread, commission, and account type. 5. Validate the optimized settings on a separate historical period that was not used during optimization. 6. Run the EA on a demo account. 7. Move to a real account only after successful testing and with limited risk. 6. Main input parameters Risk Management InpRiskPercent Risk per trade as a percentage of account equity. Used to calculate position size. InpUseFixedTPSL If true, fixed TP and SL values in percent are used. InpFixedTP Fixed Take Profit as a percentage of the entry price. InpFixedSL Fixed standard Stop Loss as a percentage of the entry price. Also used for risk calculation. InpUseMandatorySL Enables mandatory protective Stop Loss. InpMandatorySLPct Distance of the mandatory Stop Loss as a percentage of the entry price. Exit Management InpUseTrailing Enables or disables trailing stop. InpTrailingMode Selects the trailing mode: percentage-based or pip-based. InpTrailPct Percentage trailing distance. Used in TRAIL_MODE_PERCENT. InpTrailOffsetPct Activates percentage trailing after the specified profit movement. A value of 0 means no offset. InpStartTrailingAfterProfitPips Minimum profit in pips after which pip-based trailing starts. InpFirstSLFromEntryPips First SL move from the entry price in pips after trailing activation. InpTrailingDistancePips Trailing stop distance from current price in pips. InpTrailingStepPips Minimum trailing stop modification step in pips. InpDisableTPSLWhenTrailing If true, standard TP/SL is disabled when trailing is active, while the position is managed by trailing and protective SL. NO TRADE InpUseNoTrade Enables the NO TRADE zone filter. InpNTSource Price source for VWAP zone calculation: HLC3, Close, HL2, or OHLC4. InpNTBandLen Standard deviation period for the zone boundaries. InpNTBandMult Multiplier for the upper and lower NO TRADE zone boundaries. Trend Filter InpMAType Moving average type: EMA or SMA. InpTrendMAPeriod Moving average period used to determine trend direction. Pattern Filters InpShowEngulfing Enables Engulfing pattern. InpShowHarami Enables Harami pattern. InpShowHammer Enables Hammer, Hanging Man, and related candle shapes. InpShowStar Enables Morning Star and Evening Star. InpShowPiercing Enables Piercing Line and Dark Cloud Cover. InpShowREB Enables Range Expansion Bar. InpShowSweep Enables Liquidity Sweep. InpShowBodyDom Enables Body Dominance candles. Execution InpMagicNumber Unique identifier for EA trades. Use different Magic Numbers for different charts or settings. InpDeviationPoints Allowed execution price deviation in points. Visualization InpShowVisuals Shows chart visualization. Set to false to speed up backtesting. InpVisualBars Number of bars used for drawing. InpDrawNoTradeFill Draws the NO TRADE zone fill. InpDrawExitStripes Draws vertical breakout zones after leaving NO TRADE. InpDrawNonTradeSignalArrows Draws regular Long/Short signal arrows that are not necessarily real trades. InpDrawSignalText Draws Long/Short text labels. InpDrawPanel Enables the chart information panel. InpDrawTradeHistory Draws real trade opening and closing markers from account history. InpDrawCalculatedTrades Draws calculated historical signal trades. InpDrawTradeLevels Draws historical Entry, TP, and SL lines. InpDrawLevelLabels Draws labels for Entry, TP, and SL lines. 7. Trailing stop configuration The EA supports two trailing modes: 1. TRAIL_MODE_PERCENT Percentage-based trailing. Suitable for instruments with different prices and volatility when it is easier to define distance in percent. Main parameters: - InpTrailPct - InpTrailOffsetPct 2. TRAIL_MODE_PIPS Pip-based trailing. Suitable for precise configuration and optimization in the Strategy Tester. Main parameters: - InpStartTrailingAfterProfitPips - InpFirstSLFromEntryPips - InpTrailingDistancePips - InpTrailingStepPips Main trailing switch: InpUseTrailing In version 1.12, trailing works as an internal virtual SL plus an attempt to place or modify the broker-side SL. This helps preserve trade management logic when the broker or tester rejects modification because of price proximity, stop level, or freeze level restrictions. 8. Backtesting and optimization Before using the EA on a real account, backtesting and optimization are mandatory. Testing workflow: 1. In Strategy Tester, select Expert Advisor: PatternGuard VWAP Trader. 2. Choose the symbol and timeframe. 3. For initial use, XAUUSD on H1 is recommended. 4. Disable visualization for speed: InpShowVisuals = false 5. Run a single test without optimization. 6. Confirm that trades open and close correctly. 7. Optimize parameters by blocks: - risk and SL/TP; - NO TRADE zone; - MA and pattern filters; - trailing stop. 8. Do not select settings only by maximum profit. Check drawdown, stability, number of trades, profit factor, and behavior across different market phases. 9. Run a forward check or test the settings on a separate historical period. Recommended process: optimization -> historical validation -> demo account -> real account only after successful validation. 9. Demo testing before live trading Demo testing is required to check EA behavior in a live quote stream. Historical testing cannot show all execution details, delays, spread expansion, or broker server behavior. Check on a demo account: - the same settings that passed optimization are used; - position size matches the selected risk; - trades open correctly; - positions are managed and closed correctly; - the selected trailing mode works as expected; - visualization matches the trade logic; - there are no unexpected trades or unclear behavior. Do not move to a real account if the demo test shows errors or the result does not match expectations. 10. Chart visualization Visualization helps you see the EA logic directly on the chart. When InpShowVisuals is enabled, the EA can display: - VWAP; - NO TRADE zone boundaries; - trend MA; - Long and Short signals; - trade openings; - trade closings; - Entry lines; - Take Profit lines; - Stop Loss lines; - information panel. For faster testing, use: InpShowVisuals = false To display the EA visual elements on the chart, set: InpShowVisuals = true When the EA is removed from the chart, its own visualization objects are deleted automatically. Cleanup applies to objects created by the EA with its internal prefix and should not remove objects from other indicators or manual drawings without that prefix. 11. Practical recommendations - Use separate optimization for each symbol. - Do not use excessive risk per trade. - Start with conservative risk values. - For XAUUSD, consider higher volatility, wider spreads, and sharp price movements. - Do not run multiple EA copies on the same symbol with the same Magic Number. - After updating the EA version, run a new test and demo validation. - Save working parameter sets as .set files. 12. Troubleshooting No trades are opened Check Algo Trading, trading permissions, Magic Number, spread, NO TRADE filter, trend filter, and enabled pattern groups. Too few trades Reduce filter strictness: NO TRADE zone width, MA period, or number of enabled patterns. Validate every change in the tester. Trailing does not affect results Make sure you use version 1.12 or newer, InpUseTrailing = true, and the correct InpTrailingMode is selected. For pip mode, adjust the pips-based parameters. The journal shows SL modification errors These errors may be caused by broker stop level or freeze level restrictions. Version 1.12 uses virtual trailing, so management can continue even if broker-side SL modification fails. Backtest is slow Disable visualization: InpShowVisuals = false. Reduce InpVisualBars if visualization is required. Extra arrows appear on the chart Disable InpDrawNonTradeSignalArrows. This hides signal arrows that are not actual trades. Results differ between brokers This is normal. Quotes, spreads, commissions, stop level, freeze level, and execution conditions differ. Each broker requires separate validation. 13. Risk notice Trading financial markets involves risk. The EA does not guarantee profit and cannot eliminate losses. Historical results and optimized settings do not guarantee future performance. Before using a real account, always perform optimization, backtesting, and demo validation. Use only a level of risk that matches your trading plan and financial situation.