RSI_Coloured_Final_v1

Download script
Author: TheXpert

This technical tool is designed to provide a more nuanced visualization of the Relative Strength Index (RSI), a popular momentum oscillator used by traders to identify whether an asset is overbought or oversold. Instead of simply showing a standard line, this script focuses on highlighting specific price action behaviors when they breach predefined "High" and "Low" thresholds.

Core Functionality

The indicator works by monitoring the RSI values against two customizable boundaries (typically set at 70 for overbought conditions and 30 for oversold conditions). Its primary goal is to isolate and visually emphasize the exact moments when the market momentum crosses into these extreme zones.

Key Features and Logic:

  • Threshold Detection: The script constantly calculates the RSI based on your preferred price type (such as Close, Open, High, or Low prices). It then tracks whether the momentum is pushing above the high limit or dropping below the low limit.
  • Signal Visualization: Unlike a standard indicator that shows a continuous line, this tool identifies specific "peaks" and "valleys." When the RSI exceeds the set limits, the script generates distinct visual signals. It looks at the relationship between the current price point and the previous one to determine if a trend is continuing into extreme territory or starting to retract.
  • Customizable Transparency: The logic includes a specific toggle for "Transparency."
    • When enabled, it provides a cleaner look by only showing the RSI line relative to the thresholds.
    • When disabled, it employs a "shadowing" logic that creates a visual bridge between the price action and the threshold levels, making it easier to see how deeply or quickly the momentum is penetrating into overbought or oversold territory.
  • Signal Smoothing: The tool includes an internal logic check (depth) that can be toggled to influence how many previous data points are analyzed when determining a signal. This helps in filtering out minor fluctuations to focus on more significant price movements.

Summary for the User

In simple terms, this script acts as a "magnifying glass" for extreme market conditions. Rather than just telling you that the market is "hot" or "cold," it highlights the specific points where momentum breaks out of its normal range, allowing you to see exactly how much force is behind a move into overextended territory.

Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1
13 Views
1 Downloads
0 Favorites
RSI_Coloured_Final_v1
#property copyright "TheXpert"
#property link      "theforexpert@gmail.com"

#property indicator_separate_window

#property indicator_maximum 100
#property indicator_minimum 0

#property indicator_buffers 3

#property indicator_color1 DeepSkyBlue
#property indicator_color2 Red
#property indicator_color3 Khaki

//---- input parameters
extern string  RSIPeriod_Desc    =  "Ïåðèîä RSI";
extern int     RSIPeriod         =  14;
extern string  RSIPrice_Desc     =  "Öåíà RSI: 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted";
extern int     RSIPrice          =  0;
extern string  HighLevel_Desc    =  "Âåðõíèé óðîâåíü RSI";
extern int     HighLevel         =  70;
extern string  LowLevel_Desc     =  "Íèæíèé óðîâåíü RSI";
extern int     LowLevel          =  30;
extern string  MarkFalse_Desc    =  "Ìàðêèðîâàòü èëè íåò áàðû, êîòîðûå ïðè ôîðìèðîâàíèè çàëàçèëè çà óðîâíè";
extern bool    MarkFalse         =  false;
extern string  Transparent_Desc  =  "Ðèñîâàòü RSI ïîâåðõ öâåòíûõ óðîâíåé";
extern bool    Transparent       =  true;
extern string  Width_Desc        =  "Øèðèíà ñèãíàëüíûõ ëèíèé";
extern int     Width             =  3;
      
//---- buffers
double RSI[];
double Inner[];
double Higher[];
double Lower[];


/// \brief Equal to ternar operator 
/// needed = Condition ? IfTrue : IfFalse;
/// \param IfTrue
/// \param IfFalse
/// \return matching value from parameters
double DoubleIf(bool Condition, double IfTrue, double IfFalse)
{
   if (Condition) return (IfTrue);
   else           return (IfFalse);
}

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   IndicatorBuffers(4);

   SetIndexBuffer(0, Higher);
   SetIndexBuffer(1, Lower);
   SetIndexBuffer(2, Inner);

   SetIndexBuffer(3, RSI);
   
   SetLevelValue(0, HighLevel);
   SetLevelValue(1, LowLevel);
   
   SetIndexLabel(0, "RSI");
   SetIndexLabel(1, "Âûøå óðîâíÿ");
   SetIndexLabel(2, "Íèæå óðîâíÿ");
   
   SetIndexStyle(0, DRAW_LINE, EMPTY, Width);
   SetIndexStyle(1, DRAW_LINE, EMPTY, Width);

   SetIndexDrawBegin(0, RSIPeriod + 1);
   SetIndexDrawBegin(1, RSIPeriod + 1);
   SetIndexDrawBegin(2, RSIPeriod + 1);   
   
   IndicatorShortName("Öâåòíîé RSI");
   
   IndicatorDigits(2);

   return(0);
}

int start()
{
  int counted_bars = IndicatorCounted();
  if(counted_bars < 0)  return(-1);
  if(counted_bars > 0)   counted_bars--;
  int ToCount = Bars - counted_bars;
  if(counted_bars==0) ToCount-=2;
   
   for (int cnt = ToCount - 1; cnt >= 0; cnt--)
   {
      RSI[cnt] = iRSI(NULL, 0, RSIPeriod, RSIPrice, cnt);

      int depth = 2;
      if (MarkFalse)
      {
         depth = 1;
      }
      
      for (int i = cnt + depth - 1; i >= cnt; i--)
      {
         Higher[i] = EMPTY_VALUE;
         Lower[i] = EMPTY_VALUE;
      
         Inner[i] = RSI[i];
   
         if (!Transparent)
         {
            if (RSI[i] <= LowLevel)
            {
               Inner[i] = DoubleIf(RSI[i + 1] > LowLevel, LowLevel, EMPTY_VALUE);
            }
            else
            {
               Inner[i] = DoubleIf(RSI[i + 1] <= LowLevel, LowLevel, RSI[i]);
            }
   
   
            if (RSI[i] >= HighLevel)
            {
               Inner[i] = DoubleIf(RSI[i + 1] < HighLevel, HighLevel, EMPTY_VALUE);
            }
            else 
            {
               Inner[i] = DoubleIf(RSI[i + 1] >= HighLevel, HighLevel, Inner[i]);
            }
         }
         
         if(RSI[i] >= HighLevel)
         {
            Higher[i] = RSI[i];
            Higher[i + 1] = DoubleIf(RSI[i + 1] >= HighLevel, RSI[i + 1], HighLevel);
         }
         else if(RSI[i + 1] >= HighLevel)
         {
            Higher[i] = HighLevel;
            Higher[i + 1] = RSI[i + 1];
         }   


         if(RSI[i] <= LowLevel)
         {
            Lower[i] = RSI[i];
            Lower[i + 1] = DoubleIf(RSI[i + 1] <= LowLevel, RSI[i + 1], LowLevel);
         }
         else if(RSI[i + 1] <= LowLevel)
         {
            Lower[i] = LowLevel;
            Lower[i + 1] = RSI[i + 1];
         }   
      }
   }
   
   return(0);
}

Comments