RSI-TC_NEW_Alert2

Download script
RSI-TC_NEW_Alert2

Overview

The RSI with Trend Catcher is a sophisticated technical analysis tool designed to help traders identify market momentum and potential price breakouts. Rather than relying on a single indicator, it combines three distinct types of market data—Relative Strength Index (RSI), Bollinger Bands, and Keltner Channels—to filter out "noise" and provide clearer entry signals.

Core Components and Logic

1. Dual-Tone RSI Momentum Tracking

The script uses the Relative Strength Index (RSI) to measure the speed and change of price movements. It features a "Two-tone" logic:

  • Dynamic Coloring: The indicator tracks whether the market is in an upward or downward state based on predefined thresholds.
  • Visual Feedback: By monitoring these levels, it helps traders distinguish between active bullish momentum (where the RSI stays above a specific level) and bearish momentum (where it remains below), providing a clearer picture of who is currently controlling the market.

2. The "Squeeze" Detection (Volatility Analysis)

One of the primary engines of this script is its ability to detect a "Squeeze." This occurs by comparing Bollinger Bands (which measure standard deviation/volatility) with Keltner Channels (which measure average true range).

  • The Logic: When the Bollinger Bands contract and fit inside the Keltner Channels, it signals that the market is in a period of extremely low volatility.
  • The Purpose: In trading, a "squeeze" often precedes a major breakout. The script identifies these moments of compression to alert you that a significant move might be imminent.

3. Breakout Signal Generation

The script identifies specific entry points by looking for the transition from a "Squeeze" to an active expansion. It looks for three conditions to trigger a signal:

  • Momentum Confirmation: The RSI must confirm the direction (e.g., above 50 for a buy, below 50 for a sell).
  • Volatility Expansion: The script detects when the price "breaks out" of the squeezed state.
  • Trend Verification: It checks if the bands are actively expanding in the direction of the momentum.

When these conditions align, the indicator places visual markers (arrows) on your chart to signal a potential trade.

User Experience and Alerts

To ensure the trader doesn't have to watch the screen constantly, the script includes an automated notification system:

  • Visual Labels: It displays a real-time RSI value on the chart that changes color based on market conditions (Lime for bullish, Red for bearish).
  • Audio & Pop-up Alerts: The script can be configured to play specific sound files and trigger "Alert" pop-up boxes on your screen the moment a trend breakout is confirmed.
  • Smart Filtering: It includes a delay mechanism and a filter toggle to prevent "false positives," ensuring you are only notified of significant moves rather than minor fluctuations.
Indicators Used
Relative strength indexMoving average indicatorBollinger bands indicatorIndicator of the average true range
Miscellaneous
Implements a curve of type %1It plays sound alertsIt issuies visual alerts to the screen
14 Views
0 Downloads
0 Favorites
RSI-TC_NEW_Alert2
/*

*********************************************************************
          
                 RSI with Trend Catcher signal
                      
                              
                          by Matsu
              based on codes from various sources
                  
*********************************************************************
// added sound feb/17/2009 - itemsdepot@hotmail.com
*/


#property indicator_separate_window
#property indicator_buffers 5

#property indicator_color1 Silver
#property indicator_color2 Gray
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Gold

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

#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 3
#property indicator_width4 3
#property indicator_width5 1


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  BullLevel=50;
extern int  BearLevel=50;
extern bool RSiTCMessageBoxOn=True;
extern bool RSiTCSoundAlertOn=True;
extern int  RSiTCAlarmDelay=20;
extern bool  RSiTCFilter=True;
extern int  RSiTCFontsize=10;


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

string RSiTCShortName;
string RSiTCLabel1;
double RSiTCTime;


//-------------------------------------------------------
//-------- Init
//--------
//-------------------------------------------------------

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);
      

   
   RSiTCTime=TimeLocal();
   RSiTCShortName="RSiTrendCatcher";
   
   IndicatorShortName(RSiTCShortName);
   IndicatorDigits(2);   
   
   
   RSiTCLabel1="-";
   
   return(0);
   
}


//-------------------------------------------------------
//-------- De-Init
//--------
//-------------------------------------------------------


int deinit() 
{


   ObjectDelete(RSiTCLabel1);
   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;
   double RSiTCFinishTime=TimeLocal();
   bool   RSiTCSpeak=False;
   //indicator_level1 = RSiTCSellLevel;
   //indicator_level3 = RSiTCBuyLevel;
   
      
   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;

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

      
   }
   
   //Print("RSi___________"+RSI[0]);
         
   ObjectDelete(RSiTCLabel1);      
   //------------------------------------------------
     if(!ObjectCreate(RSiTCLabel1, OBJ_LABEL,WindowFind(RSiTCShortName), 0, 0))
       {
        Print("Error: - Code #",GetLastError());
       return(0);
       }else{
                           ObjectSetText(RSiTCLabel1,"RSi: "+RSI[0] ,RSiTCFontsize, "Tahoma");
              if (RSI[0]>ob) ObjectSet(RSiTCLabel1, OBJPROP_COLOR, Lime);
              if (RSI[0]>os) ObjectSet(RSiTCLabel1, OBJPROP_COLOR, Silver);
              if (RSI[0]<os) ObjectSet(RSiTCLabel1, OBJPROP_COLOR, Red);
              
              
                 ObjectSet(RSiTCLabel1, OBJPROP_XDISTANCE, (RSI[0]*10) );
                 ObjectSet(RSiTCLabel1, OBJPROP_YDISTANCE, 0);
	           // ObjectSet(RSiTCLabel1, OBJPROP_BACK, Green); 
                
              
       }      

   //---------------------------------------------------
   //Print("  Rsi :"+RSI[0]);
   //Print("DnRsi :"+DnRSI[0]);
   //Print("  Buy :"+Buy[0]);
   //Print(" Sell :"+Sell[0]);
   //Print("  Sqz :"+Squeeze[0]);

   
   //----------------------------------------------------
   RSiTCSpeak=False;
   RSiTCFinishTime=TimeLocal(); 
                                                   
   if ((RSiTCFinishTime - RSiTCTime) >= RSiTCAlarmDelay )    // && pos==0)
      {       
          RSiTCFinishTime=TimeLocal();
          RSiTCTime=TimeLocal();
          RSiTCSpeak=True;      
       }     
   
   
   
   // ======= Alert =========

   if(RSiTCSpeak==True)
   {
  
      BuyNow = Buy[1];
      BuyPrevious = Buy[2];
      SellNow = Sell[1];
      SellPrevious = Sell[2];
   

      
      
      if (RSiTCFilter==True)
      {


          if((BuyNow ==ob) && (BuyPrevious ==EMPTY_VALUE))
          {
             //Alert(Symbol(), " M", Period(), " Buy Alert");
             if (RSiTCSoundAlertOn==True) PlaySound("news.wav");//support.wav
             if (RSiTCMessageBoxOn==True) Alert(Symbol(), " M", Period(), " Sell Alert");
         
          }
          else   
          if((SellNow ==os) && (SellPrevious ==EMPTY_VALUE))
          {
             //Alert(Symbol(), " M", Period(), " Sell Alert");
             if (RSiTCSoundAlertOn==True) PlaySound("ok.wav");//resistance.wav
             if (RSiTCMessageBoxOn==True) Alert(Symbol(), " M", Period(), " Buy Alert");
         
          }


      }
      
      
   
      if (RSiTCFilter==False)
      {


          if(BuyNow ==ob)
          {
             //Alert(Symbol(), " M", Period(), " Buy Alert");
             if (RSiTCSoundAlertOn==True) PlaySound("support.wav");
             if (RSiTCMessageBoxOn==True) Alert(Symbol(), " M", Period(), " Sell Alert");
         
          }
          else   
          if(SellNow ==os)
          {
             //Alert(Symbol(), " M", Period(), " Sell Alert");
             if (RSiTCSoundAlertOn==True) PlaySound("resistance.wav");
             if (RSiTCMessageBoxOn==True) Alert(Symbol(), " M", Period(), " Buy Alert");
         
          }


      }      
 
 
 
 
      
         
      //IndicatorShortName("RSI("+RSIPeriod+") (Alert on)");

   }

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


   
   return(0);
   
}



Comments