$ £ ¥
¥ £ $

MT5 RSI Expert Advisor

RSI expert advisor is a simple MT5 expert advisor that implements an oversold/overbought trading strategy based on the Relative Strength Index (RSI) indicator. It was created using the MT5 expert advisor template. This RSI EA hasn't undergone any optimization. By default, it doesn't use any stop-loss or take-profit levels, exiting positions on opposite signals. This means that the expert advisor should always remain activated in order to be able to close its running trades.

MT5 RSI Expert Advisor

 

Warning! This expert advisor is a proof of concept for an RSI EA based on our MT5 expert advisor template. It's likely to produce losses if you run it on your trading account. Recommended usage: EA development based on RSI strategies, backtesting and optimization of risk-management and exit strategies.

How RSI expert advisor works

The condition for this EA to buy is for the RSI indicator to close above the oversold level (20 by default) after having previously closed below or at that level.

The condition for this EA to sell is for the RSI indicator to close below the overbought level (80 by default) after having previously closed above or at that level.

An opposite signal closes the current position as well.

You can see some examples of entries and exits generated by this RSI strategy:

RSI Expert Advisor - Examples of Entries and Exits

Input parameters

Despite its simplicity, this MT5 RSI expert advisor has a wide range of input parameters that let you adjust its settings according to your preferences:

RSI Expert Advisor - Input Parameters

How it was made

This RSI expert advisor is based on our MT5 EA template with minimal changes applied. Apart from the changes to the EA's basic properties (description, link), there were the following changes:

  1. Added RSI indicator input parameters:
input int RSIPeriod = 14;                        // RSI period
input double RSIOverbought = 80;                 // RSI overbought level
input double RSIOversold = 20;                   // RSI oversold level
input ENUM_APPLIED_PRICE RSIPrice = PRICE_CLOSE; // RSI applied price
 
  1. Uncommented the lines that make it so that the entry conditions are checked only once per bar.
  2. Uncommented the lines of code for reading main indicator values and changed it to work with RSI instead of MA:
IndicatorHandle = iRSI(Symbol(), Period(), RSIPeriod, RSIPrice);
 
  1. Uncommented and changed the lines for determining the entry signals:
if ((Indicator_current > RSIOversold) && (Indicator_previous <= RSIOversold)) BuySignal = true; // Check if the RSI crossed the oversold level from below.
if ((Indicator_current < RSIOverbought) && (Indicator_previous >= RSIOverbought)) SellSignal = true; // Check if the RSI crossed the overbought level from above.
 
  1. Uncommented and changed the lines for determining the exit signals:
if ((Indicator_current > RSIOversold) && (Indicator_previous <= RSIOversold)) SignalExitShort = true; // Check if the RSI crossed the oversold level from below.
else if ((Indicator_current < RSIOverbought) && (Indicator_previous >= RSIOverbought)) SignalExitLong = true; // Check if the RSI crossed the overbought level from above.
 

As you can see, the template EA offers a solid starting platform for building a working expert advisor. By just adding 4 lines, modifying 5 lines, and uncommenting 4 sections, a completely functional RSI EA with multiple features was created for use in MetaTrader 5.

Backtest results

A backtest of this RSI MT5 expert advisor showed the following results on a EUR/USD M5 chart: $453 profit and $1,211 maximum drawdown in a 3-year period. The test was using default values for its input parameters and 0.1 lot as its position size. These results aren't great and are provided just to demonstrate how an average RSI system performs.

RSI Expert Advisor - Backtesting Results - Balance Chart


MiniFAQ

What stop-loss and take-profit does this EA use?

By default, it doesn't use any stop-loss or take-profit values. The EA exits based on opposite direction signals, but you can configure it to use either fixed or ATR-based SL and TP.

How often does it trade?

On the M5 EUR/USD chart (our backtesting setup), this EA will trade about 7 times per month on average when using the default settings.

Downloads

How to install MT5 RSI expert advisor

  1. Download the expert advisor archive file.
  2. Open the MetaTrader 5 data folder (via File→Open Data Folder or Ctrl+Shift+D).
  3. Open the MQL5 folder.
  4. Copy all the folders from the archive directly to the MQL5 folder.
  5. Restart MetaTrader 5 or refresh the expert advisors list by right-clicking the Navigator subwindow of the platform and choosing Refresh.

Discussion

Do you have your own trading results or any other remarks regarding this expert advisor?

Discuss RSI expert advisor with other traders and MQL5 programmers on the forum.