# RSI Mean Reversion EA with 200 EMA Filter for MT4

> Free RSI mean reversion Expert Advisor: buys RSI dips above the 200 EMA and sells spikes below it, exiting at an RSI mid level, ATR stop or time limit.

## At a glance

- What it is: A free Expert Advisor for MetaTrader 4, written in MQL4.
- What it does: Free RSI mean reversion Expert Advisor: buys RSI dips above the 200 EMA and sells spikes below it, exiting at an RSI mid level, ATR stop or time limit.
- Shared by: Alex
- Licence: MIT
- Version: 1.0 (1 Dec 2026)
- Settings: 23 inputs
- Lab check: Compiled with MetaEditor build 2425 for MT4 on 1 Dec 2026: 0 errors, 0 warnings.
- Price: Free to download
- Page: https://hub.fxnook.com/rsi-mean-reversion-ea-with-200-ema-filter-for-mt4
- Download (compiled): https://hub.fxnook.com/download/fe7084b6-df42-40a1-b561-1178a722a74b/compiled
- Download (source): https://hub.fxnook.com/download/fe7084b6-df42-40a1-b561-1178a722a74b/source

## About

**FXN RSI Mean Reversion** is a free, open-source Expert Advisor for MetaTrader 4 and MetaTrader 5 that buys short-term weakness in an uptrend and sells short-term strength in a downtrend, using RSI with a 200 EMA trend filter, a mid-level exit and a time limit.

## How it works

- **Buy** when the close is above the EMA and RSI closed below the oversold level (10). **Sell** when below the EMA and RSI closed above overbought (90).
- **Exit** a buy when RSI closes at or above the exit level (50), a sell at or below it; the order closes at the next bar's open.
- **Time limit**: closes a trade after **Max bars in trade** (10) bars; 0 = off.
- **Stop loss** = entry minus `ATR x Stop loss multiplier` (buys) or plus (sells). No fixed take profit; after an exit the next entry waits for a new bar.
- **Lot size** (risk mode): `balance x risk % / money lost per lot at the stop`, rounded down to the lot step.

## Inputs

| Input | Default | What it does |
|---|---|---|
| RSI period | 2 | RSI look-back; 2 for short-term, 14 for classic. |
| Oversold level | 10.0 | Buys when RSI closes below this in an uptrend. |
| Overbought level | 90.0 | Sells when RSI closes above this in a downtrend. |
| RSI exit level | 50.0 | Closes when RSI crosses back over this level. |
| Trend EMA period | 200 | Buys only above this EMA, sells only below it. |
| ATR period | 14 | Average True Range period for the stop. |
| Stop loss (x ATR) | 2.5 | Stop distance = ATR of the signal bar times this. |
| Max bars in trade | 10 | Closes after this many bars; 0 = off. |
| Use risk % sizing | true | true = lot from risk %; false = fixed lot. |
| Risk per trade (% of balance) | 1.0 | Balance share lost if the stop is hit. |
| Fixed lot | 0.10 | Lot used when risk sizing is off. |
| Magic number | 410108 | Identifies this EA's trades. |
| Max spread (points) | 30 | No entry above this spread; 0 = off. |
| Max slippage (points) | 10 | Allowed fill deviation. |
| Order comment | FXN RsiReversion | Text saved on each order. |
| Use trading hours | false | Entries only inside the window; exits any time. |
| Start hour (0-23) | 7 | First hour with entries. |
| End hour (0-23) | 20 | Entries stop at this hour; may wrap past midnight. |

## How to use it

1. Copy `FXN_RsiReversion.mq4` to `MQL4/Experts` (MT4) or `FXN_RsiReversion.mq5` to `MQL5/Experts` (MT5); **File > Open Data Folder** shows where.
2. Refresh the Navigator, drag the EA onto a chart and turn on **AutoTrading** (MT4) or **Algo Trading** (MT5).
3. Suggested start: H1 to D1 on indices, gold or FX majors, RSI 2 with 10/90 levels (or RSI 14 with 30/70), exit 50, EMA 200, stop 2.5 x ATR, 10 bars, risk 0.5 %.
4. Test in the Strategy Tester and on a demo account first.

## Good to know

- A full stop loss is usually larger than a typical winner, so keep risk per trade modest.
- After a sharp trend change the EMA reacts slowly, so the EA may buy dips in a falling market (one trade at a time).
- The stop is wide on purpose; tight stops on reversion entries get hit by noise.
- Closed-bar signals that do not repaint; one entry per bar and one trade per symbol and magic number. No martingale, grid or averaging down.
- Stops respect broker stop and freeze levels. If risk sizing gives less than the minimum lot, the trade is skipped and logged. On MT5 netting accounts it will not trade a symbol that already has another position.

Trading carries risk. Test on a demo account first; past results do not predict future results.

## Settings (inputs)

| Input | Type | Default | Note |
|---|---|---|---|
| InpSep1 | string |  | ===== RSI and trend ===== |
| InpRsiPeriod | int | 2 | RSI period |
| InpOversold | double | 10.0 | Oversold level |
| InpOverbought | double | 90.0 | Overbought level |
| InpExitLevel | double | 50.0 | RSI exit level |
| InpTrendPeriod | int | 200 | Trend EMA period |
| InpSep2 | string |  | ===== Stop and time limit ===== |
| InpAtrPeriod | int | 14 | ATR period |
| InpStopAtrMult | double | 2.5 | Stop loss (x ATR) |
| InpMaxBarsInTrade | int | 10 | Max bars in trade |
| InpSep3 | string |  | ===== Lot size and risk ===== |
| InpUseRiskPercent | bool | true | Use risk % sizing |
| InpRiskPercent | double | 1.0 | Risk per trade (% of balance) |
| InpFixedLot | double | 0.10 | Fixed lot |
| InpSep4 | string |  | ===== Orders and filters ===== |
| InpMagic | int | 410108 | Magic number |
| InpMaxSpreadPoints | int | 30 | Max spread (points) |
| InpSlippagePoints | int | 10 | Max slippage (points) |
| InpOrderComment | string | FXN RsiReversion | Order comment |
| InpSep5 | string |  | ===== Trading hours (server time) ===== |
| InpUseTradingHours | bool | false | Use trading hours |
| InpStartHour | int | 7 | Start hour (0-23) |
| InpEndHour | int | 20 | End hour (0-23) |

Tags: rsi, mean-reversion, rsi-2, ema, pullback, expert-advisor

Shared code is the author's work, not financial advice. Test on a demo account first.
