LearnForexHub
EA

EA: RSI Reversal Expert Advisor

Written by , Founder & EditorLast updated How we write and review lessons

Everything else you can download on this site just draws or alerts — an Expert Advisor is different, because it submits orders on your behalf. This free EA trades a single, transparent mean-reversion strategy built on RSI: it watches for RSI to snap back out of the Overbought or Oversold 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

The signal this EA trades is the same one taught in the site's own RSI lesson: the meaningful moment is usually not RSI entering an extreme zone, but RSI leaving it. A BUY setup forms when RSI (default 14-period) crosses back above the Oversold level (default 30) after having dipped below it — not the moment RSI first dips under 30, but the bar where it climbs back over that line. A SELL setup is the mirror case: RSI crossing back below the Overbought level (default 70) after having pushed above it. Touching an extreme only tells you momentum was stretched; the cross back out is the first real evidence that the stretch is unwinding and price may bounce. Trading the touch itself, rather than the exit, is a common beginner mistake this EA is built to avoid mechanically — it only fires on the cross-back bar, never on the bar that first enters the zone.

Stop Loss, Take Profit, and Position Sizing

PriceTake Profit (TP)Stop Loss (SL)BUY7030OverboughtOversoldRSI (0–100)
Entry conditions: BUY when RSI crosses back above 30 out of the oversold zone — SELL on the mirrored cross back below 70 — SL and TP are placed automatically from ATR

Every trade's Stop Loss is sized from ATR rather than a fixed pip distance: SL distance = ATR × 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 this EA opens carries a fixed, known risk-to-reward ratio, win or lose.

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, gives a lot size where a losing trade costs roughly the same fraction of the account no matter how wide or narrow that particular Stop Loss happens to be. If you'd rather run a fixed size no matter the balance or stop width, enable UseFixedLot and the flat FixedLotSize takes over.

Entry Conditions

  • BUY — RSI crosses from below the Oversold level back above it (RSI was under 30 on the previous bar, is at or above 30 on the current bar).
  • SELL — RSI crosses from above the Overbought level back below it (RSI was over 70 on the previous bar, is at or below 70 on the current bar).

On top of the signal itself, three safety mechanics keep the EA well-behaved on a live account. Only one position at a time is allowed: the EA counts its own open trades (by symbol and magic number) and ignores any new signal while one exists. Every order it places is tagged with its own magic number (20260718), so it never touches trades opened manually or by a different EA sharing the same chart or account. And 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 — without this, a single RSI cross could otherwise fire the same signal dozens of times before the bar closes.

Parameters

  • RSIPeriod (default 14) — the lookback period for the RSI calculation; shorter reacts faster and crosses zones more often, longer is smoother and more selective.
  • Oversold (default 30) — the lower RSI threshold; a BUY fires when RSI crosses back above this level.
  • Overbought (default 70) — the upper RSI threshold; a SELL fires when RSI crosses back below this level.

The remaining parameters aren't specific to this strategy: they belong to the risk engine shared across the whole EA collection, explained in one place on the EA hub. This EA identifies its own trades with magic number 20260718.

Mean-Reversion vs. Trend-Following

This EA takes the opposite bet from a trend-following system like this site's Moving Average-based EA: instead of trying to ride a move that's already underway, it bets that a stretched, extreme reading is about to snap back toward the middle. That bet pays off well in ranging markets, where price genuinely oscillates between support and resistance and RSI repeatedly swings from Oversold back to Overbought and back again — exactly the condition described in this site's trend vs range lesson. It performs poorly in strong trending markets, where RSI can stay pinned near an extreme for an extended stretch precisely because price keeps closing in the same direction; a strong uptrend is, by definition, a market that keeps printing higher closes, which is what keeps RSI elevated. In that regime, a mean-reversion BUY signal can trigger repeatedly against the trend, each one stopping out as price simply continues rather than reverting. This is the core tradeoff of any mean-reversion system: it needs the market to actually be ranging to work, and it has no built-in awareness of whether it currently is — pairing it with a manual read of trend vs range conditions, or trading it only on pairs and timeframes known to chop rather than trend, meaningfully improves its results.

A Word of Caution

Give it an extended demo period in varied conditions before going live — historical performance, simulated or real, is not a promise of future results. No strategy, automated or manual, wins every trade, and this EA can and will lose money on individual trades, particularly if it's run on a pair or timeframe that's trending strongly rather than ranging. Everything is distributed as source code: review it line by line, and don't run anything whose parameters you can't explain. This page teaches how the mechanism works — it is not a recommendation to trade it with real money.

Download rsi-reversal-ea.mq4

For MetaTrader 4 — this is source code (.mq4), open and review it fully before using it.

Download File

Download rsi-reversal-ea.mq5

For MetaTrader 5 — this is source code (.mq5), open and review it fully before using it.

Download File

How to install

An EA installs into the Experts folder, not Indicators — this is the step people miss most often.

MetaTrader 4

  1. Download rsi-reversal-ea.mq4 above.
  2. Open MetaTrader 4FileOpen Data Folder.
  3. Place the file in the MQL4/Experts folder.
  4. Restart MetaTrader 4, then drag it from the Navigator window onto a chart.
  5. Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA places no trades while this is off, even when attached to a chart.
  6. Review and adjust the input parameters in the settings dialog before confirming.

MetaTrader 5

  1. Download rsi-reversal-ea.mq5 above.
  2. Open MetaTrader 5FileOpen Data Folder.
  3. Place the file in the MQL5/Experts folder.
  4. Restart MetaTrader 5, then drag it from the Navigator window onto a chart.
  5. Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA places no trades while this is off, even when attached to a chart.
  6. Review and adjust the input parameters in the settings dialog before confirming.

Both files are source code. Open and read them in MetaEditor before running them on any account.