This script is a specialized technical analysis tool designed to help traders identify momentum and potential trend reversals in financial markets. It enhances the standard Relative Strength Index (RSI)—a common momentum oscillator—by adding dynamic "step" boundaries that visualize market strength and structural shifts.
Core Concept
While a standard RSI shows you how fast and in what direction an asset is moving, this tool adds two distinct layers of visual information to help filter out noise. It creates three separate lines on your chart: the base RSI value, a "fast" step boundary, and a "slow" step boundary.
How the Logic Works
The script operates by analyzing price movement over a specific period and applying two different sensitivities (Fast and Slow) to identify trends:
- Trend Detection: The logic constantly monitors whether the current RSI is breaking above or below specific thresholds based on your chosen "Step Size." If the value pushes past these thresholds, the tool registers a trend direction (upward or downward).
- Dynamic Boundaries: Instead of using static horizontal lines (like the traditional 70 or 30 levels), this script creates dynamic boundaries that "stretch" and move with the market.
- The Fast Step reacts quickly to minor price fluctuations, providing a high-sensitivity view of current momentum.
- The Slow Step reacts more gradually to larger price moves, helping you see the broader underlying trend.
- Smart Tracking: The script has a "memory" feature. Once it identifies a trend direction, it tracks the highest and lowest points reached during that move. This ensures that the boundaries remain consistent as long as the trend continues, only shifting when a significant enough price action forces a change in direction.
Visual Interpretation
The three lines provide a multi-layered perspective on market behavior:
- The Primary RSI: Shows the immediate "heartbeat" of the price movement.
- Fast Step Line: Helps identify short-term momentum shifts and potential early signs of exhaustion.
- Slow Step Line: Acts as a stabilizer, helping you stay on the right side of the primary trend and identifying significant structural changes in the market.
By using these three layers together, the tool allows you to see not just where the price is going now, but how much "room" it has left to move before the current momentum potentially loses its strength.
//+------------------------------------------------------------------+
//| StepRSI_v2.mq4 |
//| Copyright © 2005, TrendLaboratory Ltd. |
//| E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, TrendLaboratory Ltd."
#property link "E-mail: igorad2004@list.ru"
//----
#property indicator_separate_window
#property indicator_minimum 20
#property indicator_maximum 80
#property indicator_buffers 3
#property indicator_color1 Orange
#property indicator_color2 SkyBlue
#property indicator_color3 Magenta
//---- input parameters
extern int PeriodRSI=14;
extern int StepSizeFast=5;
extern int StepSizeSlow=15;
//extern int HighLow=0;
//---- indicator buffers
double Line1Buffer[];
double Line2Buffer[];
double Line3Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(0,Line1Buffer);
SetIndexBuffer(1,Line2Buffer);
SetIndexBuffer(2,Line3Buffer);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
short_name="METRO("+PeriodRSI+","+StepSizeFast+","+StepSizeSlow+")";
IndicatorShortName(short_name);
SetIndexLabel(0,"RSI");
SetIndexLabel(1,"StepRSI fast");
SetIndexLabel(2,"StepRSI slow");
//----
SetIndexDrawBegin(0,1);
SetIndexDrawBegin(1,1);
SetIndexDrawBegin(2,1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| StepRSI_v2 |
//+------------------------------------------------------------------+
int start()
{
int shift,ftrend,strend;
double fmin0,fmax0,fmin1,fmax1,smin0,smax0,smin1,smax1,RSI0;
//----
for(shift=Bars-1;shift>=0;shift--)
{
RSI0=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,shift);
fmax0=RSI0+2*StepSizeFast;
fmin0=RSI0-2*StepSizeFast;
//----
if (RSI0>fmax1) ftrend=1;
if (RSI0<fmin1) ftrend=-1;
if(ftrend>0 && fmin0<fmin1) fmin0=fmin1;
if(ftrend<0 && fmax0>fmax1) fmax0=fmax1;
//----
smax0=RSI0+2*StepSizeSlow;
smin0=RSI0-2*StepSizeSlow;
//----
if (RSI0>smax1) strend=1;
if (RSI0<smin1) strend=-1;
if(strend>0 && smin0<smin1) smin0=smin1;
if(strend<0 && smax0>smax1) smax0=smax1;
Line1Buffer[shift]=RSI0;
//----
if (ftrend>0) Line2Buffer[shift]=fmin0+StepSizeFast;
if (ftrend<0) Line2Buffer[shift]=fmax0-StepSizeFast;
if (strend>0) Line3Buffer[shift]=smin0+StepSizeSlow;
if (strend<0) Line3Buffer[shift]=smax0-StepSizeSlow;
//----
fmin1=fmin0;
fmax1=fmax0;
smin1=smin0;
smax1=smax0;
}
return(0);
}
//+------------------------------------------------------------------+
Comments