On this page
Back to tutorials

Build an RSI Overbought/Oversold EA in MT5 — No Code

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

📖 16 min read

📝 3,200 words

🏷️ MQL5 & Expert Advisors

Share this article:

Want to build a no-code strategy right now?

Create your free account in seconds and start building immediately.


Build an RSI Overbought/Oversold EA for MT5 — No Code

Quick Answer: RSI Overbought/Oversold EA Without Code

Quick answer: Add RSI on Step 3 — Signals in AlfaTactix Strategy Builder, set Cross with Target = Oversold, Direction = Up, Value = 30 for Buy and Target = Overbought, Direction = Down, Value = 70 for Sell, configure Length 14, Overbought 70, Oversold 30, add Stop Loss / lot size on Step 5, Save, export MQL5 from Code Generator, 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


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(). 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(). 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
Overbought70Range 50–100 in builder
Oversold30Range 0–50 in builder
TimeframeH1 (forex majors)M15 = more signals; H4 = cleaner swings
SymbolEURUSD, GBPUSDLiquid pairs; spread matters on tight stops
SmoothingNoneOptional SMA/EMA/WMA/SMMA/VWMA on RSI line

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 add RSI on Step 3 — Signals, the Parameters panel shows seven fields:

ParameterTypeRange / optionsDefaultWhat it does
LengthNumber2 – 10014Lookback periods for RSI calculation
SourceSelectClose, Open, High, LowClosePrice series used in the calculation
SmoothingSelectNone, SMA, EMA, WMA, SMMA, VWMANoneOptional smoothing applied to the RSI line
Smoothing LengthNumber1 – 10014Period when Smoothing ≠ None
OverboughtNumber50 – 10070Upper threshold line on the oscillator
OversoldNumber0 – 5030Lower threshold line on the oscillator
OffsetNumber-50 – 500Shifts the RSI forward/backward in bars (advanced; leave 0 for standard EAs)

Tip for mean-reversion EAs: Set Overbought and Oversold in Parameters to match your Cross condition Value fields (e.g. Parameters OS 30 + Cross Target Oversold Value 30) so the chart lines align with entry rules.

Smoothing: Leave None for the classic Wilder-style RSI. Enable SMA or EMA smoothing if you want a less jagged line — keep Smoothing Length equal to Length (e.g. both 14) for consistency.


RSI Condition Types Explained

Open an RSI indicator on Step 3 → Add condition. The dropdown lists seven condition types. Below is every field the UI exposes.

1. Compare

Compare the RSI value to a fixed threshold (0–100 scale).

FieldOptions
Operator>, <, >=, <=, ==, !=
ValueNumber 0 – 100 (e.g. 30 for oversold, 70 for overbought)

Use case: “Buy when RSI <= 30” — fires while RSI remains in the zone (can re-trigger every bar).

Alternative entry: Combine Compare RSI <= 30 with a second Cross Up through 30 using AND — stricter than Compare alone.


2. Cross

Detect when RSI crosses a target level or line.

FieldOptions
TargetRSI, Overbought, Oversold, 50
DirectionUp (bullish cross) · Down (bearish cross)
ValueNumber (e.g. 30 when Target = Oversold, 70 when Target = Overbought)

Classic mean-reversion recipe:

TabTargetDirectionValue
BuyOversoldUp30
SellOverboughtDown70

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

Other targets: Target = 50, Direction = Up for midline reclaim entries; Target = RSI with custom Value for arbitrary levels.


3. Divergence

Price vs RSI disagreement — advanced reversal signal.

FieldRange / options
Divergence TypeBullish · Bearish
Period1 – 100 (default 14)
Lookback Period1 – 200 (default 40)
Strength1 – 10 (default 1)
Timeframe1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w, 1M

Use case: “Buy on bullish divergence when RSI also crosses up from oversold” — combine with Cross using AND in Step 3.


4. Failure Swing

RSI-specific reversal pattern (failed attempt to reach a new extreme).

FieldRange / options
DirectionUp · Down
Period1 – 100 (default 20)
Confirmation1 – 10 bars (default 1)

Use case: Higher-quality reversal entries than a simple threshold cross; add Confirmation 2–3 to reduce noise.


5. Breakout

RSI breaks through a dynamic threshold over a lookback window.

FieldRange / options
DirectionUp · Down
ThresholdRSI level (e.g. 70)
Period1 – 50 bars (default 5)
Confirmation1 – 10 bars (default 1)
Volume ConfirmationNone · Above Average · High

Use case: Momentum-style RSI breakout (different from classic mean-reversion); combine with trend filter if needed.


6. Pattern

Chart pattern detection on the RSI series.

FieldOptions
Pattern TypeDouble Top, Double Bottom, Head & Shoulders, Inverse H&S, Triangle, Wedge
Min HeightRSI points (default 10)
Min WidthBars (default 10)
Volume ConfirmationNone · Above Average · High

Use case: Advanced entries; most RSI mean-reversion EAs use Cross only.


7. Slope

Require the RSI line to be rising or falling by a minimum amount.

FieldRange / options
DirectionUp · Down
Period1 – 50 (default 5)
Min SlopeNumber (0 = any slope)
SmoothingNone, SMA, EMA, WMA
Smoothing Length1 – 100 (default 5 when smoothing enabled)
SourceClose, Open, High, Low

Use case: “Buy Cross Up from oversold only if RSI slope is Up” — combine with AND in Step 3.


Logical combinations on Step 3

Combine indicators and conditions with AND, OR, NOT, parentheses, and groups — same as described in Build EA Without Coding. Example: (Cross Oversold Up AND Slope Up).


Build the RSI EA Step by Step

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

Step 1 — Strategy information

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

Step 2 — Timeframes

  • Enable one trading timeframe, e.g. H1 (matches tab tf0 on Step 3).
  • Optional: add a higher timeframe later for trend filter (Advanced MTF Filters).

Step 3 — Signals (core)

  1. Open tab Buy.
  2. Select timeframe H1.
  3. Add indicatorRSI (Momentum group).
  4. Parameters:
    • Length: 14
    • Source: Close
    • Smoothing: None
    • Smoothing Length: 14 (ignored when Smoothing = None)
    • Overbought: 70
    • Oversold: 30
    • Offset: 0
  5. Add conditionCross.
    • Target: Oversold
    • Direction: Up
    • Value: 30
  6. Open tab Sell.
  7. Add RSI again (or mirror rule): Cross
    • Target: Overbought
    • Direction: Down
    • Value: 70

Alternative — Compare then Cross: On Buy, add Compare RSI <= 30 AND Cross Target Oversold Direction Up Value 30 for a stricter bounce entry.

Step 4 — Filters (optional)

Examples: market session (London/NY), spread cap, ATR filter. See Advanced EA MTF & Filters.

Step 5 — Risk management

Minimum for a testable EA:

SettingSuggestion
Lot / risk %0.01 lot demo or 1% risk
Stop LossFixed pips or ATR-based
Take ProfitOptional; many RSI EAs exit on opposite cross (sell signal closes long)
One trade at a timeAvoid overlapping positions

Full reference: EA Risk Management.

Step 6 — Preview and Save

Review Buy/Sell rules → Save strategy to your account.


Export, Compile, and Backtest

  1. Open Code Generator → select your saved strategy → MQL5 → download .mq5.
  2. Copy to MQL5/Experts, compile (F7) in MetaEditor.
  3. Strategy Tester: Every tick, realistic spread, 6–12 months data on H1 EURUSD.
  4. Forward test on Demo before live. Read Strategy Tester vs Live.

If OrderSend fails with 10016, see Invalid Stops.

Exported code uses standard iRSI() — 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 Cross not Compare; Failure Swing with Confirmation 2–3
Spread eats profitStep 4 spread filter; test on ECN/low-spread symbol
Over-tradingStep 5 max trades; one position per symbol
Late entriesTighten levels (e.g. OS 25, OB 75) or shorter Length (7–9)

Next Steps

Try it: Strategy Builder demo — build the RSI 14 / 30 / 70 mean-reversion EA in one session, export, and backtest.

References: MQL5 iRSI, MetaTrader 5 Strategy Tester.

Build your no-code trading strategy now — free

Create your account and start building a complete no-code strategy right now. Add indicators, filters, and risk rules, then export MQL5 in minutes.

Frequently Asked Questions

Yes. In AlfaTactix Strategy Builder, add RSI on Step 3 — Signals, set Cross with Target Oversold, Direction Up, Value 30 for buy and Target Overbought, Direction Down, Value 70 for sell, configure risk on Step 5, save, then export MQL5 from Code Generator. Compile once in MetaEditor and backtest in the Strategy Tester.

The classic starter is Length 14, Overbought 70, Oversold 30, on H1 forex majors like EURUSD. In Strategy Builder, set these in the RSI Parameters panel and use Cross conditions at the same levels. For deeper RSI theory, see the RSI Academy guide.

Cross fires when RSI crosses a level (e.g. crosses up through 30 after being oversold) — best for mean-reversion entries. Compare checks a static rule (e.g. RSI <= 30) and can fire every bar while oversold. For a classic bounce EA, use Cross Target = Oversold, Direction = Up, Value = 30 on Buy.

Yes. Exported code calls the standard MT5 iRSI handle with your Length, Source, and levels. You do not write that logic by hand — see MQL5 Programming Reference and Production-Ready MQL5 Without MetaEditor.

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 Strategy Tester vs Live before going live.

Use Cross instead of Compare so entries trigger on the bounce, not every bar in the zone. Add Confirmation on Failure Swing or Breakout conditions, or Step 4 filters. Set realistic Stop Loss on Step 5 per EA Risk Management. If orders fail with error 10016, see Invalid Stops.

Build your no-code strategy now — free

Create Free Account