RSI-TC_v1
Download scriptThe RSI with Trend Catcher is a specialized technical analysis tool designed to help traders identify high-probability momentum shifts by combining three different types of market data: momentum, moving averages, and volatility bands. Unlike a standard RSI (Relative Strength Index) which only tells you if an asset is "overbought" or "oversold," this script filters those signals through a multi-layered verification system to ensure the trade aligns with the broader market trend.
How the Logic Works
The tool processes information in three distinct stages before providing a signal:
1. Trend Identification (The Foundation)
The script first establishes the general direction of the market by comparing two different types of moving averages:
- Simple Moving Average (SMA): Used to determine the baseline price trend.
- Exponential Moving Average (EMA): Used to capture more recent price actions. By comparing these averages against the RSI value, the script determines if the market is in a "Bullish" state (upward momentum) or a "Bearish" state (downward momentum). This prevents the tool from suggesting a "Buy" in a crashing market or a "Sell" in a surging one.
2. Volatility & Boundary Analysis (The Filter)
To refine the signals, the script uses two different "envelope" systems to measure price boundaries:
- Bollinger Bands: These represent standard volatility based on a set period.
- Keltner-style Bands: These use Average True Range (ATR) to calculate bands based on actual market volatility rather than just standard deviation.
The script specifically looks for moments where the price is interacting with these boundaries. It acts as a safety check, ensuring that the momentum isn't just a random spike but a significant movement relative to recent volatility.
3. Signal Execution (Buy & Sell Alerts)
A signal (visualized as an arrow on your chart) is only triggered when three conditions align simultaneously:
- For a Buy Signal: The market must be in a confirmed upward trend, and the lower price boundary of one system must be lower than the other, indicating a "dip" or a value entry within an uptrend.
- For a Sell Signal: The market must be in a confirmed downward trend, and the upper price boundary of one system must be higher than the other, indicating a "peak" or a reversal point within a downtrend.
Key Features for the User
- Visual Alerts: The script places clear arrows on the chart to highlight exact entry points based on the logic above.
- Dynamic Alerts: If enabled, the tool will send a pop-up notification in your trading platform the moment a new Buy or Sell signal is confirmed.
- Trend Filtering: By requiring the RSI to be above or below the 50 level depending on the trend, it helps filter out "choppy" market noise where the price moves sideways without clear direction.
/*
*********************************************************************
RSI with Trend Catcher signal
by Matsu
based on codes from various sources
*********************************************************************
*/
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_color2 Lime
#property indicator_color3 Red
#property indicator_color4 Red
#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 Buy[];
double Sell[];
double DnRSI[];
int init()
{
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,RSI);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID);
SetIndexArrow(1,159);
SetIndexBuffer(1,Buy);
SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID);
SetIndexArrow(2,159);
SetIndexBuffer(2,Sell);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,DnRSI);
IndicatorShortName("RSI("+RSIPeriod+")");
IndicatorDigits(2);
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
int shift,limit,ob,os;
double BBMA, SBMA, TopBBand, BotBBand, TopSBand, BotSBand;
bool TrendUp, TrendDn;
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;
TrendUp=false;
TrendDn=false;
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));
if(SBMA>BBMA && RSI[shift]>50) TrendUp=true;
if(SBMA<BBMA && RSI[shift]<50) TrendDn=true;
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;
}
}
if(TrendUp==true && BotBBand<BotSBand)
{
Buy[shift]=ob;
Sell[shift]=EMPTY_VALUE;
}
else
if(TrendDn==true && TopBBand>TopSBand)
{
Buy[shift]=EMPTY_VALUE;
Sell[shift]=os;
}
else
{
Buy[shift]=EMPTY_VALUE;
Sell[shift]=EMPTY_VALUE;
}
}
// ======= 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 End =========
return(0);
}
Comments