RSI_channel_sig_2

Download script
Author: mladen
RSI_channel_sig_2

This script is a specialized technical analysis tool designed to help traders identify price trends, momentum shifts, and potential reversal points by combining several advanced mathematical filters into a single visual display.

Core Logic Overview

The tool operates by taking the standard Relative Strength Index (RSI)—which measures the speed and change of price movements—and subjecting it to a series of "smoothing" and "boundary" calculations. Instead of showing you raw, jagged data, it creates a refined "channel" and a directional path to help filter out market noise.

Key Functional Components

1. Advanced Smoothing (The T3 Filter) Rather than using standard moving averages, the script employs a specialized calculation known as a T3 filter. This is designed to reduce the "lag" typically found in most indicators while keeping the line smooth. By applying this to the RSI, the tool provides a cleaner view of momentum without the erratic jumping that often leads to false signals.

2. Dynamic Channeling (High/Low Boundaries) The script looks back over a specific period of time to identify the highest and lowest points reached by the smoothed RSI. It then draws a visual "channel" around the current price action.

  • When the momentum line touches or interacts with these high and low boundaries, it indicates that the asset is reaching an extreme state (overbought or oversold).

3. Signal Identification (The Arrows) The tool automatically places colored arrows on your chart to highlight specific behavioral shifts:

  • Trend Reversals: It identifies moments when the momentum line bounces off the upper or lower boundaries and creates primary signals.
  • Breakout Confirmations: It includes secondary logic to detect when the boundaries themselves shift significantly, providing additional confirmation of a change in market structure.

4. The ZigZag Path The script includes a "ZigZag" component that connects major turning points. This helps the trader visualize the overall "skeleton" of the market trend—clearly showing the peaks and valleys by ignoring minor price fluctuations.

Summary for the User

In simple terms, this tool acts as a sophisticated "momentum map." It takes raw RSI data, smooths it out to remove noise, places it inside a dynamic corridor of highs and lows, and then automatically draws arrows when the momentum suggests the price is likely to reverse or continue in a new direction. It aims to provide a clear visual representation of where the market is "stretched" and where the trend is most likely to turn.

Indicators Used
Relative strength indexIndicator of the average true range
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
RSI_channel_sig_2
 //+------------------------------------------------------------------+
//|                                                  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       = true;
extern bool   ShowChannel      = true;
extern bool   ShowZigZag       = true;

extern int    buyarrowwidth    = 2;
extern color  buyarrowcolor    = Lime;
extern int    sellarrowwidth   = 2;
extern color  sellarrowcolor   = Crimson;
extern int    buy1arrowwidth   = 2;
extern color  buy1arrowcolor   = Aqua;
extern int    sell1arrowwidth  = 2;
extern color  sell1arrowcolor  = Magenta;

//
//
//
//
//

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_WIDTH,buyarrowwidth);
            ObjectSet   ("Buy"+DoubleToStr(i,0),OBJPROP_COLOR,buyarrowcolor); 
            }

            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_WIDTH,sellarrowwidth);
            ObjectSet   ("Sell"+DoubleToStr(i,0),OBJPROP_COLOR,sellarrowcolor);
            }
       
            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_WIDTH,buy1arrowwidth);
            ObjectSet   ("Buy1"+DoubleToStr(i,0),OBJPROP_COLOR,buy1arrowcolor);
            }

            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_WIDTH,sell1arrowwidth);
            ObjectSet   ("Sell1"+DoubleToStr(i,0),OBJPROP_COLOR,sell1arrowcolor);
            }
         
         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