rvmGann_sv8_n

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
rvmGann_sv8_n

This script is a specialized technical analysis tool designed to identify and visualize significant price movements, specifically focusing on "peaks" and "troughs" (highs and lows) within a financial chart. Instead of relying on standard moving averages or simple momentum oscillators, it uses a logic system inspired by structural price action to determine where the market is trending and where it might be reversing.

Core Logic Overview

The tool works by scanning each candle in the historical data to identify "Extreme Points." It doesn't just look for any high or low; it seeks out significant structural breaks. The script evaluates whether the current price is breaking out of a defined range or establishing a new local boundary.

Key Components of the Analysis

1. Extreme Point Identification The script maintains a memory of the highest and lowest prices reached over a recent period. It constantly compares the current candle's high and low against these stored boundaries:

  • If a new price exceeds the previous "High," it marks a potential peak.
  • If a new price drops below the previous "Low," it marks a potential trough.

2. Trend and Sentiment Tracking Beyond just identifying highs and lows, the script analyzes how the price reached those points. It looks at:

  • Opening vs. Closing Prices: It checks if a candle opened at a new high but closed lower, or vice versa, to determine the strength of the move.
  • Relative Positioning: If a price is neither clearly at a high nor a low, the script calculates which boundary it is closer to (using mathematical distance) to assign it a logical "leaning" towards one side or the other.

3. Breakout and Reversal Detection The logic includes a specific "tendency" filter (controlled by the GSv_tend parameter). This helps smooth out market noise:

  • It tracks sequences of movements to ensure that a single erratic candle doesn't trigger a signal.
  • It identifies "breakthroughs," where price moves significantly enough to reset the internal counters, signaling a shift from one trend (e.g., bullish) to another (e.g., bearish).

4. Visual Representation Once the logic confirms a significant structural high or low:

  • The script draws visual markers on the chart (simulating a ZigZag-style movement).
  • It connects these points to provide a clear "skeleton" of the price action, making it easier for a user to see the underlying market structure without being distracted by minor fluctuations.

Summary for the User

Essentially, this tool acts as an automated "structuralist" analyst. It filters out the daily "noise" of the market to show you only the meaningful turning points. By identifying where the price has structurally failed to make new highs or lows and instead pivoted, it provides a visual map of the market's path, helping users identify key support and resistance zones based on historical extremes.

17 Views
0 Downloads
0 Favorites
rvmGann_sv8_n
//+------------------------------------------------------------------+
//|                                                  rvmGann_sv8.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 DeepSkyBlue
#property indicator_color2 DeepSkyBlue
//#property indicator_color3 DeepSkyBlue
//#property indicator_color4 DeepSkyBlue
//#property indicator_color5 DeepSkyBlue
//#property indicator_color6 DeepSkyBlue
//#property indicator_color7 DeepSkyBlue
//#property indicator_color8 DeepSkyBlue
//---- input parameters
extern int GSv_tend=2;
//---- buffers
double Upz[];
double Dnz[];
double sH[];
double sL[];
double aH[];
double aL[];
double fB[];
double lB[];
//----------
double CurH,CurL;
int lb,sp,lbars;
bool draw_up,draw_dn;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_ZIGZAG,STYLE_SOLID);
   SetIndexStyle(1,DRAW_ZIGZAG,STYLE_SOLID);
   SetIndexStyle(2,DRAW_NONE);
   SetIndexStyle(3,DRAW_NONE);
   SetIndexStyle(4,DRAW_NONE);
   SetIndexStyle(5,DRAW_NONE);
   SetIndexStyle(6,DRAW_NONE);
   SetIndexStyle(7,DRAW_NONE);
   SetIndexBuffer(0,Upz);
   SetIndexBuffer(1,Dnz);
   SetIndexBuffer(2,sH);
   SetIndexBuffer(3,sL);
   SetIndexBuffer(4,aH);
   SetIndexBuffer(5,aL);
   SetIndexBuffer(6,fB);
   SetIndexBuffer(7,lB);
   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);
   SetIndexEmptyValue(2,0);
   SetIndexEmptyValue(3,0);
   SetIndexEmptyValue(4,-1);
   SetIndexEmptyValue(5,-1);
   SetIndexEmptyValue(6,-1);
   SetIndexEmptyValue(7,-1);
   SetIndexLabel(0,"z1");
   SetIndexLabel(1,"z2");
   SetIndexLabel(2,"sH");
   SetIndexLabel(3,"sL");
   SetIndexLabel(4,"aH");
   SetIndexLabel(5,"aL");
   SetIndexLabel(6,"fB");
   SetIndexLabel(7,"lB");
//----
   return(0);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   int cb,index,limit,ai,i;
//---- 
   if( !counted_bars<0 )
   {
      index=Bars-1;
      if( index-counted_bars<2 )
      {
         limit=0;
      }
      else
      {
         limit=index-counted_bars-1;
      }
   }
   else
   {
      Alert("Ñáîé ðàñ÷åòà èíäèêàòîðà rvmGSv_mt");
      return(-1);
   }
//----
for( cb=limit; cb>=0; cb-- )
{
   ai=index-cb;
   if( lbars!=Bars && lb==ai )
   {
      lbars=Bars;
      continue;
   }
   if( lb!=ai )
   {
      lb=ai;
      if( Upz[cb+1]>0 || Dnz[cb+1]>0 )
      {
         aH[cb]=High[cb+1];
         aL[cb]=Low[cb+1];
      }
      else
      {
         if( High[cb+1]<=aH[cb+1] && Low[cb+1]>=aL[cb+1] )
         {
            aH[cb]=aH[cb+1];
            aL[cb]=aL[cb+1];
            sH[cb]=sH[cb+1];
            sL[cb]=sL[cb+1];
         }
         else
         {
            if( High[cb+1]>aH[cb+1] )
            {
               aH[cb]=High[cb+1];
            }
            else
            {
               aH[cb]=aH[cb+1];
            }
            if( aL[cb+1]>0 )
            {
               if( Low[cb+1]<aL[cb+1] )
               {
                  aL[cb]=Low[cb+1];
               }
               else
               {
                  aL[cb]=aL[cb+1];
               }
            }
            else
            {
               aL[cb]=Low[cb+1];
            }
         }
      }
      if( draw_up!=0 )
      {
         if( fB[cb+1]==1 )
         {
            sH[cb]=sH[cb+1]+1;
            if( lB[cb+1]==0 )
            {
               sH[cb]=0;
               sL[cb]=1;
            }
         }
         else
         {
            if( fB[cb+1]==0 )
            {
               sL[cb]=sL[cb+1]+1;
               if( lB[cb+1]==1 )
               {
                  sH[cb]=1;
                  sL[cb]=0;
               }
            }
         }
      }
      else
      {
         if( draw_dn!=0 )
         {
            if( fB[cb+1]==0 )
            {
               sL[cb]=sL[cb+1]+1;
               if( lB[cb+1]==1 )
               {
                  sH[cb]=1;
                  sL[cb]=0;
               }
            }
            else
            {
               if( fB[cb+1]==1 )
               {
                  sH[cb]=sH[cb+1]+1;
                  if( lB[cb+1]==0 )
                  {
                     sH[cb]=0;
                     sL[cb]=1;
                  }
               }
            }
         }
         else
         {
            if( fB[cb+1]==1 )
            {
               sH[cb]=sH[cb+1]+1;
               sL[cb]=sL[cb+1];
               if( lB[cb+1]==0 )
               {
                  sL[cb]++;
               }
            }
            else
            {
               if( fB[cb+1]==0 )
               {
                  sH[cb]=sH[cb+1];
                  sL[cb]=sL[cb+1]+1;
                  if( lB[cb+1]==1 )
                  {
                     sH[cb]++;
                  }
               }
            }
         }
      }
      if( GSv_tend>1 )
      {
         //åñëè íà ïðåäûäóùåé ñâå÷å áûëî ïðåëîìëåíèå ââåðõ è îíà âíåøíÿÿ ïî îòíîøåíèþ ê ïðåäûäóùåé + ïîñëåäíèé ìèíèìóì
         if( sH[cb]==GSv_tend && Upz[cb+1]>0 && High[cb+1]>High[cb+2] && Low[cb+1]<Low[cb+2] && fB[cb+1]==1 )
         {
            sL[cb]=1;
         }
         else //èíà÷å åñëè íà ïðåäûäóùåé ñâå÷å ñ÷åò÷èê áûëî ïðåëîìëåíèå ââåðõ
         {
            //åñëè íà ïðåäûäóùåé ñâå÷å áûëî ïðåëîìëåíèå âíèç è îíà âíåøíÿÿ ïî îòíîøåíèþ ê ïðåäûäóùåé + ïîñëåäíèé ìàêñèìóì
            if( sL[cb]==GSv_tend && Dnz[cb+1]>0 && High[cb+1]>High[cb+2] && Low[cb+1]<Low[cb+2] && fB[cb+1]==0 )
            {
               sH[cb]=1;
            }
         }
      }
      //îáíóëÿåì
      CurH=0;
      CurL=Low[cb];
   }
   if( High[cb]<=aH[cb] && Low[cb]>=aL[cb] )
   {
      continue;
   }
   if( High[cb]<=CurH && Low[cb]>=CurL )
   {
      continue;
   }
   if( High[cb]>CurH ) CurH=High[cb];
   if( Low[cb] <CurL ) CurL=Low[cb];
   Extr_seq(cb);
   //åñëè ñâèíã äâóõ è áîëåå áàðîâûé, òî åñëè ïåðâûé õàé-îáíóëÿåì ñ÷åò÷èê ìèíìóìîâ, à åñëè ïåðâûé-ëîó, îáíóëÿåì ñ÷åò÷èê ìàêñèìóìîâ
   if( GSv_tend>1 )
   {
      if( fB[cb]>0 && sH[cb]==GSv_tend-1 && sL[cb]>0 )
      {
         sL[cb]=0;
      }
      else
      {
         if( fB[cb]>-1 && sL[cb]==GSv_tend-1 && sH[cb]>0 )
         {
            sH[cb]=0;
         }
      }
   }
   if( draw_up!=0 )
   {
      if( fB[cb]==1 )
      {
         if( sp!=ai )
         {
            Upz[index-sp]=0;
            sp=ai;
         }
         Upz[cb]=High[cb];
         if( lB[cb]==0 && (sL[cb]+1)>=GSv_tend && GSv_tend<2 )
         {
            Dnz[cb]=Low[cb];
            draw_up=0;
            draw_dn=1;
         }
      }
      else
      {
         if( fB[cb]==0 )
         {
            if( (sL[cb]+1)>=GSv_tend )
            {
               Dnz[cb]=Low[cb];
               sp=ai;
               draw_up=0;
               draw_dn=1;
               if( lB[cb]==1 && (sH[cb]+1)>=GSv_tend )
               {
                  Upz[cb]=High[cb];
                  draw_up=1;
                  draw_dn=0;
               }
            }
            else
            {
               if( lB[cb]==1 )
               {
                  Upz[index-sp]=0;
                  sp=ai;
                  Upz[cb]=High[cb];
               }
            }
         }
      }
   }
   else
   {
      if( draw_dn!=0 )
      {
         if( fB[cb]==1 )
         {
            if( (sH[cb]+1)>=GSv_tend )
            {
               Upz[cb]=High[cb];
               sp=ai;
               draw_up=1;
               draw_dn=0;
               if( lB[cb]==0 && (sL[cb]+1)>=GSv_tend )
               {
                  Dnz[cb]=Low[cb];
                  draw_up=0;
                  draw_dn=1;
               }
            }
            else
            {
               if( lB[cb]==0 )
               {
                  Dnz[index-sp]=0;
                  sp=ai;
                  Dnz[cb]=Low[cb];
               }
            }
         }
         else
         {
            if( fB[cb]==0 )
            {
               if( sp!=ai )
               {
                  Dnz[index-sp]=0;
                  sp=ai;
               }
               Dnz[cb]=Low[cb];
               if( lB[cb]==1 && (sH[cb]+1)>=GSv_tend && GSv_tend<2 )
               {
                  Upz[cb]=High[cb];
                  draw_up=1;
                  draw_dn=0;
               }
            }
         }
      }
      else
      {
         if( fB[cb]==1 && (sH[cb]+1)>=GSv_tend )
         {
            Dnz[index]=Low[index];
            Upz[cb]=High[cb];
            draw_up=1;
            sp=ai;
            if( lB[cb]==0 && (sL[cb]+1)>=GSv_tend )
            {
               Dnz[cb]=Low[cb];
               draw_up=0;
               draw_dn=1;
            }
         }
         else
         {
            if( fB[cb]==0 && (sL[cb]+1)>=GSv_tend )
            {
               Upz[index]=High[index];
               Dnz[cb]=Low[cb];
               draw_dn=1;
               sp=ai;
               if( lB[cb]==1 && (sH[cb]+1)>=GSv_tend )
               {
                  Upz[cb]=High[cb];
                  draw_up=1;
                  draw_dn=0;
               }
            }
         }
      }
   }
}
//----
   return(0);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Ôóíêöèÿ îïðåäåëÿåò ïîñëåäîâàòåëüíîñòü ïîÿâëåíèÿ ýêñòðåìóìîâ      |
//+------------------------------------------------------------------+
void Extr_seq(int curb)
  {
//---- 
   if( fB[curb]<0 )
   {
      //åñëè áàð ïðîñ÷èòûâàåòñÿ ïî èñòîðèè è îí ñðàçó âíåøíèé
      if( High[curb]>aH[curb] && Low[curb]<aL[curb] )
      {
         //åñëè îòêðûòèå íà íîâîì ìàêñèìóìå
         if( Open[curb]>aH[curb] )
         {
            fB[curb]=1;
            lB[curb]=0;
         }
         else //èíà÷å åñëè îòêðûòèå íà íîâîì ìàêñèìóìå
         {
            //åñëè îòêðûòèå íà íîâîì ìèíèìóìå
            if( Open[curb]<aL[curb] )
            {
               fB[curb]=0;
               lB[curb]=1;
            }
            else
            {
               //åñëè çàêðûòèå íà íîâîì ìàêñèìóìå è îíî âûøå èëè ðàâíî îòêðûòèÿ
               if( Close[curb]>aH[curb] && Close[curb]>=Open[curb] )
               {
                  fB[curb]=0;
                  lB[curb]=1;
               }
               else //èíà÷å åñëè çàêðûòèå íà íîâîì ìàêñèìóìå è îíî âûøå èëè ðàâíî îòêðûòèÿ
               {
                  //åñëè çàêðûòèå íà íîâîì ìèíèìóìå è íèæå èëè ðàâíî îòêðûòèþ
                  if( Close[curb]>aL[curb] && Close[curb]<=Open[curb] )
                  {
                     fB[curb]=1;
                     lB[curb]=0;
                  }
                  else //èíà÷å åñëè çàêðûòèå íà íîâîì ìèíèìóìå è íèæå èëè ðàâíî îòêðûòèþ
                  {
                     //åñëè êëîç âûøå îïåíà
                     if( Close[curb]>Open[curb] )
                     {
                        fB[curb]=0;
                        lB[curb]=1;
                     }
                     else //èíà÷å åñëè êëîç âûøå îïåíà
                     {
                        //åñëè êëîç íèæå îïåíà
                        if( Close[curb]<Open[curb] )
                        {
                           fB[curb]=1;
                           lB[curb]=0;
                        }
                        else //èíà÷å åñëè êëîç íèæå îïåíà
                        {
                           //åñëè îïåí áëèæå ê àêòèâíîìó ìèíèìóìó
                           if( MathAbs(Open[curb]-aL[curb])<MathAbs(Open[curb]-aH[curb]) )
                           {
                              fB[curb]=0;
                              lB[curb]=1;
                           }
                           else //èíà÷å åñëè îïåí áëèæå ê àêòèâíîìó ìèíèìóìó
                           {
                              //åñëè îïåí áëèæå ê àêòèâíîìó ìàêñèìóìó
                              if( MathAbs(Open[curb]-aL[curb])>MathAbs(Open[curb]-aH[curb]) )
                              {
                                 fB[curb]=1;
                                 lB[curb]=0;
                              }
                              else //èíà÷å èíà÷å åñëè îïåí áëèæå ê àêòèâíîìó ìàêñèìóìó
                              {
                                 //åñëè îïåí áëèæå èëè ðàâíîóäàëåí îò ìèíèìóìà
                                 if( MathAbs(Open[curb]-Low[curb])>=MathAbs(Open[curb]-High[curb]) )
                                 {
                                    fB[curb]=0;
                                    lB[curb]=1;
                                 }
                                 else
                                 {
                                    fB[curb]=1;
                                    lB[curb]=0;
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }
      else
      {
         if( High[curb]>aH[curb] )
         {
            fB[curb]=1;
         }
         else
         {
            fB[curb]=0;
         }
      }
   }
   else
   {
      //åñëè òåêóùàÿ öåíà ðàâíà ìàêñèìóìó íà áàðå èëè íåò ìèíèìóìà è ïðè ýòîì ìàêñèìóì-íîâûé
      if( (Low[curb]>=aL[curb] || Close[curb]==High[curb] ) && High[curb]>aH[curb] )
      {
         lB[curb]=1;
      }
      else //èíà÷å åñëè öåíà ðàâíà ìàêñèìóìó íà áàðå
      {
         //åñëè öåíà ðàâíà ìèíèìóìó íà áàðå èëè íåò íîâîãî ìàêñèìóìà è ïðè ýòîì ìèíèìóì - íîâûé
         if( (High[curb]<=aH[curb] || Close[curb]==Low[curb]) && Low[curb]<aL[curb] )
         {
            lB[curb]=0;
         }
      }
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments