RSI Expert Advisor for MT5 and MT4: Build, Test, Export
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:
| Idea | Buy signal | Works best in |
|---|---|---|
| Mean reversion | RSI turns up from below 30 | Ranging markets |
| Momentum | RSI 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:
- OnNewCandle on your timeframe, so each decision uses a closed bar.
- A Technical Indicator node set to RSI — period 14, applied price close.
- A Variable
prevRsi, and at the end of every candle a Set Variable that stores the current RSI in it for the next bar. - Two Comparison nodes —
prevRsi < 30andRSI ≥ 30— plus a Positions & Orders count compared with 0, all into an AND. - A BUY Order with stop loss and take profit in points.
- 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
Moving Average Crossover EA for MT5 and MT4: Build It Free
Build a moving average crossover EA without code — detecting the cross correctly, one trade at a time, exits, a trend filter, and settings as inputs.
4 min readConvert a TradingView Strategy to an MT5 Expert Advisor
Two ways to take a Pine Script strategy to MetaTrader 5 — a webhook bridge or a native rebuild — what each costs, and why results never match exactly.
4 min readIndicator to EA: Turn Any MT4/MT5 Indicator Into a Robot
Turn a built-in or custom indicator into an Expert Advisor without code — reading buffers, arrow indicators, the repainting trap, and what a converter can't do.
4 min read