Where an indicator stops at plotting a line or sounding an alert, an Expert Advisor goes one step further and sends the trade itself. 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.
What's left — position sizing, stop and target geometry, and the safety checks — follows the site-wide risk engine, documented on the EAs overview. Trades opened by this EA carry magic number 20260729.
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.
A Word of Caution
Put it through a demo account across quiet and volatile markets before risking capital; what it did in the past, in a tester or live, says nothing certain about what it will do next. No trading system wins every position; expect this EA to lose on individual trades as a matter of course. 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. Since both versions are open source files, read the code yourself — every parameter should make sense to you before it ever touches a live chart. None of the above is personal financial advice — it is a technical explanation, nothing more.