RSI_channel_sig
Download scriptThis script is a technical analysis tool designed for the MetaTrader 4 platform. It provides traders with a visual way to identify potential market momentum, price extremes, and structural trends by combining three distinct mathematical concepts into a single indicator window.
Core Logic Overview
The tool functions by processing raw price data through several layers of calculation to smooth out market "noise" and highlight significant movements:
1. The Foundation: Modified RSI (T3 Smoothing) At its core, the script uses the Relative Strength Index (RSI), which is a standard momentum oscillator. However, instead of using a basic RSI, it applies a specialized "T3" smoothing algorithm. This is a sophisticated mathematical filter designed to reduce the jagged movements often seen in standard indicators, providing a much cleaner and more stable line that represents the underlying trend of price momentum.
2. The Dynamic Channel (Highs and Lows) The script then identifies the highest and lowest points reached by this smoothed RSI over a specific period (user-defined). By connecting these highs and lows, the tool creates a "channel." This visualizes the boundaries of recent price activity, allowing traders to see whether the current momentum is pushing toward the upper limits (potential overbought territory) or the lower limits (potential oversold territory).
3. Signal Identification (Arrows and ZigZags) Beyond just showing lines, the script performs real-time logic to identify specific turning points:
- Reversal Alerts: The tool looks for instances where the momentum line touches the boundaries of the channel and begins to turn back. When this happens, it automatically places colored arrows on the main chart to signal potential buying or selling opportunities.
- Structural Trends (ZigZag): The script contains logic to track significant "peaks" and "valleys" in the price action. It identifies major structural shifts where the trend changes direction significantly, helping traders see the broader market geometry rather than getting distracted by minor fluctuations.
Visual Summary for the User
- The Channel: Provides a visual zone of "normal" momentum.
- The Smooth Line: Shows the current strength and direction of the market's push.
- The Arrows: Act as automated alerts for when the momentum hits a boundary and starts to retreat.
- The ZigZag Logic: Helps in identifying the major "swings" of the market trend over time.
In essence, this script automates the process of watching price extremes and momentum exhaustion, providing a cleaner visual map of where the market might be reaching its limits and where it might be heading next.
//+------------------------------------------------------------------+
//| RSI channel.mq4 |
//| mladen |
//| |
//| |
//| original idea for this indicator found on |
//| http://www.fxexpert.ru (RSI-2 posted by Dm_35) |
//| |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link "mladenfx@gmail.com"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 White
#property indicator_color2 Crimson
#property indicator_width2 3
#property indicator_color3 LimeGreen
#property indicator_width3 3
#property indicator_color4 Orange
#property indicator_width4 4
#property indicator_style1 STYLE_DASH
//
//
//
//
//
//
extern int RSIPeriod = 14;
extern int RSIPrice = PRICE_CLOSE;
extern int HighLowPeriod = 30;
extern int T3Period = 8;
extern double T3Hot = 0.7;
extern bool T3Original = false;
extern bool ShowChannel = true;
extern bool ShowZigZag = true;
//
//
//
//
//
double T3RSIBuffer[];
double HighBuffer[];
double LowBuffer[];
double ZigZagBuffer[];
double ZigZagLow[];
double ZigZagHigh[];
double emas[][6];
double alpha;
double c1;
double c2;
double c3;
double c4;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
int init()
{
IndicatorBuffers(6);
SetIndexBuffer(0,ZigZagBuffer);
SetIndexBuffer(1,HighBuffer);
SetIndexBuffer(2,LowBuffer);
SetIndexBuffer(3,T3RSIBuffer);
SetIndexBuffer(4,ZigZagLow);
SetIndexBuffer(5,ZigZagHigh);
SetIndexStyle(0,DRAW_SECTION);
SetIndexEmptyValue(0,0);
SetIndexEmptyValue(3,0);
SetIndexEmptyValue(4,0);
SetIndexEmptyValue(5,0);
SetIndexLabel(0,NULL);
if (ShowChannel)
{
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
}
else
{
SetIndexStyle(1,DRAW_NONE);
SetIndexStyle(2,DRAW_NONE);
}
//
//
//
//
//
double a = T3Hot;
c1 = -a*a*a;
c2 = 3*(a*a+a*a*a);
c3 = -3*(2*a*a+a+a*a*a);
c4 = 1+3*a+a*a*a+3*a*a;
T3Period = MathMax(1,T3Period);
if (T3Original)
alpha = 2.0/(1.0 + T3Period);
else alpha = 2.0/(2.0 + (T3Period-1.0)/2.0);
//
//
//
//
//
IndicatorShortName("RSI ("+RSIPeriod+","+HighLowPeriod+","+T3Period+")");
return(0);
}
int deinit()
{
for(int j=Bars; j>=0; j--)
{
ObjectDelete("Sell"+DoubleToStr(j,0));
ObjectDelete("Buy" +DoubleToStr(j,0));
ObjectDelete("Sell1"+DoubleToStr(j,0));
ObjectDelete("Buy1" +DoubleToStr(j,0));
}
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
int start()
{
int counted_bars = IndicatorCounted();
int lastZag;
int i,limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if (ArrayRange(emas,0) != Bars) ArrayResize(emas,Bars);
//
//
//
//
//
if (ShowZigZag)
for (lastZag=limit+1; lastZag<Bars; lastZag++) if (ZigZagLow[lastZag] != 0 || ZigZagHigh[lastZag] != 0) break;
//
//
//
//
//
for(i=limit; i>=0; i--)
{
T3RSIBuffer[i] = iT3(iRSI(NULL,0,RSIPeriod,RSIPrice,i),i);
LowBuffer[i] = T3RSIBuffer[ArrayMinimum(T3RSIBuffer,HighLowPeriod,i)];
HighBuffer[i] = T3RSIBuffer[ArrayMaximum(T3RSIBuffer,HighLowPeriod,i)];
if (!ShowZigZag) continue;
if (T3RSIBuffer[i]>LowBuffer[i]&&T3RSIBuffer[i+1]==LowBuffer[i+1])
{
ObjectCreate("Buy"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],Low[i]-iATR(NULL,0,20,i)/2.0);
ObjectSet ("Buy"+DoubleToStr(i,0),OBJPROP_ARROWCODE,228);
ObjectSet ("Buy"+DoubleToStr(i,0),OBJPROP_COLOR,Aqua);
}
if (T3RSIBuffer[i]<HighBuffer[i]&&T3RSIBuffer[i+1]==HighBuffer[i+1])
{
ObjectCreate("Sell"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],High[i]+iATR(NULL,0,20,i)/2.0);
ObjectSet ("Sell"+DoubleToStr(i,0),OBJPROP_ARROWCODE,230);
ObjectSet ("Sell"+DoubleToStr(i,0),OBJPROP_COLOR,Tomato);
}
if (HighBuffer[i]>HighBuffer[i+1]&&HighBuffer[i+1]==HighBuffer[i+2])
{
ObjectCreate("Buy1"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],Low[i]-iATR(NULL,0,20,i)/2.0);
ObjectSet ("Buy1"+DoubleToStr(i,0),OBJPROP_ARROWCODE,225);
ObjectSet ("Buy1"+DoubleToStr(i,0),OBJPROP_COLOR,Blue);
}
if (LowBuffer[i]<LowBuffer[i+1]&&LowBuffer[i+1]==LowBuffer[i+2])
{
ObjectCreate("Sell1"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],High[i]+iATR(NULL,0,20,i)/2.0);
ObjectSet ("Sell1"+DoubleToStr(i,0),OBJPROP_ARROWCODE,226);
ObjectSet ("Sell1"+DoubleToStr(i,0),OBJPROP_COLOR,Red);
}
//
//
//
//
//
ZigZagLow[i] = 0;
ZigZagHigh[i] = 0;
if (LowBuffer[i] < LowBuffer[i+1])
{
if (ZigZagBuffer[lastZag] == LowBuffer[lastZag])
ZigZagBuffer[lastZag] = 0;
ZigZagBuffer[i] = LowBuffer[i];
ZigZagLow[i] = LowBuffer[i];
lastZag = i;
continue;
}
if (HighBuffer[i] > HighBuffer[i+1])
{
if (ZigZagBuffer[lastZag] == HighBuffer[lastZag])
ZigZagBuffer[lastZag] = 0;
ZigZagBuffer[i] = HighBuffer[i];
ZigZagHigh[i] = HighBuffer[i];
lastZag = i;
continue;
}
if (ZigZagBuffer[i] != 0)
{
ZigZagBuffer[i] = 0;
for (lastZag=i+1; lastZag<Bars; lastZag++)
{
if (ZigZagLow[lastZag] != 0) { ZigZagBuffer[lastZag] = ZigZagLow[lastZag]; break; }
if (ZigZagHigh[lastZag] != 0) { ZigZagBuffer[lastZag] = ZigZagHigh[lastZag]; break; }
}
}
}
//
//
//
//
//
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
double iT3(double price,int shift)
{
int i = Bars-shift-1;
if (i < 1)
{
emas[i][0] = price;
emas[i][1] = price;
emas[i][2] = price;
emas[i][3] = price;
emas[i][4] = price;
emas[i][5] = price;
}
else
{
emas[i][0] = emas[i-1][0]+alpha*(price -emas[i-1][0]);
emas[i][1] = emas[i-1][1]+alpha*(emas[i][0]-emas[i-1][1]);
emas[i][2] = emas[i-1][2]+alpha*(emas[i][1]-emas[i-1][2]);
emas[i][3] = emas[i-1][3]+alpha*(emas[i][2]-emas[i-1][3]);
emas[i][4] = emas[i-1][4]+alpha*(emas[i][3]-emas[i-1][4]);
emas[i][5] = emas[i-1][5]+alpha*(emas[i][4]-emas[i-1][5]);
}
return(c1*emas[i][5] + c2*emas[i][4] + c3*emas[i][3] + c4*emas[i][2]);
}
Comments