This tool is designed to help traders visualize market momentum and volatility by adding a sophisticated "dynamic" layer to the traditional Relative Strength Index (RSI). While a standard RSI tells you if an asset is potentially overbought or oversold, this script adds a layer of statistical boundaries that adjust automatically based on recent price action.
How it Works
The logic operates in three distinct stages:
1. Measuring Momentum (The Core RSI) At its foundation, the script calculates the Relative Strength Index. This measures the speed and change of price movements. It identifies whether the market is pushing strongly in one direction or if the momentum is beginning to fade.
2. Establishing a Moving Average Instead of just looking at the raw RSI value, the script takes the RSI data over a specific period (the "Band Period") and calculates its average. This smooths out the noise, allowing you to see the underlying trend of the momentum rather than reacting to every tiny price flick.
3. Creating Dynamic Boundaries (The Zones) This is where the unique logic resides. The script calculates the "Standard Deviation"—a mathematical measure of how much the price typically fluctuates from its average.
Using this calculation, it creates two dynamic boundaries:
- An Upper Zone: Set above the average momentum based on a specific statistical multiplier.
- A Lower Zone: Set below the average momentum using the same logic.
What This Means for the Trader
Because these zones are based on Standard Deviation, they are not "fixed" numbers like 70 or 30. They expand when the market is highly volatile and contract when the market is calm.
By watching where the RSI line moves in relation to these dynamic zones, you can better identify extreme moves. When the RSI pushes outside of these calculated bands, it signals that the current momentum is statistically unusual compared to recent history, potentially highlighting high-probability entry or exit points for a trade.
//+------------------------------------------------------------------+
//| Dynamic Zone RSI.mq4 |
//| Copyright © 2005, Pavel Kulko. |
//| polk@alba.dp.ua |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Pavel Kulko"
#property link "polk@alba.dp.ua"
#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 SlateBlue
#property indicator_color3 Orange
#property indicator_separate_window
extern int RSIPeriod = 5;
extern int BandPeriod = 30;
double RSIBuf[],UpZone[],DnZone[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(0,RSIBuf);
SetIndexBuffer(1,UpZone);
SetIndexBuffer(2,DnZone);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double MA, RSI[];
ArrayResize(RSI,BandPeriod);
int counted_bars=IndicatorCounted();
int limit = Bars-counted_bars-1;
for(int i=limit; i>=0; i--)
{
RSIBuf[i] = iRSI(NULL,0,RSIPeriod,MODE_CLOSE,i);
MA = 0;
for(int j=i; j<i+BandPeriod; j++) {
RSI[j-i] = RSIBuf[j];
MA += RSIBuf[j]/BandPeriod;
}
UpZone[i] = MA + (1.3185 * StDev(RSI,BandPeriod));
DnZone[i] = MA - (1.3185 * StDev(RSI,BandPeriod));
}
//----
return(0);
}
double StDev(double& Data[], int Per)
{
return(MathSqrt(Variance(Data,Per)));
}
double Variance(double& Data[], int Per)
{
double sum, ssum;
for (int i=0; i<Per; i++)
{
sum += Data[i];
ssum += MathPow(Data[i],2);
}
return((ssum*Per - sum*sum)/(Per*(Per-1)));
}
//+------------------------------------------------------------------+
Comments