_Channel@RSI

Download script
_Channel@RSI

This tool is designed to help traders identify key price extremes—specifically peaks and troughs—by combining momentum analysis with structural price tracking. It automates the process of finding "turning points" in the market, making it easier to visualize the overall trend and significant historical highs or lows.

Core Logic Overview

The script functions by monitoring a specific momentum oscillator (the RSI) to determine when the market is entering "overbought" or "oversold" territories. Instead of just providing a raw reading, the logic uses these momentum signals as triggers to search for and mark actual price points on your chart.

Key Functional Components

1. Momentum Filtering (The Trigger) The tool continuously monitors whether the asset is overextended. It establishes two threshold boundaries:

  • Overbought: When the momentum exceeds a high limit, the script begins looking for a potential "peak."
  • Oversold: When the momentum falls below a low limit, the script begins looking for a potential "trough."

2. Price Extreme Identification Once a momentum trigger is hit, the logic doesn't just mark the current candle; it performs a targeted search:

  • Peak Detection: If the market is overbought, the tool scans recent price history to find the highest point reached during that specific move.
  • Trough Detection: If the market is oversold, the tool scans back to locate the lowest point reached during that move.

3. Visual Mapping (ZigZag and Channels) The script offers three distinct ways to display this information based on user preference:

  • ZigZag Structure: It can draw a traditional zigzag line connecting these peaks and troughs, highlighting the "skeleton" of the market movement.
  • Time-Based Extremes: Users can choose to mark these points based on the specific time they occurred or specifically at the price extremes.
  • Dynamic Channels: The logic can project lines representing the upper and lower boundaries of these identified extremes, creating a visual "corridor" of recent price action.

Summary for the Trader

In simple terms, this script acts as a scout. It watches for the market to get "stretched" too far in one direction (using RSI). When it detects this stretch, it reaches back into the data to find exactly where the highest and lowest points were, then draws those levels on your chart so you can see the structural boundaries of the price movement clearly.

Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
_Channel@RSI
#property indicator_chart_window // â îêíå èíñòðóìåíòà
#property indicator_buffers 5
#property indicator_color1 Magenta // çèãçàã
#property indicator_color3 Green // âåðõí. ãð. êàíàëà
#property indicator_color4 Red // íèæí. ãð. êàíàëà
// âõîäíûå ïàðàìåòðû
extern double OverSold=30; // çîíà ïåðåïðîäàííîñòè â %% (çîíà ïåðåêóïëåííîñòè=100-çîíà ÏÏ)
extern int RSIperiod=14; // Ïåðèîä RSI
extern int applied_price=0; // 0-CLOSE, 1-OPEN, 2-HIGH, 3-LOW, 4-MEDIAN, 5-TYPICAL, 6-WEIGHTED
extern int ShowChannel=2; // ïîêàçàòü 1 - ïî ìåñòó ýêñòðåìóìîâ, 2 - ïî âðåìåíè îïðåäåëåíèÿ
extern int ShowZigZag=0; // ïîêàçàòü 1 - ïî ìåñòó ýêñòðåìóìîâ, 2 - ïî âðåìåíè îïðåäåëåíèÿ
// èíä.áóôåðû
double   ZZpeak[], // ïèê
         ZZtrough[], // âïàäèíà
         ChTop[], // âåðõí. ãð. êàíàëà
         ChBot[], // íèæí. ãð. êàíàëà
         RSI[]; // RSI
// îáùèå ïåðåìåííûå
double OverBought; // çîíà ïåðåêóïëåííîñòè
bool dir; // 0-ïîéìàíà âïàäèíà, 1 - ïèê
double max,min; // òåêóùèå ìàêñ., ìèíèìóìû
double top,bot; // ïèêè, âïàäèíû
int jDn,jUp; // ñ÷åò÷èêè ðàññòîÿíèÿ ìåæäó ýêñòðåìóìàìè
bool count=1; // íàïðàâëåíèå ïîèñêà öåíîâîãî ýêñòðåìóìà; 1 - îò ñòàðøèõ áàðîâ ê ìëàäøèì
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   if(ShowZigZag<0 || ShowChannel<0) count=0;
   ShowZigZag=MathAbs(ShowZigZag); ShowChannel=MathAbs(ShowChannel);

   OverBought=100.0-OverSold; // çîíà ïåðåêóïëåííîñòè
//---- indicators
   SetIndexBuffer(0,ZZpeak);
   SetIndexEmptyValue(0,0.0);
   SetIndexLabel(0,"Peak");
   
   SetIndexBuffer(1,ZZtrough);
   SetIndexEmptyValue(1,0.0);
   SetIndexLabel(1,"Trough");
   
   if(ShowZigZag>0) {
      SetIndexStyle(0,DRAW_ZIGZAG);
      SetIndexStyle(1,DRAW_ZIGZAG);
     }
   else {      
      SetIndexStyle(0,DRAW_NONE);
      SetIndexStyle(1,DRAW_NONE);
     }

   SetIndexBuffer(2,ChTop);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexLabel(2,"ChTop");

   SetIndexBuffer(3,ChBot);
   SetIndexEmptyValue(3,0.0);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexLabel(3,"ChBot");

   if(ShowChannel>0) {
      SetIndexStyle(2,DRAW_LINE);
      SetIndexStyle(3,DRAW_LINE);
     }
   else {      
      SetIndexStyle(2,DRAW_NONE);
      SetIndexStyle(3,DRAW_NONE);
     }

   SetIndexBuffer(4,RSI);
   SetIndexStyle(4,DRAW_NONE);
   string _rsi="RSI("+RSIperiod+") "+applied_price;
   SetIndexLabel(4,_rsi);

//----
   IndicatorShortName("ZZ@RSI"); 

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int ic=IndicatorCounted();
   if(Bars-ic-1>1) ic=reinit();
   int limit=Bars-ic-1; // êîë-âî ïåðåñ÷åòîâ

   for(int i=limit; i>=0; i--) RSI[i]=iRSI(NULL,0,RSIperiod,applied_price, i); 

   for(i=limit; i>0; i--)
     {
      double rsi=RSI[i];
      jDn++; jUp++; // ñ÷åò÷èêè ðàññòîÿíèÿ ìåæäó ýêñòðåìóìàìè

      bool up=rsi>OverBought;
      bool dn=rsi<OverSold;

      if(dir) { // ëîâèòñÿ âïàäèíà
         if(up) { // åñëè â çîíå ÏÊ, òî
            double l=High[i]*100;
            if(count) {for(int k=jUp; k>=0; k--) if(Low[i+k]<l) {int sh=i+k;l=Low[i+k];}}
            else {for(k=0; k<=jUp; k++) if(Low[i+k]<l) {sh=i+k;l=Low[i+k];}}
            bot=Low[sh]; // âïàäèíà = ìèíèìóìó
            if(ShowZigZag==1) ZZtrough[sh]=bot; else ZZtrough[i]=bot;
            if(ShowChannel==1) for(k=sh; k>i; k--) ChBot[k]=bot;
            dir=0; // ïîéìàíà âïàäèíà öåíû
           }
        }
      else { // ëîâèòñÿ ïèê
         if(dn) { // åñëè â çîíå ÏÏ, òî
            double h=0;
            if(count) {for(k=jDn; k>=0; k--) if(High[i+k]>h) {sh=i+k; h=High[i+k];}}
            else {for(k=0; k<=jDn; k++) if(High[i+k]>h) {sh=i+k; h=High[i+k];}}
            top=High[sh];
            if(ShowZigZag==1) ZZpeak[sh]=top; else ZZpeak[i]=top;
            if(ShowChannel==1) for(k=sh; k>i; k--) ChTop[k]=top;
            dir=1; // ïîéìàí ïèê öåíû
           }
        }

      if(up) jUp=-2; if(dn) jDn=-2; // ñáðîñ ñ÷åò÷èêîâ

      for(k=0; k<2; k++) {ChTop[i-k]=top; ChBot[i-k]=bot;}
     }
        
   return(0);
  }


// ô-ÿ äîïîëíèòåëüíîé èíèöèàëèçàöèè
int reinit()
  {
   ArrayInitialize(ZZpeak,0.0);
   ArrayInitialize(ZZtrough,0.0);
   ArrayInitialize(ChTop,0.0);
   ArrayInitialize(ChBot,0.0);
   ArrayInitialize(RSI,0.0);
   dir=0;max=0;min=0;top=0;bot=0;jDn=0;jUp=0;
   return(0);
  }

Comments