Flat Trend RSI

Author: Copyright � 2006, Forex-TSD.com
Flat Trend RSI

This tool is designed to help traders visualize and filter market trends by analyzing the Relative Strength Index (RSI), a common momentum oscillator. Instead of showing you the raw RSI numbers, this script translates that data into a simplified visual signal that helps identify "Up" and "Down" zones on your chart.

How the Logic Works

The tool functions by monitoring the price action over a specific timeframe (set by the PeriodRSI) and categorizing the market momentum into three distinct states:

1. Identifying Extreme Momentum The script first looks for "overbought" or "oversold" conditions. It treats the market as being in a strong upward trend if the RSI climbs above 70, and in a strong downward trend if it falls below 30. These levels act as the primary triggers for the tool's logic.

2. Filtering the Trend Once a trend direction is identified, the tool applies a secondary filter to ensure the signals remain relevant:

  • Upward Trends: If the market is flagged as trending up (exceeding 70), the script checks if the RSI remains above 40. If it does, it marks this as a valid "Up" zone.
  • Downward Trends: If the market is flagged as trending down (falling below 30), the script checks if the RSI remains below 60. If it does, it marks this as a valid "Down" zone.

Visual Representation

The results are displayed in a separate window on your trading platform as a histogram:

  • Upward Signals: Represented by blue bars when the upward momentum conditions are met.
  • Downward Signals: Represented by red bars when the downward momentum conditions are met.

By using these filters, the tool aims to help you stay aligned with the prevailing market direction while filtering out "noise" or minor fluctuations that do not represent a significant move in price.

Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
Flat Trend RSI
///+------------------------------------------------------------------

//|                                                 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