Flat Trend RSI_v1

Download script
Author: Copyright � 2006, Forex-TSD.com
Flat Trend RSI_v1

This tool is designed as a visual filter for traders who use the Relative Strength Index (RSI) to identify market momentum. Rather than just showing a standard oscillating line, this script interprets RSI data to highlight specific "zones" of interest, helping traders distinguish between active trends and potentially exhausted moves.

Core Logic Overview

The indicator monitors the RSI over a user-defined period (defaulting to 14 bars) to determine whether the market is showing upward or downward strength. It functions by categorizing market behavior into two distinct states based on specific price thresholds:

  • Trend Identification: The script first looks for extreme momentum. If the RSI climbs above 70, it flags an upward trend. Conversely, if the RSI drops below 30, it identifies a downward trend.
  • Filtering Mechanism: Once a trend is established, the script applies a secondary "filter" to ensure the signal remains relevant. It doesn't just flag every movement; it looks for specific conditions within those trends:
    • Upward Movement: In an identified uptrend, it highlights the data only if the RSI maintains a position above 40.
    • Downward Movement: In an identified downtrend, it highlights the data only if the RSI remains below 60.

Visual Representation

The script translates these calculations into a clear visual histogram on a separate window:

  • UpTrend Signals: Represented by one color (DeepSkyBlue), these appear when the market is showing consistent upward strength within the filtered parameters.
  • DownTrend Signals: Represented by another color (Red), these appear when the market is showing consistent downward strength within the filtered parameters.

How it Assists a Trader

The primary goal of this script is to provide a "cleaner" view of the market. By using these filters, the indicator effectively ignores "noisy" data—price movements that aren't strong enough to be considered part of a significant trend. It allows you to see at a glance when the market has enough momentum to sustain a move, specifically highlighting areas where the trend is still healthy versus areas where it might be losing steam or consolidating.

Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
Flat Trend RSI_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

///+------------------------------------------------------------------

//|                                                 RSIFilter_v1.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 -2
#property indicator_maximum 2
#property indicator_buffers 2
#property indicator_color1 DeepSkyBlue
#property indicator_color2 Red

//---- input parameters
extern int PeriodRSI=14;
//---- indicator buffers
double UpBuffer[];
double DnBuffer[];
//+------------------------------------------------------------------

//| Custom indicator initialization function                         

//+------------------------------------------------------------------

  int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexBuffer(0,UpBuffer);
   SetIndexBuffer(1,DnBuffer);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   short_name="RSI Filter("+PeriodRSI+")  (Down trade only when down bars are orange)";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"UpTrend");
   SetIndexLabel(1,"DownTrend");
//----
   SetIndexDrawBegin(0,PeriodRSI);
   SetIndexDrawBegin(1,PeriodRSI);
//----
   return(0);
  }

//+------------------------------------------------------------------

//| RSIFilter_v1                                                     

//+------------------------------------------------------------------

int start()
  {
   int shift,trend;
   double RSI0;

   
   for(shift=Bars-PeriodRSI-1;shift>=0;shift--)
   {	
   RSI0=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,shift);
   	
	  if (RSI0>70)  trend=1; 
	  if (RSI0<30)  trend=-1;
	  
	  if (trend>0) 
	  {
	  if (RSI0 > 40) UpBuffer[shift]=1.0;
	  else UpBuffer[shift] = EMPTY_VALUE;
	  DnBuffer[shift]=0;
	  }
	  if (trend<0) 
	  {
	  if (RSI0 < 60) DnBuffer[shift]=-1.0;
	  else DnBuffer[shift] = EMPTY_VALUE;
	  UpBuffer[shift]=0;
	  }
	}
	return(0);	
 }




//+------------------------------------------------------------------+

Comments