RSI-TC_NEW1

Download script
RSI-TC_NEW1

This indicator is designed to provide traders with a multi-layered visual and audible signal by combining momentum, volatility, and trend analysis. It goes beyond a standard Relative Strength Index (RSI) by filtering noise through specialized mathematical conditions to identify high-probability market entries.

Core Logic Overview

The script operates using three primary analytical layers:

1. Two-Tone Momentum Analysis (The RSI) The indicator tracks the RSI to determine the speed and change of price movements. Unlike a standard RSI, this version uses a "Two-tone" logic. It highlights specific momentum shifts by monitoring whether the price is moving into bullish or bearish territory relative to a 50% midpoint. This helps visually distinguish between active trends and periods of indecision.

2. Volatility Filtering (The Squeeze) To prevent false signals during "flat" markets, the script calculates the relationship between two different types of trading bands:

  • Bollinger Bands: Measure standard market volatility.
  • Keltner Channels: Measure smoothed volatility based on average true range.

When the Bollinger Bands contract inside the Keltner Channels, it identifies a "Squeeze"—a state where the market is coiled and preparing for a significant breakout. The script specifically looks for these periods of low volatility as precursors to major price moves.

3. Trend Breakout Detection (The Signals) The actual buy and sell signals are generated by looking for a specific convergence of all three factors:

  • Breakouts: It detects when the price "breaks out" of the compressed squeeze mentioned above.
  • Momentum Confirmation: It ensures the RSI is on the correct side of the 50% neutral line (above for buys, below for sells).
  • Sequential Validation: The logic checks for consecutive changes in the bands to ensure that a move is sustained and not just a momentary spike.

Visual and Audible Alerts

  • Buy Signals: Represented as gold arrows on your chart. These appear when a breakout occurs from a squeeze while momentum is trending upward.
  • Sell Signals: Represented as orange-red arrows. These appear when a breakout occurs from a squeeze while momentum is trending downward.
  • Real-Time Notifications: The script includes an integrated alert system. When the specific conditions for a Buy or Sell signal are met, the platform will generate an audible and visual alert, allowing you to react to the market instantly without constantly staring at the screen.

In summary, this tool acts as a "filter" that waits for the market to become quiet (The Squeeze), identifies the moment it begins to move (The Breakout), and confirms that the momentum is strong enough to follow (The RSI) before providing a signal.

Indicators Used
Relative strength indexMoving average indicatorBollinger bands indicatorIndicator of the average true range
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
10 Views
0 Downloads
0 Favorites
RSI-TC_NEW1
/*

*********************************************************************
          
                 RSI with Trend Catcher signal
                      
                              
                          by Matsu
              based on codes from various sources
                  
*********************************************************************

*/
//mod obos levels

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 LimeGreen
#property indicator_color4 OrangeRed
#property indicator_color5 Gold

#property indicator_level1 60
#property indicator_level2 50
#property indicator_level3 40

int       BBPrd=20;
double    BBDev=2.0;
int       SBPrd=13;
int       SBATRPrd=21;
double    SBFactor=2;
int       SBShift=1;
extern int       RSIPeriod=21;
extern int       OverBoughtLevel=60;
extern int       OverSoldLevel=40;
extern int       BullLevel=50;
extern int       BearLevel=50;

extern bool      AlertOn = true;

double RSI[];
double DnRSI[];
double Buy[];
double Sell[];
double Squeeze[];



int init() 
{

   IndicatorBuffers(5);
   
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,RSI);
   
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,DnRSI);
   
   SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(2,159);
   SetIndexBuffer(2,Buy);
   
   SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(3,159);
   SetIndexBuffer(3,Sell);
   
   SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID);
   SetIndexArrow(4,159);
   SetIndexBuffer(4,Squeeze);
      
   IndicatorShortName("RSI("+RSIPeriod+")");
   IndicatorDigits(2);
   
   return(0);
   
}



int start() 
{

   int counted_bars=IndicatorCounted();
   int shift,limit,ob,os;
   double BBMA, SBMA, TopBBand, BotBBand, TopBBandPrev, BotBBandPrev, TopSBand, BotSBand;
   bool dn = false;
   double BuyNow, BuyPrevious, SellNow, SellPrevious;
   static datetime prevtime = 0;
   
      
   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
   limit=Bars-31;
   if(counted_bars>=31) limit=Bars-counted_bars-1;

   for (shift=limit;shift>=0;shift--)   
   {
            
      RSI[shift]=iRSI(NULL,0,RSIPeriod,PRICE_CLOSE,shift);
//    ob = indicator_level1;
//    os = indicator_level3;
      ob = OverBoughtLevel;
      os = OverSoldLevel; 
    
      // ========= Two-tone RSI
      
      if (dn==true)
      {
         if (RSI[shift]>BullLevel) 
         {
            dn=false;
            DnRSI[shift]=EMPTY_VALUE;
         }
         else
         {
            dn=true;
            DnRSI[shift]=RSI[shift];
         }

      }
      else
      {
         if (RSI[shift]<BearLevel) 
         {
            dn=true;
            DnRSI[shift]=RSI[shift];
         }
         else
         {
            dn=false;
            DnRSI[shift]=EMPTY_VALUE;
         }
           
      }
      
      // ========= Two-tone RSI Ends
      
      // ========= Squeeze Signals
      
      BBMA     = iMA(NULL,0,BBPrd,0,MODE_SMA,PRICE_CLOSE,shift);
      SBMA     = iMA(NULL,0,SBPrd,0,MODE_EMA,PRICE_CLOSE,shift+SBShift);
      TopBBand = iBands(NULL,0,BBPrd,BBDev,0,PRICE_CLOSE,MODE_UPPER,shift);
	   BotBBand = iBands(NULL,0,BBPrd,BBDev,0,PRICE_CLOSE,MODE_LOWER,shift);
      TopSBand = SBMA + (SBFactor * iATR(NULL,0,SBATRPrd,shift+SBShift));
      BotSBand = SBMA - (SBFactor * iATR(NULL,0,SBATRPrd,shift+SBShift));
      TopBBandPrev = iBands(NULL,0,BBPrd,BBDev,0,PRICE_CLOSE,MODE_UPPER,shift+1);
	   BotBBandPrev = iBands(NULL,0,BBPrd,BBDev,0,PRICE_CLOSE,MODE_LOWER,shift+1);
      
      if (TopBBand<TopSBand && BotBBand>BotSBand) Squeeze[shift]=50;
      
      // ========= Squeeze Signals Ends
      
      // ========= BB Breakout Signals
      
      //if(Squeeze[shift+2]==50 && RSI[shift]>50 && BotBBand<BotSBand) 
      if((Squeeze[shift+2]==50 || Squeeze[shift+1]==50) && RSI[shift]>50 && BotBBand<BotSBand) 
      {
         Buy[shift]=ob;
         Sell[shift]=EMPTY_VALUE;
      } 
      else 
      //if(Squeeze[shift+2]==50 && RSI[shift]<50 && TopBBand>TopSBand) 
      if((Squeeze[shift+2]==50 || Squeeze[shift+1]==50) && RSI[shift]<50 && TopBBand>TopSBand) 
      {
         Buy[shift]=EMPTY_VALUE;
         Sell[shift]=os;
      }
      else
      if(Buy[shift+1]==ob && BotBBand<BotBBandPrev && RSI[shift]>50)
      {
         Buy[shift]=ob;
         Sell[shift]=EMPTY_VALUE;
      } 
      else
      if(Sell[shift+1]==os && TopBBand>TopBBandPrev && RSI[shift]<50)
      {
         Buy[shift]=EMPTY_VALUE;
         Sell[shift]=os;
      }
      else
      {
         Buy[shift]=EMPTY_VALUE;
         Sell[shift]=EMPTY_VALUE;
      }
      
      // ========= BB Breakout Signals Ends
      
   }      
         

   // ======= Alert =========

   if(AlertOn)
   {
      if(prevtime == Time[0]) 
      {
         return(0);
      }
      prevtime = Time[0];
   
      BuyNow = Buy[1];
      BuyPrevious = Buy[2];
      SellNow = Sell[1];
      SellPrevious = Sell[2];
   
      if((BuyNow ==ob) && (BuyPrevious ==EMPTY_VALUE) )
      {
         Alert("RSI TC ",Symbol(), " M", Period(), " Buy Alert");
      }
      else   
      if((SellNow ==os) && (SellPrevious ==EMPTY_VALUE) )
      {
         Alert("RSI TC ",Symbol(), " M", Period(), " Sell Alert");
      }
         
      IndicatorShortName("RSI("+RSIPeriod+") (Alert on)");

   }

   // ======= Alert Ends =========


   
   return(0);
   
}



Comments