Expanding Volatility Breakout Filter
A channel breakout - price closing beyond the highest high or lowest low of the recent lookback window - is the entry trigger, but taken on its own it fires constantly in choppy markets where the range keeps re-testing its own edges without ever really moving. The classic refinement is to require the volatility regime itself to be expanding at the same time, on the reasoning that a breakout backed by genuinely widening ranges has real participation behind it, while one occurring during flat or shrinking ATR is more likely to be a range edge giving way briefly before snapping back. This EA measures expansion directly: the current ATR is compared against ATR read a fixed number of bars earlier, and the breakout is only taken if the current reading is at least a configurable multiple of that baseline. A breakout with ATR flat or falling is logged and skipped rather than traded. Because the signal exists specifically to catch a genuine volatility expansion, both the initial stop and the trailing stop are sized in ATR multiples rather than fixed pips, so they scale with the same expansion that triggered the entry instead of being calibrated to some other, unrelated distance. Notes and limitations - This project reimplements the catalogue's standard helper functions (retryable-error classification, pip/lot normalisation, position lookup by magic number) locally rather than including another project's file, per house style - each submission is self-contained. - No fixed take profit - the position is managed by the ATR trailing stop only, so it can give back a meaningful share of an open profit before the trail catches up in a fast reversal. - The expansion filter compares two single ATR readings; it does not test the statistical significance of the difference, so a ratio just above the threshold on a noisy ATR series is a marginal signal, not a strong one. - Signals are evaluated once per closed bar for entries; the trailing stop itself updates on every tick. - One position at a time, tracked by InpMagicNumber. - Requires AutoTrading enabled (IsTradeAllowed()); if trading is disabled the EA logs it and skips the entry.
Expert advisor · MT4 · v1.0 · Free
About Expanding Volatility Breakout Filter
Expanding Volatility Breakout Filter is an expert advisor (trading robot) for MetaTrader 4 based on ATR. It moves the stop loss behind price (trailing stop / break-even), can size trades from your balance and risk percent and has a news filter. It has 13 settings, such as Channel period, Atr period and Atr lookback. MQL source code included.
It also trades breakouts.
Files in the download: ExpandingVolBreakoutFilter.ex4, ExpandingVolBreakoutFilter.mq4, ExpandingVolBreakoutFilter.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 |
|---|---|---|
| Channel period | 20 | Donchian channel lookback, in bars |
| Atr period | 14 | ATR period |
| Atr lookback | 10 | Bars back used as the ATR expansion baseline |
| Min expansion ratio | 1.15 | Current ATR must be at least this multiple of the baseline ATR |
| Stop atr multiple | 1.5 | Initial protective stop, in ATR multiples |
| Trail atr multiple | 2.0 | Trailing stop distance, in ATR multiples (0 disables trailing) |
| 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 | 20260603 | 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 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 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 · ATR · Channels & Envelopes · Trailing Stop & Break-even · Risk & Lot Size · News Trading · MT4 Expert Advisor · MQL4 Source Code