rvmGann_sv6

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

This script is a technical analysis tool designed to identify and visualize trend reversals on a price chart. It focuses on tracking price extremes—specifically, how high or low the market moves over a sequence of consecutive bars—to determine when a trend has lost momentum or reached an exhaustion point.

Core Logic Overview

The logic operates by monitoring the "peaks" and "valleys" of price action. Instead of simply looking at whether the price is going up or down, it calculates how many consecutive times the market has made a new high or a new low compared to previous data points.

1. Extremum Tracking The script constantly evaluates the current price bar against the highest and lowest points seen in recent history. It categorizes bars into different types:

  • Higher Highs/Lower Lows: It tracks how many times in a row the market has exceeded its previous ceiling or dropped below its previous floor.
  • Internal Bars: It identifies "inside" bars (price action contained within the previous bar's range) and ignores them, ensuring that the trend data isn't skewed by minor fluctuations.

2. Trend Detection & Momentum The user can define a specific "tendency" threshold (the GSv_tend parameter). The script counts consecutive movements:

  • If the price makes a new high for several bars in a row (meeting your chosen count), the script flags a potential upward trend or a state of strength.
  • If the price makes a new low for that same number of consecutive bars, it flags a downward trend or a state of weakness.

3. Reversal Identification The core "intelligence" of the script lies in how it handles these reversals. When the count for one direction (e.g., a series of new lows) is interrupted by a significant move in the opposite direction (a new high), the script recognizes this as a shift in market dynamics. It then identifies the specific points where the "break" occurred.

4. Visual Projection Once the script detects these pivotal points of reversal, it performs a geometric calculation to draw trend lines on your chart:

  • It connects the most recent significant peak and valley to create a visual slope.
  • These lines are designed to show the path of the price momentum, helping a trader see where the previous "strength" ended and the new "weakness" began.

Summary for the User

In simple terms, this script filters out "noise" by ignoring small movements and only reacting when the market consistently pushes in one direction for a specific number of bars. When that consistency breaks, it automatically draws lines to visualize the transition between trends, helping you identify structural changes in price movement more clearly.

Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
14 Views
0 Downloads
0 Favorites
rvmGann_sv6
//+------------------------------------------------------------------+
//|                                                  rvmGann_sv6.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 Black
//---- input parameters
extern int GSv_tend=2;
//---- buffers
double Buf1[];
double Buf2[];
double sH[];
double sL[];
double fp[];
double sp[];
double dup[];
double ddn[];
//----
bool draw_up=0,draw_dn=0,initfl=0;
int lb,fpoint,spoint;
double aH,aL,lH,lL;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   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,Buf1);
   SetIndexBuffer(1,Buf2);
   SetIndexBuffer(2,sH);
   SetIndexBuffer(3,sL);
   SetIndexBuffer(4,fp);
   SetIndexBuffer(5,sp);
   SetIndexBuffer(6,dup);
   SetIndexBuffer(7,ddn);
   SetIndexLabel(0," ");
   SetIndexLabel(1," ");
   SetIndexLabel(2,"Ñ÷.ìàêñ.");
   SetIndexLabel(3,"Ñ÷.ìèí.");
   SetIndexLabel(4,"1-ÿ òî÷êà");
   SetIndexLabel(5,"2-ÿ òî÷êà");
   SetIndexLabel(6,"ââåðõ");
   SetIndexLabel(7,"âíèç");
   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);
   SetIndexEmptyValue(2,-1);
   SetIndexEmptyValue(3,-1);
   SetIndexEmptyValue(4,-1);
   SetIndexEmptyValue(5,-1);
   SetIndexEmptyValue(6,-1);
   SetIndexEmptyValue(7,-1);
//----
   return(0);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   int cb,ai,limit,index,i;
//---- 
   index=Bars-1;
   if( counted_bars>=0 )
   {
      if( index-counted_bars<=0 )
      {
         limit=0;
      }
      else
      {
         limit=index-counted_bars;
         if( limit>index-2 )
         {
            if( initfl!=1 )
            {
               myInit();
               if( initfl!=1 )
               {
                  Alert("Ñáîé èíèöèàëèçàöèè èíäèêàòîðà!");
                  return(-1);
               }
            }
            limit=index-2;
         }
      }
   }
   else
   {
      Alert("Ñáîé ðàñ÷åòà èíäèêàòîðà!");
      return(-1);
   }
   //öèêë ïî áàðàì
   for( cb=limit;cb>=0;cb-- )
   {
      ai=index-cb;
      //åñëè ïîÿâèëñÿ íîâûé áàð
      if( lb!=ai )
      {
         lb=ai;
         //åñëè ïðåäûäóùèé áàð "âíóòðåííèé"...
         if( High[cb+1]<=aH && Low[cb+1]>=aL )
         {
         }
      }
      //åñëè òåêóùèé áàð "âíóòðåííèé"...
      if( High[cb]<=aH && Low[cb]>=aL )
      {
         //ïåðåõîäèì ê ñëåäóþùåé èòåðàöèè
         continue;
      }
      //åñëè èäåò ðàñ÷åò ðåàë-òàéì
      if( cb==0 && counted_bars>0 )
      {
      }
      else //èíà÷å åñëè ïðîñ÷èòûâàåòñÿ èñòîðèÿ
      {
         //åñëè áàð âíåøíèé
         if( High[cb]>aH && Low[cb]<aL )
         {
            //åñëè ñíà÷àëà áûë ìàêñèìóì
            if( Close[cb]<Open[cb] || ( Close[cb]==Open[cb] && Close[cb]<(Low[cb]+High[cb])/2 ) )
            {
               sL[cb]=1;
               if( High[cb]>High[cb+1] && sH[cb+1]>=GSv_tend-1 )
               {
                  sH[cb]=sH[cb+1]+1;
               }
            }
            else //èíà÷å åñëè ñíà÷àëà áûë ìèíèìóì
            {
               sH[cb]=1;
               if( Low[cb]<Low[cb+1] && sL[cb+1]>=GSv_tend-1 )
               {
                  sL[cb]=sL[cb+1]+1;
               }
            }
            if( sH[cb]>=GSv_tend )
            {
               if( draw_dn==1 )
               {
                  fpoint=spoint;
                  draw_dn=0;
               }
               draw_up=1;
            }
            else
            {
               if( sL[cb]>=GSv_tend )
               {
                  if( draw_up==1 )
                  {
                     fpoint=spoint;
                     draw_up=0;
                  }
                  draw_dn=1;
               }
            }
            //åñëè èíäèêàòîð îòðèñîâûâàåòñÿ òî ìåíÿåì çíà÷åíèå àêòèâíîãî áàðà
            if( draw_up!=draw_dn || sH[cb]>=GSv_tend || sL[cb]>=GSv_tend )
            {
               aH=High[cb];
               aL=Low[cb];
               spoint=ai;
            }
         }
         else //èíà÷å áàð íå âíåøíèé
         {
            //åñëè òîëüêî ìàêñèìóì
            if( High[cb]>aH )
            {
               if( sH[cb+1]>0 && High[cb]>High[cb+1] )
               {
                  sH[cb]=sH[cb+1]+1;
               }
               else
               {
                  sH[cb]=1;
               }
               if( sH[cb]>=GSv_tend )
               {
                  if( draw_dn==1 )
                  {
                     fpoint=spoint;
                     draw_dn=0;
                  }
                  draw_up=1;
               }
               //åñëè èíäèêàòîð îòðèñîâûâàåòñÿ òî ìåíÿåì çíà÷åíèå àêòèâíîãî áàðà
               if( draw_up==1 || sH[cb]>=GSv_tend )
               {
                  aH=High[cb];
                  aL=Low[cb];
                  spoint=ai;
               }
            }
            else //èíà÷å òîëüêî ìèíèìóì
            {
               if( sL[cb+1]>0 && Low[cb]<Low[cb+1] )
               {
                  sL[cb]=sL[cb+1]+1;
               }
               else
               {
                  sL[cb]=1;
               }
               if( sL[cb]>=GSv_tend )
               {
                  if( draw_up==1 )
                  {
                     fpoint=spoint;
                     draw_up=0;
                  }
                  draw_dn=1;
               }
               //åñëè èíäèêàòîð îòðèñîâûâàåòñÿ òî ìåíÿåì çíà÷åíèå àêòèâíîãî áàðà
               if( draw_dn==1 || sL[cb]>=GSv_tend )
               {
                  aH=High[cb];
                  aL=Low[cb];
                  spoint=ai;
               }
            }
         }
         fp[cb]=fpoint;
         sp[cb]=spoint;
         dup[cb]=draw_up;
         ddn[cb]=draw_dn;
         if( draw_up==1 && spoint==ai)
         {
            up_draw();
         }
         else
         {
            if( draw_dn==1 && spoint==ai)
            {
               dn_draw();
            }
         }
      }
   }

//----
   return(0);
  }
//+------------------------------------------------------------------+

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

//+------------------------------------------------------------------+
//| Ôóíêöèÿ ïåðâîíà÷àëüíîé èíèöèàëèçàöèè èíäèêàòîðà                  |
//+------------------------------------------------------------------+
int myInit()
  {
//---- 
   //åñëè íåäîñòàòî÷íî äàííûõ
   if( Bars<GSv_tend+1 )
   {
      Alert("Íåäîñòàòî÷íî äàííûõ íà ãðàôèêå!");
      return(-1);
   }
   if( GSv_tend<2 )
   {
      Alert("Íåâåðíûé ïàðàìåòð èíäèêàòîðà!");
      return(-1);
   }
   aH=High[Bars-1];
   aL=Low[Bars-1];
   lH=aH;
   lL=aL;
   if( High[Bars-2]>aH )
   {
      if( Low[Bars-2]>=aL || (Close[Bars-2]>Open[Bars-2] || Close[Bars-2]>(Close[Bars-2]+Open[Bars-2])/2 ) )
      {
         sH[Bars-2]=1;
      }
   }
   if( Low[Bars-2]<aL )
   {
      if(  High[Bars-2]<=aH || (Close[Bars-2]<Open[Bars-2] || Close[Bars-2]<(Close[Bars-2]+Open[Bars-2])/2 ) )
      {
         sL[Bars-2]=1;
      }
   }
   fpoint=0;
   spoint=0;
   initfl=1;
//----
   return(0);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Îòðèñîâêà èíäèêàòîðà ââåðõ                                       |
//+------------------------------------------------------------------+
int up_draw()
  {
//---- 
   double a;
   int index=Bars-1,i;
   Buf1[index-fpoint]=Low[index-fpoint];
   Buf1[index-spoint]=High[index-spoint];
   a=(spoint-fpoint)/(High[index-spoint]-Low[index-fpoint]);
   for( i=index-fpoint-1;i>index-spoint;i--)
   {
      Buf1[i]=(index-fpoint-i)/a+Low[index-fpoint];
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Îòðèñîâêà èíäèêàòîðà âíèç                                        |
//+------------------------------------------------------------------+
int dn_draw()
  {
//---- 
   double a;
   int index=Bars-1,i;
   
   Buf1[index-fpoint]=High[index-fpoint];
   Buf1[index-spoint]=Low[index-spoint];
   a=(High[index-fpoint]-Low[index-spoint])/(spoint-fpoint);
   if( index-spoint==26 ) Print(fpoint," ",spoint," ",a);
   for( i=index-fpoint-1;i>index-spoint;i--)
   {
      Buf1[i]=High[index-fpoint]-(index-fpoint-i)*a;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments