RSI-TC_NEW_v2
Download scriptThis script is a sophisticated technical analysis tool designed to help traders identify momentum shifts and potential breakout opportunities by combining three distinct market indicators into a single visual display.
Core Component Overview
1. Two-Tone RSI (Relative Strength Index) The primary visual element is a modified version of the RSI, which measures the speed and change of price movements. Unlike a standard RSI, this script utilizes a "Two-tone" logic. It categorizes momentum into specific behaviors:
- It tracks whether the market is trending in a bullish or bearish direction based on predefined thresholds.
- The indicator changes its visual output depending on these conditions, allowing traders to distinguish between different types of price pressure more clearly than a standard single-line RSI would allow.
2. The "Squeeze" Mechanism To identify periods of low volatility—often referred to as a "squeeze"—the script compares two different types of moving bands:
- Bollinger Bands: These measure historical volatility.
- Keltner Channels: These use an Average True Range (ATR) calculation to measure current price range. When these two sets of bands tighten and nest inside one another, the script identifies a "Squeeze." This indicates that market energy is building up and a significant breakout in either direction may be imminent.
3. Breakout Signal Logic The script generates specific "Buy" and "Sell" signals by looking for a confluence of three conditions:
- Volatility Release: It detects when the market price escapes the "Squeeze" state (the bands begin to expand).
- Momentum Confirmation: It checks if the RSI is positioned above or below the 50-level midpoint to determine the strength of the move.
- Trend Continuity: It includes logic to confirm that a new signal is actually occurring by comparing current price action against the previous bar, ensuring that signals are not repeated unnecessarily during a long trend.
User Experience and Alerts
The tool provides immediate visual feedback through different colors and symbols (arrows) on the chart:
- Visual Cues: It marks specific entry points with arrows when the breakout conditions are met.
- Automated Notifications: If the alert feature is enabled, the script will trigger a real-time pop-up notification on your platform the moment a new Buy or Sell signal is generated. This ensures that you do not have to watch the charts constantly to catch high-probability momentum shifts.
In summary, this tool acts as a filter, taking complex data (volatility, momentum, and price action) and distilling it into clear visual signals that highlight when "quiet" markets are about to "explode" in a specific direction.
//+------------------------------------------------------------------+
//| RSI with Trend Catcher signal |
//| Copyright © 1999-2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.ru |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 5
//----
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Red
#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 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;
// ========= 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[0];
BuyPrevious=Buy[1];
SellNow=Sell[0];
SellPrevious=Sell[1];
if((BuyNow ==ob) && (BuyPrevious ==EMPTY_VALUE) )
{
Alert(Symbol(), " M", Period(), " Buy Alert");
}
else
if((SellNow ==os) && (SellPrevious ==EMPTY_VALUE) )
{
Alert(Symbol(), " M", Period(), " Sell Alert");
}
IndicatorShortName("RSI("+RSIPeriod+") (Alert on)");
}
// ======= Alert Ends =========
return(0);
}
//+------------------------------------------------------------------+
Comments