RSI with MA and Divergence
- Indicadores
-
Alexandru Dumitru
MQL5 Developer | Expert Advisors & Custom Indicators
Hi, I'm Alexandru!
I'm an active trader with programming experience, and I enjoy developing tools that make trading easier, more efficient, and better organized. - Versão: 1.0
RSI with MA and Divergence is a technical indicator for MetaTrader 5 that combines the Relative Strength Index (RSI), moving-average smoothing, optional Bollinger Bands, and regular bullish and bearish divergence detection in a single indicator window.
It is designed for traders who want to examine market momentum, identify overbought and oversold conditions, and compare RSI behavior with price movements.
The indicator includes customizable levels, visual highlights, optional divergence alerts, and several display settings.
Main features
-
RSI with adjustable period, applied price, and overbought/oversold levels.
-
Seven smoothing modes: None, SMA, SMA with Bollinger Bands, EMA, SMMA (RMA), WMA, and VWMA.
-
Optional Bollinger Bands calculated from RSI values.
-
Regular bullish and bearish divergence detection using confirmed RSI pivots.
-
Divergence lines, Bull/Bear labels, and colored RSI highlights.
-
Optional pop-up alerts when new divergences are confirmed.
-
Background shading, overbought highlighting, current-value labels, and adjustable vertical scaling.
RSI and smoothing
The default RSI period is 14, using Close Price, with overbought and oversold levels set to 70 and 30. A reference level of 50 is also available.
Overbought and oversold conditions help describe momentum, but they do not necessarily indicate an immediate price reversal. RSI can remain above 70 or below 30 during sustained trends.
Moving-average smoothing is applied directly to RSI values rather than market prices.
SMA provides simple averaging, EMA responds more strongly to recent values, SMMA applies Wilder-style smoothing, and WMA uses linearly weighted observations.
VWMA weights RSI values by volume. It uses real volume when available and tick volume otherwise, so results may vary between brokers and instruments.
The SMA with Bollinger Bands mode adds upper and lower bands around the smoothed RSI. The default smoothing period is 14 and the Bollinger Band multiplier is 2.0. Optional shading can be displayed between the bands.
These tools can help visualize changes in momentum and RSI volatility. They are not automatic trading signals.
Regular divergence detection
The indicator can identify two types of regular RSI divergence.
A bullish divergence occurs when price forms a lower low while RSI forms a higher low at the corresponding confirmed pivot locations.
A bearish divergence occurs when price forms a higher high while RSI forms a lower high at the corresponding confirmed pivot locations.
When a divergence is detected, the indicator can draw a line between the compared RSI pivots, display a Bull or Bear label, and highlight the relevant RSI area.
Divergence calculation is disabled by default and can be enabled in the Inputs tab.
How divergence confirmation works
Divergence signals require confirmation. They are not available at the exact moment a potential pivot appears.
The indicator waits for the configured number of bars to close on the right side of a pivot before evaluating it. For example, with Pivot Right Bars set to 5, the required five right-side bars must close before the pivot can be confirmed.
After confirmation, the divergence marker is drawn at the historical pivot location. This means the marker may appear several bars before the time when the divergence actually became available.
When reviewing historical charts, do not confuse the marker's position with the confirmation time.
The default divergence settings use 5 left bars, 5 right bars, a minimum pivot distance of 5 bars, and a maximum distance of 60 bars.
You can also adjust line thickness, label size, RSI highlight width, highlight radius, and the historical drawing range. The default drawing range is 1600 bars.
Divergences can indicate changes in momentum, but they do not guarantee reversals or profitable trades.
Display and configuration
The indicator includes optional background shading between the selected overbought and oversold levels.
When the overbought fill option is enabled, the area between RSI and the upper threshold is highlighted in green whenever RSI exceeds that threshold. For example, changing the threshold from 70 to 75 also changes where the highlighting begins.
Current RSI and applicable moving-average values can be displayed on the right side of the indicator window. The dimensions and font size of these labels are adjustable.
The vertical scale supports four modes: Fixed 0-100, Fixed Custom Range, MT5 Automatic Scale, and MT5 Manual Scale.
Fixed 0-100 is the default.
Important configuration note
For consistent results, configure the indicator primarily through the Inputs tab.
To change functional overbought and oversold thresholds, use the Overbought Level and Oversold Level parameters under RSI Settings.
The standard MetaTrader 5 Levels tab changes native visual levels but does not update the indicator's internal thresholds used for background shading and overbought highlighting.
Likewise, the standard Colors and Scale tabs contain native display properties that may operate independently of the indicator's internal settings.
For the intended default appearance, leave the standard Colors, Levels, and Scale tabs unchanged and use Inputs for configuration.
The exception is MT5 Manual Scale mode, where the native Scale tab can be used for manual adjustments.
Alerts
Optional divergence alerts are generated through MetaTrader 5's built-in pop-up alert system after a new regular divergence is confirmed.
To use alerts, enable both Calculate Regular Divergence and Enable Divergence Alerts in Inputs, and keep the indicator running in MetaTrader 5.
This version does not include email alerts or mobile push notifications.
Installation and use
Install the indicator from MQL5 Market, open a chart in MetaTrader 5, and attach it from the Navigator panel.
The indicator will appear in a separate window below the price chart.
Open Inputs to adjust the RSI calculation, smoothing method, display settings, divergence detection, and alerts.
A conventional starting configuration is RSI 14, Close Price, overbought level 70, oversold level 30, SMA smoothing with period 14, and Fixed 0-100 scale. Divergence detection is disabled by default and can be enabled when needed.
The indicator can be used with different symbols and timeframes, subject to the historical data available from the broker.
Limitations and support
RSI with MA and Divergence is an analytical indicator, not an Expert Advisor. It does not execute or manage trades and does not require automatic trading permissions.
Its signals are intended to support market analysis rather than provide guaranteed entry or exit points. Divergence confirmation requires additional closed bars, and historical markers should be interpreted accordingly.
Indicator values may differ between brokers because of pricing, volume availability, and historical data.
For questions or technical issues, please contact me through MQL5 Messages or the product's Comments section. When reporting a problem, include the MetaTrader 5 build, symbol, timeframe, relevant input settings, and a screenshot if possible.
Trading involves risk, and past market behavior does not guarantee future results.
