R_Volatility_I





//+------------------------------------------------------------------+
//|                                                          RSI.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_minimum 20
#property indicator_maximum 80
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int RVIPeriod=10;
//---- buffers
double RSIBuffer[];
double PosBuffer[];
double NegBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
   SetIndexBuffer(1,PosBuffer);
   SetIndexBuffer(2,NegBuffer);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,RSIBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="R_Volatility_I("+RVIPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,RVIPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   int    i,counted_bars=IndicatorCounted();
   double rel,negative,positive;
//----
   if(Bars<=RVIPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=RVIPeriod;i++) RSIBuffer[Bars-i]=0.0;
//----
   i=Bars-RVIPeriod-1;
   if(counted_bars>=RVIPeriod) i=Bars-counted_bars-1;
   while(i>=0)
      {
      positive=iStdDev(NULL,0,RVIPeriod,0,MODE_EMA,PRICE_HIGH,i);
      negative=iStdDev(NULL,0,RVIPeriod,0,MODE_EMA,PRICE_LOW,i);
      RSIBuffer[i]=100.0-100.0/(1+positive/negative);
      i--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:



Indicator Curves created:


Implements a curve of type DRAW_LINE

Indicators Used:

Standard Deviation indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: