Loading…

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

SettingDefaultWhat it does
Channel period20Donchian channel lookback, in bars
Atr period14ATR period
Atr lookback10Bars back used as the ATR expansion baseline
Min expansion ratio1.15Current ATR must be at least this multiple of the baseline ATR
Stop atr multiple1.5Initial protective stop, in ATR multiples
Trail atr multiple2.0Trailing stop distance, in ATR multiples (0 disables trailing)
Use risk sizingfalseSize by percent risk instead of a fixed lot
Risk percent1.0Percent of equity risked per trade, when risk sizing is on
Fixed lots0.10Lot size when risk sizing is off, or as a fallback
Magic number20260603Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Breakout · ATR · Channels & Envelopes · Trailing Stop & Break-even · Risk & Lot Size · News Trading · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria