Waddah_Attar_Def_RSI
Download scriptThis custom indicator is designed to help traders identify market momentum and trend strength by comparing two different speeds of price movement. Instead of looking at raw price alone, it analyzes the "Relative Strength Index" (RSI), which is a common tool used to measure how fast and how far an asset's price is moving.
How the Logic Works
1. Dual-Speed Analysis The script tracks two different RSI values simultaneously. One value looks at a shorter period of time (fast movement), while the other looks at a longer period of time (slower, broader movement). By calculating both, the tool can distinguish between temporary price fluctuations and more established trends.
2. Calculating the Gap The core "engine" of this script involves finding the difference between these two RSI values. By subtracting the slower, long-term data from the faster, short-term data, the indicator identifies the "gap" or "spread" between current momentum and the overall historical trend.
3. Smoothing the Results Because raw price differences can often be "noisy" or jump around erratically (which can lead to false signals), the script applies a final smoothing layer. It takes the calculated differences and runs them through a Simple Moving Average (SMA). This produces a much cleaner, more stable line on your chart.
What this means for the trader
The resulting visual output provides a smoothed representation of the relationship between short-term and long-term momentum. Rather than reacting to every tiny wiggle in the market, this logic filters out the noise to show you a clearer picture of whether the current momentum is strengthening or weakening relative to its recent history.
//+------------------------------------------------------------------+
//| 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
//----
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