AtlasFX TrendGuard documentation
AtlasFX TrendGuard
A rules-based forex breakout EA with trend confirmation, volatility-scaled stops and conservative default sizing. Read the rules, inspect the code and test the idea.
H1 · 0.25% default equity risk · MT5 desktop · Source + EX5

How AtlasFX TrendGuard selects a trade
AtlasFX TrendGuard is a transparent research implementation of an H1 trend-breakout hypothesis. Simplicity, inspectable rules and conservative sizing guide the design. No parameter optimisation or claim of a proven trading edge is included.
- Evaluate a signal once per new H1 bar. The signal candle is the most recently completed bar, index 1. The 20-bar Donchian range uses bars 2 through 21, excluding the signal candle and the still-forming candle.
- For a buy, the completed close must exceed the highest high of that range and its EMA 200. For a sell, it must fall below the lowest low and its EMA 200. ADX 14 on the completed bar must be at least 20. Equality at the range boundary is not a breakout.
- The trading window, spread limit, daily equity brake, symbol ownership checks, available margin and broker restrictions must all pass. Failed or skipped signals are not repeatedly retried within the same bar.
- Use a market order at the available ask for a buy or bid for a sell; the signal close is not an assumed fill price. The initial stop uses 2 ATR 14, widened if necessary for the broker's stop rules, then aligned to the instrument's tick size.
- The default target is 3 times the initial stop distance. The trailing rule activates after a move of 1 initial risk unit (1R) and uses a distance of 2 ATR. It only tightens an existing stop. A trailing exit can occur before the target.
There is no grid, martingale, averaging down, trade recovery sequence or automatic reversal. EURUSD H1 is a sensible first test case, not a validated recommendation or the result of a comparison across pairs.
Risk is an estimate, not a guarantee
The default risk budget is 0.25% of current account equity for each new position. Position sizing uses OrderCalcProfit in account currency and rounds volume down to the broker's permitted step. A minimum lot that exceeds the budget causes the trade to be skipped. Broker minimum stops can change both the stop distance and the resulting volume.
Example: equity of 10,000 account-currency units gives a nominal 25-unit risk budget. If the estimated loss at the stop is 200 units per lot, the unconstrained volume is 0.125 lot; at a 0.01 lot step it is at most 0.12 lot, before any other code limits or cost allowance. This arithmetic is illustrative and is not a pip-value assumption.
The daily brake latches after an observed 1.5% equity decline from its broker-server-day reference. It blocks new entries until the next server day; it does not liquidate positions or guarantee that losses stop at 1.5%. The reference is the first equity observation made by the running EA for that day, not a reconstructed midnight valuation. Deposits, withdrawals, other trades and offline periods affect its interpretation. Persistent local state helps preserve the brake through normal restarts.
One-position-per-symbol checks include other EAs and manual positions. This is not a portfolio allocation system: correlated currency pairs can multiply the same exposure. Use one instance per symbol and a separate aggregate risk budget. Local terminal state does not coordinate different computers or VPS instances.
Spread controls govern new entries. Existing positions can still require management outside the entry window or during wide spreads. Stops, trailing changes and risk limits remain subject to execution, gaps, disconnections and broker rules. Commission, swaps and realised slippage can make the final loss larger than the planned stop-loss estimate.
Inputs you can inspect and change
These defaults are engineering starting values, not optimised parameters. Hours use broker server time and are not automatically converted to London, New York or your local time. Check the broker's daylight-saving changes.
| Input | Default | Meaning |
|---|---|---|
EnableLiveTrading | false | False blocks ALL trade requests on real accounts, including trailing changes. Demo and tester operation is allowed. |
MagicNumber | 2026090501 | EA ownership identifier. Use a stable value; changing it changes the daily-state scope. |
SignalTimeframe | PERIOD_H1 | Timeframe for all signals and indicators; H1 by default. |
MaxSignalDelaySeconds | 90 | Skip a new-bar entry if it is observed more than 90 seconds after the bar begins. |
DonchianPeriod | 20 | Completed range bars preceding the signal candle. |
TrendEMAPeriod | 200 | EMA trend filter on the completed close. |
ADXPeriod | 14 | ADX trend-strength lookback. |
MinimumADX | 20.0 | Minimum completed-bar ADX strength. |
ATRPeriod | 14 | ATR volatility lookback. |
RiskPercent | 0.25 | Equity percentage used for nominal stop-loss sizing; excludes commission and swaps. |
StopATRMultiplier | 2.0 | Initial ATR-based stop distance, subject to broker minimums. |
TakeProfitR | 3.0 | Target as a multiple of initial stop distance; 0 disables the target. |
UseTrailingStop | true | Enable tightening of eligible owned-position stops. |
TrailStartR | 1.0 | Minimum favourable move in original risk units before trailing. |
TrailATRMultiplier | 2.0 | Trailing distance based on the latest completed ATR. |
TrailIntervalSeconds | 30 | Minimum interval between trailing-management evaluations. |
DailyEquityBrakePercent | 1.5 | Observed equity-decline threshold that latches the daily new-entry brake. |
MaxFreeMarginUsagePct | 80.0 | Maximum fraction of free margin accepted for the estimated new trade margin. |
MaximumSpreadPoints | 20.0 | Maximum entry spread in broker points, not pips. 20 points = 2 pips on usual 5-digit EURUSD / 3-digit JPY quotes. |
MaximumDeviationPoints | 10 | Requested execution deviation in points; execution mode can limit its effect. |
UseSessionFilter | true | Filter new entries by broker-server hour. |
SessionStartHour | 7 | Entry window opens at 07:00 server time. |
SessionEndHour | 20 | Entry window ends before 20:00; equal start/end means all day; overnight windows are supported. |
BlockLateFriday | true | Block new Friday entries at/after the cutoff; does not close existing positions. |
FridayCutoffHour | 16 | Friday new-entry cutoff at 16:00 server time. |
Attach only one instance per symbol in a single terminal. The EA skips the first current bar after attachment, then waits for a new bar. Real-account operation, including trailing modifications, is entirely disabled unless EnableLiveTrading is true. The daily brake is scoped by account, server and MagicNumber within the local terminal. Keep the magic number stable across charts that should share this brake. Another terminal or VPS is not coordinated. Foreign/manual intervention in a position can cause ownership checks to stop management. Missing original-risk state is recovered from available order history when possible; if safe recovery fails, trailing stands aside. No news filter is included.
Start in the Strategy Tester and on demo
- Download and extract the ZIP. In the Windows desktop version of MetaTrader 5, choose File → Open Data Folder and open
MQL5/Experts. CopyAtlasFX_TrendGuard.mq5andAtlasFX_TrendGuard.ex5into a folder there. - To rebuild, open the source in MetaEditor and press F7. The EA uses the standard MetaTrader trade library; it needs no DLL, paid indicator, WebRequest permission or external service.
- Refresh the Expert Advisors list in Navigator. First select the EA in View → Strategy Tester, choose the exact broker symbol including any suffix, and use H1. The signal timeframe is an EA input, independent of the display chart.
- Use a dedicated demo account for forward testing. In Expert properties → Inputs, use Load to select
Default_Demo.set, or keep the source defaults. Review symbol digits, tick size, minimum lot, volume step, spread units, server-time window and the daily-brake definition. Start with one chart and inspect the Experts and Journal tabs. - The live-account switch is disabled by default. Keep it disabled during this release's evaluation. Demo/tester trading still requires the relevant MetaTrader permissions. Attaching software to a chart is not evidence that its trading behaviour or profitability has been validated.
Existing server-side SL/TP orders normally remain after the terminal closes, but the EA cannot update its trailing stop while offline. Disabling Algo Trading prevents further EA trade requests; it does not close an existing position. Manage any open trade deliberately.
Make any performance claim reproducible
Release status: Compiled in MetaEditor with 0 errors and 0 warnings; source checks and an independent static code review completed. No historical performance backtest or demo-forward performance test is supplied. Profit factor, expected return, drawdown and live reliability have therefore not been established.
- Record MT5 build, EA version and file hash, broker, account type/currency, symbol specification, leverage, deposit, date range, inputs and modelling mode. Use Every tick based on real ticks where broker data supports it, and inspect missing data and history quality.
- Separate an earlier development period, a later validation period and a final untouched out-of-sample period. Select dates before inspecting the results. As an example only, use 2020–2023 / 2024 / 2025 if complete broker data is available; this release has not run those periods.
- Include variable spread, commission and swaps. Test execution delay and cost sensitivity. Tick data does not recreate every live rejection, liquidity event or slippage outcome. Document any assumptions the tester cannot model.
- Report trades, net expectancy after costs, equity drawdown, profit factor, exposure, worst trade, longest losing sequence and results by year and symbol. Never treat a small trade sample or the best historical parameter combination as evidence of robustness.
- Inspect modest changes in breakout length, EMA, ADX threshold and ATR distances without repeatedly selecting a new optimum. Evaluate neighbouring settings and later data, then forward-test on demo under the intended broker conditions.
- Exercise operational failures: insufficient history, high spread, volume below minimum, missing margin, market closed, rejected order, restart mid-bar, restart after a brake trigger, server-day rollover, competing symbol position and missing persistent state. Save journals and expected-versus-actual outcomes.
Stop evaluation if behaviour differs from the written rules. A clean compilation and a source review are engineering checks; they do not substitute for end-to-end testing or establish an investment edge.
Conditions that can defeat the idea
Market behaviour
Sideways prices can cause repeated false breakouts. EMA and ADX lag. An ATR stop reflects recent ranges and cannot anticipate a news gap. There is no economic-news filter or correlation-aware portfolio allocator. The trading window does not prevent overnight or weekend exposure from positions already open.
Operational behaviour
Terminal shutdown, state loss, broker rejections or manual interference can prevent protective updates. Missing or ambiguous ownership/state causes the EA to stand aside rather than assume it can safely act. Review journal messages and the full operational notes in the package.
This EA has not been shown to be the most profitable or best-performing alternative. It is a deliberately inspectable starting point for a disciplined evaluation. Leveraged forex/CFD trading can produce rapid losses.
Source, compiled EA and documentation
Version 1.00 research release. The ZIP contains the MQL5 source, compiled EX5, this documentation, default demo settings, validation notes, a full MIT software licence and SHA-256 checksums. The MIT licence covers the EA code and documentation; the editorial image is supplied separately.
ZIP checksum: see the release web page.
Implementation and testing documentation
- MetaQuotes: OrderCalcProfit — estimating a trade result in account currency.
- MetaQuotes: symbol properties — tick size, stops, freeze levels and permitted volumes.
- MetaTrader 5 Strategy Tester — test configuration and modelling modes.
References explain platform behaviour. They do not validate this strategy's profitability. Documentation prepared 5 September 2026.
← Browse all MT5 Expert Advisors
Educational software and information, not personal investment advice or a return guarantee. Test on demo, supervise the system and keep risk within an independently defined account-wide plan.