Loading…

Band Walk Filtered Reversion

The base signal is the standard, well-known Bollinger reversion entry: a close outside a band followed by a close back inside it, confirming the reversion has actually started rather than merely that price reached the edge. Traded on its own, that signal has one well-known failure mode - in a strong trend the price rides the outer band for many bars in a row ("band walking"), and any single close back inside it is usually just a pause before the walk resumes, not a genuine reversion. This EA adds a direct, literal filter for that condition: before taking the reversion signal, it counts how many of the closes in a recent lookback window were already sitting beyond the same band edge the signal fired on. If that touch count meets or exceeds a threshold, the regime is classified as a band walk and the trade is skipped outright, logged plainly rather than silently dropped. This is not an ADX or slope-based trend filter standing in for the concept - it counts the actual band touches the walk would leave behind. The take profit on trades that do go through is the basis (middle band) reading captured once at entry, sent as a hard broker-side order rather than recalculated bar by bar, so it survives a terminal disconnect. A pip-distance stop protects against the reversion failing outright. 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. - The band walk filter reduces trade frequency by design; in a genuinely ranging market it will also occasionally skip a valid reversion that happened to follow a couple of earlier touches. - The basis target is fixed at entry, not trailed, so a basis that has moved substantially by the time price arrives will not be chased. - 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 carrying a different magic number or opened manually, but on a netting account a new order from this EA can still merge into any existing position on the symbol - see the differences section above. Run the MQL5 build on a hedging account only. - Requires AutoTrading enabled. MQL4 checks IsTradeAllowed(); MQL5 checks TERMINAL_TRADE_ALLOWED together with the account's ACCOUNT_TRADE_ALLOWED and ACCOUNT_TRADE_EXPERT flags. Either way, if trading is disabled the EA logs it and skips the entry.

Expert advisor · MT4 · v1.0 · Free

About Band Walk Filtered Reversion

Band Walk Filtered Reversion is an expert advisor (trading robot) for MetaTrader 4 based on Bollinger Bands. It can size trades from your balance and risk percent. It has 12 settings, such as Bands period, Bands deviation and Walk lookback. MQL source code included.

Files in the download: BandWalkFilteredReversion.ex4, BandWalkFilteredReversion.mq4, BandWalkFilteredReversion.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Bands period20Bollinger Bands period
Bands deviation2.0Bollinger Bands standard deviation multiplier
Walk lookback6Bars checked before the signal bar for band-walk touches
Max walk touches2Touches in the lookback that mark this as a band walk (skip trade)
Stop loss pips50Protective stop loss distance, in pips
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 number20260601Magic 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: Price Action · Bollinger Bands · Buy/Sell Arrows · Trend · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria