StepRSI_v5.2_v1

Download script
Author: Copyright � 2006, Forex-TSD.com
StepRSI_v5.2_v1

The StepRSI tool is a specialized technical analysis indicator designed to help traders identify market trends and momentum by blending the principles of a Relative Strength Index (RSI) with a unique "staircase" smoothing logic.

Instead of showing a standard oscillating line that moves up and down constantly, this script processes price data to create a structured visual representation of market movement. Here is a breakdown of how the logic works:

1. Momentum Foundation

The core of the indicator begins by analyzing the relationship between price changes over a specific timeframe (the RSI Period). It calculates the difference between moving averages to determine whether the market is experiencing positive or negative momentum. This data is then converted into a value that helps define the current "strength" of the price movement.

2. Trend Identification

Unlike standard indicators that simply react to every tick, this script looks for definitive shifts in direction. It establishes a "Trend" state based on specific price boundaries. By comparing the current momentum against previous peaks and valleys, it determines whether the market is currently in an upward or downward phase.

3. The "Step" Mechanism

The defining characteristic of this indicator is its Step Calculation. Rather than allowing the line to move freely, the logic applies a "Step Size." This creates a staircase effect:

  • In an Uptrend: The indicator tracks the lowest point reached and adds a specific step value, creating a series of flat plateaus that climb upward.
  • In a Downtrend: The indicator tracks the highest point reached and subtracts a specific step value, creating flat plateaus that descend.

4. Visual Smoothing

By utilizing this staircase logic, the indicator filters out "market noise"—the small, insignificant price fluctuations that often cause traders to see false signals. It creates a cleaner visual path that highlights the primary direction of the market. This allows users to see the overarching trend more clearly, as the line only moves when the momentum is strong enough to overcome the established step threshold.

Summary for the User

Essentially, this tool takes the raw volatility of the market and translates it into a structured, stepped path. It tells you not just how much the price is moving, but confirms the structural direction of that movement by smoothing out minor fluctuations into clear, readable levels.

Indicators Used
Moving average indicatorRelative strength index
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
StepRSI_v5.2_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                 StepRSI_v5.2.mq4 |
//|                                  Copyright © 2006, Forex-TSD.com |
//|                         Written by IgorAD,igorad2003@yahoo.co.uk |   
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |                                      
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"

#property indicator_separate_window
#property indicator_minimum 20
#property indicator_maximum 80
#property indicator_level1 40
#property indicator_level2 60
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Yellow
//---- input parameters
extern int RSIPeriod=14;
extern double StepSize=5;
extern int MAPeriod=1;
extern int Price=0;
extern int Mode=1;
//---- buffers
double RSIBuffer[];
double FastBuffer[];
double trend[];
double smax[],smin[];

int limit; 
//---- StepMA Calculation   
      
   double StepMACalc (double Size, int k)
   {
   int count, counted_bars=IndicatorCounted();
   double result;
   	
	  smax[k]=RSIBuffer[k] +2.0*Size;
	  smin[k]=RSIBuffer[k] -2.0*Size;
     
	  trend[k]=trend[k+1];   
	  
	  if (trend[k+1]<=0 && RSIBuffer[k]>smax[k+1]) trend[k]=1;   
	 
	  if (trend[k+1]>=0 && RSIBuffer[k]<smin[k+1]) trend[k]=-1;  
	 
	  if(trend[k]>0)
	  {
	  if(smin[k]<smin[k+1]) smin[k]=smin[k+1];
	  result=smin[k]+Size;
	  
	  } 
	  else
	  if(trend[k]<0)
	  {
	  if(smax[k]>smax[k+1]) smax[k]=smax[k+1];
	  result=smax[k]-Size;
	  }
     return(result); 
     } 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,RSIBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,FastBuffer);
   SetIndexBuffer(2,smin);
   SetIndexBuffer(3,smax);
   SetIndexBuffer(4,trend);
//---- name for DataWindow and indicator subwindow label
   short_name="StepRSI("+RSIPeriod+","+MAPeriod+","+Price+","+DoubleToStr(StepSize,1)+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetIndexLabel(1,"Fast");   
//----
   
   SetIndexDrawBegin(0,RSIPeriod);
   SetIndexDrawBegin(1,RSIPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| StepRSI_v5.2                                                       |
//+------------------------------------------------------------------+
int start()
  {
   int    count,i,counted_bars=IndicatorCounted();
   double rel,negative,positive;
//----
   if(Bars<=RSIPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=RSIPeriod;i++) 
      {RSIBuffer[Bars-i]=0.0;FastBuffer[Bars-i]=0.0;}
//----
   if ( counted_bars > 0 )  limit=Bars-counted_bars;
   if ( counted_bars ==0 )  limit=Bars-RSIPeriod-1; 
   
   for(i=limit;i>=0;i--) 
   {	 
      
      double sumn=0.0,sump=0.0;
      for (int k=RSIPeriod-1;k>=0;k--)
           { 
            rel=iMA(NULL,0,MAPeriod,0,MODE_SMA,Price,i+k)-iMA(NULL,0,MAPeriod,0,MODE_SMA,Price,i+k+1);
            if(rel>0) sump+=rel;
            else      sumn-=rel;
           }
         positive=sump/RSIPeriod;
         negative=sumn/RSIPeriod;
      
      if (Mode==1)
      {
      if(negative==0.0) RSIBuffer[i]=100.0;
      else 
      RSIBuffer[i]=100.0-100.0/(1.0+positive/negative);
      }
      else
      RSIBuffer[i]=iRSI(NULL,0,RSIPeriod,Price,i);
      FastBuffer[i]=StepMACalc(StepSize,i);
	}
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments