A transparent trend assistant with conservative default risk
TF Donchian ATR Assistant evaluates completed H4 candles, trades a 55-bar breakout only in the EMA 200 direction and sizes each position from its ATR stop. It is supplied as one individual download—not a bundle.
Includes .mq5 source, .ex5 binary, individual README and SHA-256 checksums.

How a trade is selected
- The EA runs once when a new H4 signal bar has completed; it does not use an unfinished candle as a signal.
- A long setup requires the completed close to break above the highest high of the preceding 55 completed bars and to be above EMA 200. A short setup mirrors those conditions.
- The spread, trade window, daily-loss lock and one-position-per-symbol rules must all pass.
- The initial stop distance is the greater of 2.2 ATR and the broker’s minimum stop distance. The default target is 2.5 times that initial distance.
- Volume is calculated against the estimated stop loss in account currency and rounded down to the symbol’s permitted volume step.
Risk controls built into the code
| Control | Default | Purpose |
|---|---|---|
| RiskPercent | 0.50% | Balance-based risk estimate; any input above 1.00% is rejected. |
| StopATR | 2.20 | Adapts the initial stop distance to recent volatility. |
| RewardRisk | 2.50 | Defines the initial target as a multiple of initial risk. |
| DailyEquityLossLimit | 2.00% | Stops new entries after the day reference has fallen by the threshold. |
| MaximumSpreadPips | 2.00 | Avoids new entries when the quoted spread is unusually wide. |
| Position guard | One per symbol | Stands aside if any EA or manual position already exists on the symbol. |
The EA contains no grid, martingale, recovery sizing or averaging down. These controls reduce specific risks; they cannot cap losses during gaps, slippage, disconnections or execution failures.
Evidence, stated precisely
Price breakouts belong to the broader trend/time-series momentum family. Moskowitz, Ooi and Pedersen documented time-series momentum across almost five dozen futures and forward contracts, including currencies. Their study supports examining transparent trend rules; it does not validate this exact Donchian/EMA/ATR configuration or future retail-FX results.
Known failure modes
Sideways markets can create repeated false breakouts. A 200 EMA is a lagging filter. ATR measures recent ranges but cannot predict gaps or news liquidity. Several currency pairs may carry the same USD or risk-on exposure, so a 0.50% setting on each chart is not a 0.50% portfolio risk.
Installation and validation
- Extract this EA’s ZIP. Copy the .ex5—or the .mq5 and .ex5—to
MQL5/Expertsin the MetaTrader 5 data folder. - Refresh Navigator, attach the EA to the intended chart and check broker server time, spread convention, volume step and stops level.
- Run symbol-specific tests with variable spread, commission and slippage. Separate development, later out-of-sample and demo-forward periods.
- Review maximum drawdown, consecutive losses, trade count and sensitivity to modest input changes. Do not select a setup only because it maximizes historical profit.
- Start disabled or on demo, verify journal messages and keep aggregate exposure within a written risk plan.
Auditable and reproducible
Both MQL5 source and the compiled MT5 file are supplied. Version 1.00 compiled with 0 errors and 0 warnings. ZIP SHA-256: 8774e9dafa8cb44a9bc014a09f03def1be26207f52f0b7aca8d53640ddb5ee56.
Position sizing uses MetaTrader’s account-currency profit estimate rather than assuming a fixed pip value. See the official OrderCalcProfit documentation.
Open an account with HFM
If HFM suits your jurisdiction and requirements, you can use our sponsored link. Compare regulation, costs and account terms independently before registering.
Affiliate disclosure: Trade-Forex.info may receive compensation if you register through the HFM link, at no additional charge to you. Leveraged trading is high risk. This software and page are educational information, not personal investment advice.
