Skip to content

Free MT5 Expert Advisor

RSI Reversal EA

MT5 Expert Advisor that trades RSI exits from overbought or oversold, with an optional 200 EMA filter, ATR stop and a target at the mean.

Mean reversionv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Stop-loss on every trade
Strategy
Buys when RSI closes back above the oversold level and sells when it closes back below the overbought level, optionally only on the side of the 200 EMA. The take-profit is the 20-period moving average.
Risk model
1% of balance per trade (configurable), ATR-based stop-loss on every order, one position at a time

What it does

RSI Reversal EA trades the moment momentum turns back from an extreme. Instead of buying as soon as RSI drops below 30, it waits for RSI to close back above the level, which shows that selling pressure has started to fade. The trade then aims for the average price of recent bars rather than for a new trend.

An optional 200 EMA filter keeps the EA on the side of the larger trend, so in an uptrend it only buys oversold dips and in a downtrend it only sells overbought rallies.

How it works

On each new bar the EA reads the last two closed bars:

  • Buy: RSI on the previous bar was below the oversold level and RSI on the last closed bar is at or above it.
  • Sell: RSI on the previous bar was above the overbought level and RSI on the last closed bar is at or below it.
  • Trend filter (optional): a buy needs the close above the 200 EMA, a sell needs it below.
  • Stop-loss: entry price minus (or plus) 1.5 × ATR(14).
  • Take-profit: the value of the 20-period SMA on the signal bar.
  • Reward check: if the distance to the SMA is less than 0.8 × the stop distance, the signal is skipped because the target is too close to justify the risk.

An optional exit closes the trade early when RSI crosses back through 50 against it. Position size comes from the stop distance and your risk percentage, using the symbol's tick value and tick size.

How to use it

The idea works best in ranges or in steady trends with orderly pullbacks. On H1 and H4 the signals are less frequent and less affected by spread. Read the RSI lesson if you are new to the indicator, and check your lot sizes with the Position Size Calculator.

The Experts log explains every skipped signal: outside trading hours, spread too wide, trend filter against the trade, or a target too close.

Settings

InputDefaultWhat it changes
RSI period14Sensitivity of the RSI
Oversold / Overbought level30 / 70Extremes that must be left to trigger a trade
Trend filter / Trend EMA periodtrue / 200Restricts trades to the trend side
Mean (SMA) period20Take-profit level
Stop-loss distance (x ATR)1.5Stop size
Skip if distance to the mean < this x stop0.8Minimum reward relative to risk
Close when RSI crosses 50falseOptional early exit
Risk per trade / Fixed lots1.0% / 0Position sizing
Max spread (points)30Spread filter
Trading start / end hour7 / 20Server-time window for new trades
Break-even / Trailingon / offStop management after the trade moves in profit

Limitations

In a strong trend RSI can leave an extreme and return to it quickly, so the stop is hit before the mean is reached. The trend filter reduces this but cannot remove it. Because the target moves with the average, a fixed take-profit set at entry may be slightly away from the live average later. Results depend heavily on spread and on the timeframe chosen.

Before you run it live

Test it in the MT5 Strategy Tester on several years of data and more than one symbol, then run it on a demo account for a few weeks. Make sure the trading hours match your broker's server time, set a spread limit that suits the symbol, and keep the risk per trade small. Read basic risk management before going live. Past behavior does not guarantee future results.

Key inputs

Key inputs of RSI Reversal EA
InputDefaultDescription
RSI period14Bars used for the Relative Strength Index.
Oversold level30A buy signal needs RSI to close back above this level.
Overbought level70A sell signal needs RSI to close back below this level.
Trade only in the direction of the trend EMAtrueBuys only above the trend EMA, sells only below it.
Mean (SMA) period used as take-profit20The moving average the trade targets.
Stop-loss distance (x ATR)1.5Stop-loss distance as a multiple of ATR(14).
Risk per trade (% of balance)1.0Lot size is calculated so the stop-loss loses about this share of the balance.

Educational tools, not advice. Automated trading can lose money quickly. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 expert advisors