Gold H1H4 Trend Continuation EA
- Experts
-
Phan Van Khoa
⭐ PROFESSIONAL QUANT DEVELOPER & ALGORITHMIC TRADING SYSTEMS
Welcome to my official MQL5 developer page. I specialize in institutional-grade quantitative trading systems, high-precision Expert Advisors, and statistical breakout models for MetaTrader 5. - Version: 1.0
- Activations: 5
Gold (XAUUSD) trend-continuation Expert Advisor for MT5. It trades in the direction of the H4 trend after an H1 pullback and breakout, sends a hard stop loss with every order, sizes positions at 0.25% of equity by default and has a daily loss guard. One position at a time. No grid, no martingale, no averaging. How it works 1. H4 trend filter: buys are allowed only when the last closed H4 bar closed above EMA 50 and EMA 50 is above EMA 200. Sells are the mirror. No clear trend, no trade. 2. H1 pullback: one of the last two closed H1 bars must have touched the H1 EMA 20 (low below it for buys, high above it for sells). 3. H1 breakout: the last closed H1 bar must close beyond the high (buys) or low (sells) of the 15 H1 bars before it. 4. Volatility: H1 ATR(14) must be at or above its own 30-bar average. 5. Entries are checked once per new H1 bar. The EA reads H1 and H4 data itself; the backtests below were run on an M15 chart. 6. Spread filter: no new entry when the current spread is above "Max Spread Points" (default 400 points). 7. One position at a time per symbol and magic number. It never adds to a position. Exits - Hard stop loss: 2.5 x ATR(14) H1, sent with the order. It is never zero: the distance is at least the broker's stop or freeze level, twice the current spread, or 50 points, whichever is largest. - Take profit: 6 x ATR(14) H1, sent with the order. - Breakeven: once profit reaches 1.5 x ATR, the stop moves to 20 points beyond the entry price, on the profit side. - ATR trailing stop: 2 x ATR behind price, checked at most every 30 seconds. Breakeven and trailing are paused from 23:00 to 00:05 server time. Position size - Default 0.25% of equity per trade, calculated from the stop distance. - Rounded down to the lot step, then capped by "Maximum Lot Size" (default 5.0), the broker's volume limit and 90% of free margin. If the margin check fails, the trade is skipped. - Important: if the calculated lot is smaller than the broker's minimum lot (0.01), the EA rounds it up to the minimum lot. On Exness XAUUSDm 0.01 lot is 1 ounce. With Gold around $4,000 the 2.5 x ATR stop on 0.01 lot was about $49 at the median in 2026, so on a $10,000 account the real risk was about 0.46% per trade (up to 0.92%), not 0.25%. To stay near 0.25% at that volatility you need roughly $20,000 or more in equity. On smaller accounts, risk per trade is set by the minimum lot. Daily loss guard - At the first tick of each server day the EA records the day-start equity (or balance, if you choose). - If equity falls 4% (default) below that value, it closes its own positions (same symbol and magic number) and opens no new trades until the next server day. - The guard watches account equity, so losses from other EAs or manual trades on the same account count toward the 4%. It only closes this EA's positions. - The day-start value is kept in memory. If the EA is restarted during the day (terminal or VPS restart, re-attach, timeframe change), it is sampled again from the equity at that moment. - There is no overall (maximum) drawdown stop, no profit target and no consistency rule. If your prop firm has an overall loss limit, you have to watch it yourself. - In the backtests the worst losing day was about 0.6% of the account, so the 4% guard never triggered. News filter (optional, not tested) - The EA can skip new entries 90 minutes before and after high-impact events of the symbol's currencies, using the MT5 economic calendar. - The Strategy Tester has no calendar data, so this filter did nothing in any backtest and its live behaviour has not been verified. The results below do not include it. Do not rely on it to avoid news. Backtest results MT5 Strategy Tester, XAUUSDm (Exness, 3 digits), M15 chart, "Every tick based on real ticks", history quality 98-99%, deposit $10,000, leverage 1:100, default inputs, swaps included, no commission. - Full period 1 Jan 2021 to 1 Aug 2026: 237 trades, profit factor 1.39, net profit +$607.79 (+6.08%), maximum equity drawdown 2.15%, recovery factor 2.80, win rate 44.7%. - Out-of-sample 2024 to 1 Aug 2026: 112 trades, profit factor 1.70, +$596.40, drawdown 1.67%. - In-sample 2021-2023: 125 trades, profit factor 1.02, +$11.39. - 2024 alone: 49 trades, profit factor 0.98, -$6.76. - By year: 2021 -$85, 2022 +$134, 2023 -$28, 2024 -$7, 2025 +$354, 2026 (to 1 Aug) +$257. Three of six years were negative or flat. Almost all of the profit came from 2022 and from mid-2024 onwards. - That is about +1.1% a year at the default risk. This is a low-risk, low-return system, not a fast-growth one. - Largest single loss $58.94. Longest losing streak 9 trades. The screenshots show the balance curve, the year-by-year results and the risk per trade from the same tests. Recommended setup - Symbol: Gold, tested on Exness XAUUSDm. Other brokers' Gold symbols should work, but check the point size first (see below). - Chart: M15 to match the tests (entries are evaluated on H1 bars). - Inputs: defaults. Risk 0.25%, Daily loss cap 4.0%, Flatten on breach = true, Basis = equity, Max spread 400 points. - Account: a hedging account is recommended. Leave enough equity for the minimum-lot effect described above. - One unique magic number per chart. A VPS helps the trailing stop and the daily guard run continuously. Symbol and point size notes - Exness XAUUSDm quotes 3 digits (point = 0.001). The defaults were tested there: Max spread 400 points = $0.40, breakeven offset 20 points = $0.02, minimum stop distance 50 points = $0.05. - On a 2-digit Gold quote (point = 0.01) the same numbers are 10 times larger: 400 points = $4.00, so the spread filter would almost never block. Set "Max Spread Points" to about 40 on a 2-digit symbol for the same protection. - The stop loss, take profit, breakeven trigger and trailing are ATR-based, so they adapt to the symbol automatically. - Test on your own broker's symbol before going live: spread, swap and contract size change the results. How to test it yourself 1. Download the free demo and open the Strategy Tester (Ctrl+R). 2. Select your Gold symbol, M15, "Every tick based on real ticks", 2021 to today, deposit of the amount you would really trade. 3. Run with default inputs, then look at the Graph tab and the Journal for "PROP-FIRM GUARD" lines. 4. Compare the lot sizes in the Deals tab with your intended risk. On small deposits they stay at 0.01. Risk and limitations - Trend systems lose in ranging markets. In these tests 2021, 2023 and 2024 ended negative or flat. - Expect long periods with few trades: about 40 trades a year. - Gaps and fast markets can close a trade beyond its stop loss. - The daily guard is measured from the EA's own day-start sample, not from your broker's or prop firm's daily reference. - Backtests are simulations. Go from demo to a small live account first. Risk warning: trading Gold CFDs carries a high risk of loss. This EA is software, not financial advice. Past results, including backtests, do not guarantee future results.
