Dynamic Zone RSI

Download script
Author: Copyright � 2005, Pavel Kulko
Dynamic Zone RSI

This script is designed to provide traders with a more sophisticated way to view market momentum by combining two well-known financial concepts: the Relative Strength Index (RSI) and dynamic volatility bands. Instead of looking at a standard RSI line in isolation, this tool creates a "channel" that adapts automatically to current market conditions.

How the Logic Works

1. Momentum Tracking (The Core) At its foundation, the script calculates the Relative Strength Index (RSI). This is a standard momentum oscillator that measures the speed and change of price movements. It helps traders understand whether an asset is being bought aggressively or sold off rapidly.

2. Dynamic Averaging Rather than simply plotting the raw RSI value, the script calculates a moving average of that RSI over a specific timeframe. This smooths out minor "noise" in the market data, allowing the user to see the underlying trend of the momentum more clearly.

3. Volatility-Based Boundaries (The "Zones") The most unique feature of this logic is how it creates the upper and lower boundaries (the zones). It calculates the "Standard Deviation"—a mathematical measure of how much the price typically fluctuates away from its average.

By applying this calculation to the RSI values:

  • The Upper Zone: The script identifies a ceiling based on how volatile the momentum currently is.
  • The Lower Zone: The script identifies a floor based on that same volatility.

The Practical Result

Because these zones are calculated using standard deviation, they are not static lines. When the market is calm and moving steadily, the bands will tighten together. When the market becomes highly erratic or volatile, the bands will expand outward automatically.

For a trader, this means the indicator provides a visual representation of "overextended" momentum. When the RSI line pushes outside of these dynamically adjusted zones, it signals that the asset may be experiencing an unusual surge in strength or weakness relative to its recent history, potentially highlighting opportunities for reversal or trend exhaustion.

Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
Dynamic Zone RSI
//+------------------------------------------------------------------+
//|                                             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