Blog

RSI Expert Advisor for MT5 and MT4: Build, Test, Export

TradeSmithy Team4 min read

Short answer: a basic RSI Expert Advisor buys when the Relative Strength Index crosses back up through 30 and sells when it crosses back down through 70, one trade at a time, with a stop and target. The common mistake is the rule "buy when RSI is below 30", which fires on every candle of a falling market and fills the account with losing positions.

How does an RSI trading strategy work?

RSI measures the speed of recent gains against recent losses on a 0–100 scale, 14 periods by default. Readings below 30 are called oversold, above 70 overbought. An RSI EA usually trades one of two ideas:

IdeaBuy signalWorks best in
Mean reversionRSI turns up from below 30Ranging markets
MomentumRSI rises above 50 (or 60)Trending markets

They are opposites, so pick one per EA. The rest of this guide builds the mean reversion version, then adds a filter so it stops fighting strong trends.

"Below 30" versus "crossing back above 30"

"RSI < 30" is true for as long as the market keeps falling — which is exactly when a mean-reversion buy loses most. Waiting for RSI to cross back above 30 means price has at least stopped accelerating down. In rule form, on each closed candle:

  • previous RSI < 30, and
  • current RSI ≥ 30, and
  • no position already open.

How to build an RSI EA in TradeSmithy

Start from the RSI Trading Bot template, or build it:

  1. OnNewCandle on your timeframe, so each decision uses a closed bar.
  2. A Technical Indicator node set to RSI — period 14, applied price close.
  3. A Variable prevRsi, and at the end of every candle a Set Variable that stores the current RSI in it for the next bar.
  4. Two Comparison nodes — prevRsi < 30 and RSI ≥ 30 — plus a Positions & Orders count compared with 0, all into an AND.
  5. A BUY Order with stop loss and take profit in points.
  6. The mirror for sells at 70, and OnNewCandle End to close every path.

One detail worth getting right: prevRsi starts at 0 on the first candle, which satisfies "below 30". Either give it a neutral initial value such as 50, or it may enter on the first bar after you attach it.

Add a trend filter

Mean reversion loses when it fights a strong trend. Add a 200-period Moving Average and only take buys when price is above it, sells when below. That is one indicator, one Price Data node and one more input on the AND.

Make the levels inputs

Wire the RSI period and the 30/70 levels to Global Parameter nodes. They become EA inputs you can change in the terminal and sweep in MetaTrader's optimiser, without touching the graph. How parameter ports work.

Common RSI variations

  • Short-period RSI (2–5) with extreme levels such as 10/90 — much more frequent signals, very sensitive to spread.
  • RSI exit instead of a fixed target: close the buy when RSI reaches 50 or 70, with a Close Order node.
  • Momentum RSI: buy when RSI crosses above 50 in the direction of the 200 MA.

Test it before trusting it

RSI strategies are notorious for looking good on one period and failing on the next. Test on data you did not tune on, with realistic spread — our MT5 backtesting guide — and compare modelling modes if your targets are small.

Build your RSI EA

Start free on TradeSmithy: open the RSI template, set your levels, and export MQL5 or MQL4 — one export a month is free. On Pro, ask the AI assistant to "add a 200 EMA trend filter" and queue backtests on our servers. The same pattern works for a moving average crossover.

Frequently asked questions

What are the best RSI settings for an EA?

14 with 30/70 is the standard starting point, not a recommendation. Make them inputs and test alternatives on your symbol and timeframe.

Is an RSI EA profitable?

Mean-reversion RSI strategies can work in ranging markets and struggle in trends. A trend filter and realistic costs decide most of the outcome.

Why does my RSI EA open a trade every candle?

It is testing "RSI below 30" rather than the cross, and has no limit on open positions.

Can I use RSI on a higher timeframe than my chart?

The OnNewCandle node can act on a higher timeframe's candle close; the indicator itself reads the chart's timeframe.

Keep reading

← More from the TradeSmithy blog