SRVI@1

The Super Relativ Vigor Index (RVI) is a technical analysis tool designed to help traders understand the momentum and strength of price movements in the market. By analyzing the relationship between how much a price moves upward versus how much it moves downward, the script provides a visual representation of market "vigor."

Core Logic and Calculations

The indicator operates by looking at a specific number of past price candles (determined by the user-defined period). It processes these candles using two primary metrics:

  • Upward Momentum: The logic calculates the difference between the opening and closing prices over several consecutive periods. It applies a weighting system where the most recent candles carry more influence than those further back, creating a smoothed average of the "upward" movement.
  • Downward Momentum: Simultaneously, the script calculates the range between the highest and lowest points reached during those same periods. Again, it uses a weighted average to capture the intensity of the price swings.

By dividing the upward momentum by the downward momentum, the indicator produces a ratio. This ratio allows traders to see whether the market is being driven more by aggressive buying pressure or wide price fluctuations.

Visual Components

The script generates three distinct data lines in a separate window below the main price chart:

  1. The RVI Line: This is the primary indicator. It represents the raw ratio of upward momentum to downward momentum. When this line climbs, it suggests that the price movement is becoming more dominated by upward progress relative to its volatility.
  2. The Signal Line: This is a smoothed average of the RVI line. It moves more slowly than the main line and serves as a baseline. Traders often look for the RVI line to cross above or below this signal line to identify potential shifts in trend direction.
  3. The Value Line: This is an additional calculation that provides further context by combining the RVI and Signal values. It acts as a supplementary reference point to help gauge the overall magnitude of the market's vigor.

How it Helps Traders

Essentially, this tool filters out "noise" from the market to show the underlying strength of a trend. Instead of just looking at whether the price is going up or down, the RVI helps traders see how strongly it is moving. By observing where the RVI and its Signal line interact, users can better identify periods of sustained momentum or potential points of exhaustion where a trend might be losing steam.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
SRVI@1
//+------------------------------------------------------------------+
//|                                    Super Relativ Vigor Index.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2005, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Green
#property  indicator_color2  Red
#property  indicator_color3  Yellow
//---- indicator parameters
extern int ExtRVIPeriod=10;
//---- indicator buffers
double     ExtRVIBuffer[];
double     ExtRVISignalBuffer[];
double     ExtRVIValue[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtRVIBuffer);
   SetIndexBuffer(1,ExtRVISignalBuffer);
   SetIndexBuffer(2,ExtRVIValue);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
//---- drawing settings   
   SetIndexDrawBegin(0,ExtRVIPeriod+3);   
   SetIndexDrawBegin(1,ExtRVIPeriod+7);     
   SetIndexDrawBegin(2,ExtRVIPeriod);     
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("RVI("+ExtRVIPeriod+")");
   SetIndexLabel(0,"RVI");
   SetIndexLabel(1,"RVIS");
   SetIndexLabel(2,"Value");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Relativ Vigor Index                                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,j,nLimit,nCountedBars;
   double dValueUp,dValueDown,dNum,dDeNum;
//----
   if(Bars<=ExtRVIPeriod+8) return(0);
//----
   nCountedBars=IndicatorCounted();
//---- check for possible errors
   if(nCountedBars<0) return(-1);
//---- last counted bar will be recounted
   nLimit=Bars-ExtRVIPeriod-4;
   if(nCountedBars>ExtRVIPeriod+4)
      nLimit=Bars-nCountedBars;
//---- RVI counted in the 1-st buffer
   for(i=0; i<=nLimit; i++)
     {
      dNum=0.0; 
      dDeNum=0.0;
      for(j=i; j<i+ExtRVIPeriod; j++)
        {
         dValueUp=((Close[j]-Open[j])+2*(Close[j+1]-Open[j+1])+2*(Close[j+2]-Open[j+2])+(Close[j+3]-Open[j+3]))/6;
         dValueDown=((High[j]-Low[j])+2*(High[j+1]-Low[j+1])+2*(High[j+2]-Low[j+2])+(High[j+3]-Low[j+3]))/6;
         dNum+=dValueUp;
         dDeNum+=dValueDown;
        }
      if(dDeNum!=0.0)
         ExtRVIBuffer[i]=dNum/dDeNum;
         //==----==//
         //ExtRVIValue[i]=ExtRVISignalBuffer[i]-ExtRVIBuffer[i]*2;
      else
         ExtRVIBuffer[i]=dNum;   
      //==----==//
      ExtRVIValue[i]=ExtRVISignalBuffer[i]+ExtRVIBuffer[i]*2;
     }
//---- signal line counted in the 2-nd buffer
   nLimit=Bars-ExtRVIPeriod-7;
   if(nCountedBars>ExtRVIPeriod+8)
      nLimit=Bars-nCountedBars+1;
   for(i=0; i<=nLimit; i++)
      ExtRVISignalBuffer[i]=(ExtRVIBuffer[i]+2*ExtRVIBuffer[i+1]+2*ExtRVIBuffer[i+2]+ExtRVIBuffer[i+3])/6;
      //==----==//
      ExtRVIValue[i]=ExtRVISignalBuffer[i]+ExtRVIBuffer[i]*4;
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments