An Expert Advisor (EA) is different from every other download on this site — an indicator only plots or alerts, while an EA actually sends orders on your behalf. This free EA trades a single, transparent mean-reversion strategy built on the Money Flow Index: it watches for MFI to turn back out of its oversold or overbought zone, then opens a trade with an ATR-based Stop Loss, an RR-multiple Take Profit, and a risk-based position size — all calculated automatically, with no manual chart-watching required.
How the Strategy Works
MFI is often described as "volume-weighted RSI," and that description matters for how this EA behaves. Like RSI, it produces a bounded 0-100 reading by comparing recent up-moves to recent down-moves — but where RSI works purely off price, MFI folds in each bar's traded volume, weighting bars with heavier participation more heavily than quiet ones. The practical effect is that MFI can diverge from what price alone would suggest: a price move on thin volume shows up as a weaker MFI swing than the same move on heavy volume, even though both look identical on a plain price chart.
The signal this EA trades is not MFI reaching an extreme, but MFI turning back through it. A BUY setup forms when MFI (default 14-period, MFIPeriod) crosses back above the Oversold level (default 20.0) after having been at or below it on the previous completed bar — not the moment MFI first drops to 20, but the bar where it climbs back above that line. A SELL setup mirrors this: MFI crossing back below the Overbought level (default 80.0) after having been at or above it. Trading the touch itself, rather than the turn back out, is the classic beginner mistake with any extreme-reading oscillator — this EA is built to avoid it mechanically, since it only fires on the cross-back bar and never on the bar that first enters the zone.
Stop Loss, Take Profit, and Position Sizing
Every trade's Stop Loss is sized from ATR rather than a fixed pip distance: SL distance = ATR (14-period, ATRPeriod) × ATRMultiplier (default 2.0). A volatile pair or session gets a wider stop automatically; a quiet one gets a tighter stop — the stop always reflects what the market is actually doing right now, rather than an arbitrary fixed number that's too tight on some pairs and too loose on others. Take Profit is then set at RiskRewardRatio (default 2.0) times that same SL distance, so every trade opened by this EA carries a fixed, known risk-to-reward ratio regardless of which pair or timeframe it's running on.
Position size is calculated the same way it's taught in Risk Management Basics: RiskPercent (default 1.0%) of account balance, divided by the Stop Loss distance and converted through the symbol's tick value, gives a lot size where a losing trade costs roughly the same fraction of the account no matter how wide or narrow that particular ATR-based stop happens to be. The result is normalized to the broker's minimum lot, maximum lot, and lot step before being sent with the order. Traders who'd rather trade a constant lot size regardless of account balance or stop width can flip on UseFixedLot, which overrides the risk-based calculation with a flat FixedLotSize instead.
Entry Conditions
- BUY — MFI crosses from at-or-below the Oversold level back above it (MFI ≤ 20.0 on the previous completed bar, and > 20.0 on the current bar).
- SELL — MFI crosses from at-or-above the Overbought level back below it (MFI ≥ 80.0 on the previous completed bar, and < 80.0 on the current bar).
On top of the signal itself, several safety mechanics keep the EA well-behaved on a live account. It opens one position at a time — before considering a new entry, it counts existing positions filtered by symbol and magic number, and skips the signal entirely if one is already open. Every order it places is tagged with its own magic number (20260729), so it never touches trades opened manually or by a different EA sharing the same chart or account. It evaluates entry logic once per new bar only, tracking the timestamp of the last bar it processed rather than re-checking on every incoming tick, so a single cross-back can't fire the same trade multiple times before the bar closes. And before sending any order, it checks the current spread against MaxSpreadPoints and skips the entry entirely if the market is too illiquid at that moment — the same concern covered in Spread and Slippage.
Parameters
- MFIPeriod (default 14) — the lookback period for the Money Flow Index calculation. Shorter reacts faster and crosses the 80/20 lines more often; longer is smoother and more selective.
- Overbought (default 80.0) — the upper MFI threshold; a SELL fires when MFI crosses back below this level after having been at or above it.
- Oversold (default 20.0) — the lower MFI threshold; a BUY fires when MFI crosses back above this level after having been at or below it.
- ATRPeriod (default 14) — the lookback period used to calculate ATR for the Stop Loss distance.
- ATRMultiplier (default 2.0) — Stop Loss distance = ATR × this multiplier.
- RiskRewardRatio (default 2.0) — Take Profit distance = Stop Loss distance × this ratio.
- RiskPercent (default 1.0) — percentage of account balance risked per trade, used to calculate lot size against the ATR-based Stop Loss distance. Ignored if
UseFixedLotis enabled. - UseFixedLot (default false) — when enabled, every trade uses
FixedLotSizeinstead of the risk-based calculation. - FixedLotSize (default 0.01) — the flat lot size used only when
UseFixedLotis enabled. - MaxSpreadPoints (default 30) — skips new entries while the spread is wider than this, avoiding entries at a bad price during illiquid conditions.
- EnableTrading — a master on/off switch, useful for pausing the EA without removing it from the chart.
- MagicNumber (default 20260729) — the unique identifier tagged on every order this EA opens, used to isolate its positions from manual trades and other EAs.
Why 80/20 Instead of RSI's 70/30
Traders coming from RSI often assume MFI should use the same 70/30 zone markers, since both indicators are bounded 0-100 and both are read the same way — above the upper line is "overbought," below the lower line is "oversold." In practice, MFI's distribution of readings behaves somewhat differently, which is why 80/20 is the more common convention for it, and why this EA uses those levels by default rather than reusing RSI's 70/30.
The reason traces back to the volume weighting itself. RSI is a pure function of the sequence of closing-price changes, so its readings spread fairly evenly across the 0-100 range as price momentum shifts. MFI multiplies each bar's price movement by that bar's volume before comparing up-flow to down-flow, which means a handful of high-volume bars can dominate the calculation regardless of how many bars actually moved in each direction. That weighting tends to pull MFI toward the middle of its range more often and produces extreme readings less frequently than RSI does under the same price action — so a 70/30 boundary calibrated for RSI's distribution catches MFI in its zone too rarely, or triggers this EA's reversal logic before the extreme is genuinely exhausted. Widening the bands to 80/20 gives MFI room to reflect its own, somewhat different statistical behavior before this EA treats a reading as extreme enough to trade against.
This is also why comparing MFI to a plain oscillator matters when you're deciding which reversal EA to run: RSI Reversal and CCI Reversal both trade the same "turn back out of the zone" logic covered above, but MFI's volume component means it can sometimes agree with price-only oscillators and sometimes diverge from them sharply — a reversal signal that price alone doesn't yet show, or the absence of a signal that price alone would suggest, precisely because the volume behind the move told a different story than the price bars did.
Installation and Setup
EAs install into a different folder than indicators — this is the step people miss most often.
- Download the file below for your platform.
- Open MetaTrader → click
File→Open Data Folder. - Place the file in
MQL4/Experts(MetaTrader 4) orMQL5/Experts(MetaTrader 5) — not the Indicators folder. - Restart MetaTrader, then drag the EA from the Navigator window onto a chart.
- Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA will not place any trades while this is off, even if it's attached to a chart.
- Review and adjust the input parameters in the EA's settings dialog before confirming.
A Word of Caution
Test on a demo account first, across different market conditions, before risking real money — past performance, in backtests or live, never guarantees future results. No strategy, automated or manual, wins every trade, and this EA can and will lose money on individual trades. Mean-reversion systems in general get hurt in strong trending markets, and this EA is no exception: if price keeps trending down through the 20 level bar after bar instead of bouncing, the EA will keep opening BUY trades against a market that has no intention of reversing — a classic "catch a falling knife" scenario, and the mirrored risk applies to SELL trades in a strong uptrend through 80. The ATR-based Stop Loss limits how much any single trade can cost, but it does not prevent a string of consecutive losses when the broader trend overwhelms the reversal signal repeatedly. Consider pairing this EA with a trend filter of your own — reading ADX or checking trend vs range conditions before enabling it — rather than running it unmodified through a strongly trending market. Both files are source code — open and review them fully, and understand what every parameter does, before using it. This content is general education, not personalized investment advice.
Download the EA
How to Install — MetaTrader 4
- Download the
mfi-reversal-ea.mq4file below. - Open MetaTrader 4 → click
File→Open Data Folder. - Place the file in the
MQL4/Expertsfolder. - Restart MetaTrader 4, then drag the EA from the Navigator window onto the chart.
How to Install — MetaTrader 5
- Download the
mfi-reversal-ea.mq5file below. - Open MetaTrader 5 → click
File→Open Data Folder. - Place the file in the
MQL5/Expertsfolder. - Restart MetaTrader 5, then drag the EA from the Navigator window onto the chart.
Both files are source code — open and review the full code before using it, for your own safety.