RSI Overbought/Oversold EA MT5 — No Code

Strategy Builder walkthrough: RSI parameters, Cross from oversold/overbought, all seven condition types, export MQL5, and backtest a mean-reversion EA.

📖 10 min read

📝 1,960 words

🏷️ MQL5 and Expert Advisors

Share this article:

RSI Overbought/Oversold EA MT5 — No Code

Can I build an RSI overbought/oversold EA for MT5 without coding?

Yes. Add RSI on Step 3 — Entry rules in AlfaTactix Strategy Builder, set the Buy rule to RSI crosses above its Oversold level (30) and the Sell rule to RSI crosses below its Overbought level (70), keep Length 14, Overbought level 70, Oversold level 30, add a Stop loss on Step 5 and the position size on Step 6, press Save strategy in Step 7 and Get the code, compile once in MetaEditor, and backtest on H1 EURUSD with Every tick in the Strategy Tester.

Disclosure: This tutorial uses AlfaTactix Strategy Builder. For the full no-code platform overview, see Build EA Without Coding. For RSI indicator theory and chart reading, see the RSI Academy guide. For a trend-following alternative built the same way, see Moving Average Crossover EA — No Code.

Related guides: Create/Edit MT5 EA · EA Risk Management · Backtest in Strategy Tester · EA Strategy Library


What Is an RSI Overbought/Oversold EA?

An RSI overbought/oversold Expert Advisor automates one of the most popular mean-reversion systems in trading:

SignalRule
Buy (long)RSI was oversold and crosses back up through the oversold level (e.g. 30)
Sell (short)RSI was overbought and crosses back down through the overbought level (e.g. 70)

The Relative Strength Index (RSI) oscillates between 0 and 100. Values above 70 are traditionally overbought; below 30 are oversold. A mean-reversion EA bets that extreme readings will revert toward the middle (often 50).

The EA runs on every tick or bar in MetaTrader 5 via OnTick() [1]. You do not watch charts manually — the platform executes when your RSI condition fires.

Why traders search for this: RSI is the default momentum oscillator in most platforms. Tutorials usually show hand-written MQL5 with iRSI() [2]. This guide shows the same logic in Strategy Builder with every parameter and condition the product exposes for RSI.


Classic RSI Settings and When It Works

SettingStarter valueNotes
Length14Wilder default; 7 = faster, 21 = slower
Overbought level70Range 50–100 in builder
Oversold level30Range 0–50 in builder
Trading timeframe (Step 2)H1 (forex majors)M15 = more signals; H4 = cleaner swings
SymbolEURUSD, GBPUSDLiquid pairs; spread matters on tight stops

Works best: Range-bound or mildly trending markets where price bounces from extremes — especially during mean-reverting sessions on liquid forex.

Struggles in: Strong one-way trends — RSI can stay overbought (uptrend) or oversold (downtrend) for long periods, causing repeated counter-trend entries. Mitigate with Step 4 session/spread filters, Step 5 stop loss, or a trend filter from the MA Crossover EA guide.

For indicator background (calculation, divergence, failure swings), read the RSI Academy guide.


RSI Parameters in Strategy Builder

When you pick RSI under What to watch in Step 3 — Entry rules (Indicator tab), its settings open in the picker:

SettingRange / optionsDefaultWhat it does
Length2 – 20014Lookback periods for the RSI calculation
Price (More settings)open … ohlc4 (7 options)ClosePrice series used in the calculation
Overbought level50 – 10070Upper threshold of the oscillator
Oversold level0 – 5030Lower threshold of the oscillator

Tip for mean-reversion EAs: Use the Level tab for Compare with, so the rule reads the Oversold level and Overbought level you set in the indicator. The entry rule and the levels then always match (for example Oversold level 30 and the rule "crosses above its oversold level (30)").

Smoothing: v2 has no smoothing setting on RSI. If you want a less jagged line, use the Calculation tab to build a moving average of the RSI (for example SMA(14) of RSI) and compare RSI with it.


RSI Condition Types Explained

Step 3 has a Buy rule and a Sell rule. Each line reads like a sentence: Buy when [What to watch] [How they compare] [Compare with]. Below is what v2 offers for RSI.

1. Is above / is below (static rule)

How they compare offers is above, is below, is at or above and is at or below. Compare with takes a number (Number tab) or a level (Level tab).

Use case: “Buy when RSI(14) is above 50” — true while RSI stays on that side (can re-trigger every bar).

Alternative entry: Put a static line and a cross line in one All of these group — stricter than the static line alone.


2. Crosses above / crosses below

True only on the bar where RSI passes the other side.

Part of the lineChoice
What to watchRSI(14)
How they comparecrosses above / crosses below
Compare withLevel tab: Oversold level / Overbought level; or Number tab (e.g. 50); or another indicator

Classic mean-reversion recipe:

RuleLine
Buy ruleRSI(14) crosses above its Oversold level (30)
Sell ruleRSI(14) crosses below its Overbought level (70)

Use case: “RSI crosses up through 30 after being oversold” — fires once per bounce, not every bar in the zone.

Other cross rules: RSI crosses above 50 (midline reclaim); RSI crosses above its own average (Calculation tab, e.g. SMA(14) of RSI).


3. Divergence

How they compare: diverges from price. The form asks for the divergence type (regular or hidden, bullish or bearish), the swing points (left and right bars, for example 5 and 5) and the distance between swings (for example 5 to 60 bars). There is also a minimum oscillator difference (0 = any difference).

Use case: “Buy on bullish divergence when RSI also crosses up from oversold” — put both lines in an All of these group.


4. Rising / falling

is rising / is falling, with Over how many bars and Minimum change (0 = any rise or fall).

Use case: “Buy when RSI crosses up from oversold only if RSI is rising” — one more line in the All of these group.


5. Time window

Under Time window, a line can be Happened within the last N bars (for example a cross within the last 3 bars) or Has been true for N bars in a row. The second is not offered with crosses.


Logical combinations on Step 3

Use groups: All of these or Any of these (a group needs two complete conditions), and Must not be true for a condition. Same as in Build EA Without Coding. Example: All of these → (RSI crosses above its oversold level AND RSI is rising).


Build the RSI EA Step by Step

Workflow: 7 steps in Strategy Builder demo. We detail what matters for a classic RSI 14 / 30 / 70 mean-reversion EA.

Step 1 — Information and platform

  • Name: e.g. RSI Mean Reversion H1 EURUSD
  • Description: optional

Step 2 — Timeframes

  • Add one trading timeframe, e.g. H1. The rule reads it.
  • Optional: add up to two higher timeframes as context for a trend filter (Advanced MTF Filters).

Step 3 — Entry rules (core)

  1. Open the Buy rule.
  2. Under What to watch, pick RSI (Indicator tab).
  3. Settings:
    • Length: 14
    • Price: Close
    • Overbought level: 70
    • Oversold level: 30
  4. How they compare: crosses above.
  5. Compare with: Level tab → Oversold level (30).
  6. Sell rule: switch on Sell mirrors Buy (RSI crosses below its Overbought level (70)), or choose Write the sell rule yourself.

Alternative — static line plus cross: In the Buy rule, use an All of these group with RSI is at or below 30 AND RSI crosses above its oversold level for a stricter bounce entry.

Step 4 — Filters (optional)

Examples: Market sessions (London / New York), Spread limit, a Market condition on ATR. See Advanced EA MTF & Filters.

Steps 5 and 6 — Exits, risk and money management

Minimum for a testable EA:

SettingSuggestion
Position size (Step 6)0.01 lot demo (Fixed lots) or risk per trade (Risk per trade (% of the account))
Stop loss (Step 5)Fixed distance or ATR multiple
Take profit (Step 5)Optional; many RSI EAs close on the opposite signal (Exit by signal)
Open positions (Step 6)Most trades open at the same time: 1, to avoid overlapping positions

Full reference: EA Risk Management.

Step 7 — Review and save

Fix anything in the Check list, then Save strategy.


Export, Compile, and Backtest

  1. In Step 7, Save strategy, then Get the code → MetaTrader 5 code → download .mq5.
  2. Copy to MQL5/Experts, compile (F7) in MetaEditor [3].
  3. Strategy Tester: Every tick, realistic spread, 6–12 months data on H1 EURUSD.
  4. Forward test on Demo before live.

If OrderSend fails with 10016, see Invalid Stops.

Exported code uses standard iRSI() [2] — see MQL5 Programming Reference for handle patterns.


Improvements: Filters and Risk

ProblemBuilder lever
Counter-trend losses in strong trendsStep 4 session filter; add trend filter (see MA Crossover EA)
Too many entries in rangeUse crosses above not is at or below; add Happened within the last N bars or a second line in All of these
Spread eats profitStep 4 Spread limit; test on ECN/low-spread symbol
Over-tradingStep 6 Entries per day; Most trades open at the same time: 1
Late entriesTighten levels (e.g. OS 25, OB 75) or shorter Length (7–9)

Next Steps

Mean-reversion trap: RSI 30/70 in a strong trend keeps firing against you. In the live demo, build RSI cross first, then add one session or ATR volatility filter — if entries on your worst trending month disappear, you learned something worth exporting.

References: MQL5 iRSI [2], MetaTrader 5 Strategy Tester [4].

Frequently Asked Questions

Yes. In AlfaTactix Strategy Builder, add RSI on Step 3 — Entry rules: in the Buy rule, RSI(14) crosses above its Oversold level (30); in the Sell rule, RSI(14) crosses below its Overbought level (70) (or switch on Sell mirrors Buy). Set exits on Step 5 and size on Step 6, press Save strategy in Step 7, then Get the code. Compile once in MetaEditor and backtest in the Strategy Tester.

The classic starter is Length 14, Overbought level 70, Oversold level 30, on H1 forex majors like EURUSD. In Strategy Builder, set these in the RSI settings and use the Level tab in Compare with, so the rule reads the same levels. For deeper RSI theory, see the RSI Academy guide.

crosses above fires when RSI crosses a level (e.g. crosses up through 30 after being oversold) — best for mean-reversion entries. is at or below checks a static rule (e.g. RSI is at or below 30) and can fire every bar while oversold. For a classic bounce EA, use RSI crosses above its Oversold level (30) in the Buy rule.

Yes. Exported code calls the standard MT5 iRSI (opens in a new tab) handle with your Length, Price, and levels. You do not write that logic by hand — see MQL5 Programming Reference and Build EA Without Coding.

RSI mean-reversion buys dips in uptrends and sells rallies in downtrends — but in a strong trend RSI can stay overbought/oversold for long stretches. Add Step 4 session/spread filters, Step 5 stop loss, or combine RSI with a trend filter (e.g. from the MA Crossover EA guide). Read Backtest an EA in the MT5 Strategy Tester before going live.

Use crosses above instead of is at or below so entries trigger on the bounce, not every bar in the zone. Add a Time window line (Happened within the last N bars), a second line in an All of these group, or Step 4 filters. Set a realistic Stop loss on Step 5 per EA Risk Management. If orders fail with error 10016, see Invalid Stops.

References

  1. MetaQuotes, MQL5 Reference. OnTick. https://www.mql5.com/en/docs/event_handlers/ontick
  2. MetaQuotes, MQL5 Reference. iRSI. https://www.mql5.com/en/docs/indicators/irsi
  3. MetaQuotes, MetaEditor Help. Welcome to algorithmic trading!. https://www.metatrader5.com/en/metaeditor/help
  4. MetaQuotes. MetaTrader 5 Built-in Trading Strategy Tester. https://www.metatrader5.com/en/automated-trading/strategy-tester