Flat_Trend_RSI

Download script
Author: Copyright � 2006, Forex-TSD.com
Flat_Trend_RSI

This tool is designed as a visual aid to help traders identify the underlying momentum of a market and filter potential trade entries based on the Relative Strength Index (RSI). Instead of showing standard price movements, it provides a simplified view of "Up" and "Down" trends to help users decide when to take action.

How the Logic Works

The script analyzes price data over a specific period (defaulting to 14 cycles) to determine if the market is experiencing significant strength or weakness. It categorizes these movements into three distinct phases:

1. Trend Identification The tool continuously monitors the RSI value to establish a "trend state."

  • If the momentum pushes above a high threshold (70), the system identifies a potential Upward Trend.
  • If the momentum drops below a low threshold (30), the system identifies a potential Downward Trend.

2. Filtering for Trade Clarity To prevent traders from entering a position too late or during "noisy" price action, the script applies a secondary filter:

  • Upward Trends: For an upward trend to be visually confirmed, the momentum must remain above a mid-point (40). If it falls below this, the signal is cleared.
  • Downward Trends: For a downward trend to be visually confirmed, the momentum must stay below a mid-point (60). If it rises above this, the signal is cleared.

Visual Representation

The tool communicates these findings using two distinct visual bars in a separate window:

  • UpTrend Signals: These appear when the market shows sustained upward momentum that meets the specific filtering criteria.
  • DownTrend Signals: These appear when the market shows sustained downward momentum that meets the specific filtering criteria.

By using this logic, the script acts as a "filter," highlighting only the most reliable trend movements while ignoring minor price fluctuations that do not meet the required strength levels. This helps traders focus on high-probability trends rather than reacting to every small movement in the market.

Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1
9 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[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
  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);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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