ATR Channel Breakout EA
The channel itself is an SMA basis plus and minus an ATR multiple, recomputed every bar - MQL4 has no built-in ATR channel indicator, so it is built by hand from iMA and iATR. The distinguishing feature is not the channel shape, which is a close cousin of a Keltner Channel, but the entry gate: without it, a single sustained move outside the channel re-fires the same-direction breakout signal on every bar it stays there, effectively pyramiding into one continuous move under the appearance of many separate trades. Each direction only re-arms after price closes back inside the channel, so one sustained breakout produces exactly one entry, not a chain of them. Both the stop loss and the optional take profit are set in ATR multiples from the entry price rather than fixed pips or a moving trail, so the exits scale automatically with how volatile the symbol was at the moment of entry. Position sizing can run as a fixed lot or, with InpUseRiskSizing on, as a percentage of equity risked to that ATR-scaled stop distance, using MODE_TICKVALUE and MODE_TICKSIZE rather than a hardcoded contract size so it prices correctly on gold, indices and JPY crosses as well as plain FX pairs. Notes and limitations - The re-arm rule stops one move from being counted as many entries, but it also means a genuinely fresh breakout that never closes back inside the channel between waves will not be re-entered - by design, not oversight. - No trend filter beyond the channel itself; false breakouts in choppy markets are the documented weakness of this whole family of systems. - Signals are evaluated once per closed bar, not on every tick. - One position at a time, tracked by InpMagicNumber. It will not manage or interfere with trades opened manually or by another EA. - Requires AutoTrading enabled and IsTradeAllowed() true; if trading is disabled the EA logs it and skips the entry (the arm/disarm state still updates, so a missed entry cannot be replayed once trading resumes).
Expert advisor · MT5 · v1.0 · Free
About ATR Channel Breakout EA
ATR Channel Breakout EA is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average and ATR. It increases the lot size after a losing trade (martingale), can size trades from your balance and risk percent and trades breakouts. It has 12 settings, such as Ma period, Atr period and Atr multiplier. MQL source code included.
Files in the download: AtrChannelEa.ex5, AtrChannelEa.mq5, AtrChannelEa.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Ma period | 20 | Channel basis SMA period |
| Atr period | 14 | ATR period used for the channel width |
| Atr multiplier | 1.5 | Channel distance from basis, in ATR multiples |
| Stop atr multiple | 2.0 | Stop loss distance from entry, in ATR multiples |
| Take profit atr mult | 3.0 | Take profit distance from entry, in ATR multiples (0 = none) |
| Use risk sizing | false | Size by percent risk instead of a fixed lot |
| Risk percent | 1.0 | Percent of equity risked per trade, when risk sizing is on |
| Fixed lots | 0.10 | Lot size when risk sizing is off, or as a fallback |
| Magic number | 20260704 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Breakout · Moving Average · ATR · Channels & Envelopes · Buy/Sell Arrows · Martingale · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code