Waddah Attar Def RSI
Download scriptThis custom technical indicator is designed to help traders identify market momentum and potential trend reversals by analyzing the relationship between two different Relative Strength Index (RSI) calculations.
Core Logic and Functionality
The script operates through a three-step mathematical process to filter out "market noise" and highlight significant price movements:
1. Dual RSI Comparison The indicator begins by calculating two separate Relative Strength Indices simultaneously. The first uses a shorter timeframe (defaulting to 14 periods), which is more sensitive to quick price changes. The second uses a longer timeframe (defaulting to 28 periods), which provides a broader view of the overall market trend.
2. Calculating the Variance Instead of showing you these two values separately, the script subtracts the long-term RSI value from the short-term RSI value. This calculation isolates the "gap" or "divergence" between the immediate price action and the long-term trend. By focusing on this difference, the indicator helps identify when short-term momentum is moving significantly faster or slower than the historical average.
3. Smoothing the Data To ensure the visual output is easy for a human to read—avoiding jagged lines that can cause confusion—the script applies a Simple Moving Average (SMA) to the calculated variance. This smoothing process cleans up the data, creating a more stable line on your chart.
Visual Representation
The result is displayed in a separate window on your trading platform as a two-toned line (Green and Red). By observing how this smoothed line fluctuates, traders can better gauge the strength of the current market move:
- When the short-term momentum pulls away significantly from the long-term trend, the indicator reflects that intensity.
- The smoothing ensures that only sustained shifts in momentum are highlighted, rather than minor, insignificant price flickers.
In summary, this tool simplifies complex data by comparing "fast" and "slow" market speeds, subtracting them to find the difference, and smoothing the result into a clear visual signal of market momentum.
//+------------------------------------------------------------------+
//| Waddah_Attar_Def_RSI.mq4 |
//| Copyright © 2007, Eng. Waddah Attar |
//| waddahattar@hotmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Eng. Waddah Attar"
#property link "waddahattar@hotmail.com"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
//----
extern int RSIPeriod1=14;
extern int RSIPeriod2=28;
double ind_buffer1[];
double MABuffer1[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
//----
SetIndexBuffer(0, ind_buffer1);
SetIndexBuffer(1, MABuffer1);
//----
IndicatorShortName("Waddah Attar Def RSI");
Comment("copyright waddahwttar@hotmail.com");
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
Comment("");
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double RSI1,RSI2,Explo;
int limit, i, counted_bars = IndicatorCounted();
//----
if(counted_bars < 0)
return(-1);
//----
if(counted_bars > 0)
counted_bars--;
limit = Bars - counted_bars;
//----
for(i = limit - 1; i >= 0; i--)
{
RSI1 = iRSI(NULL, 0, RSIPeriod1, PRICE_CLOSE, i);
RSI2 = iRSI(NULL, 0, RSIPeriod2, PRICE_CLOSE, i);
MABuffer1[i] = (RSI1-RSI2);
}
for(i = 0; i < Bars; i++)
{
ind_buffer1[i] = iMAOnArray(MABuffer1,0,14,0,MODE_SMA,i);
}
for(i = 0; i < Bars; i++)
{
MABuffer1[i]=0;
}
return(0);
}
//+------------------------------------------------------------------+
Comments