RAVI Indicator

#1
Hi,
Can any one write an AFL for Range Action Verification Index.
Following is the Metacode sample :

Thanks
Shekhar

//+------------------------------------------------------------------+
//| RAVI.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_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- indicator parameters
extern int Period1=7;
extern int Period2=65;
//---- buffers
double ExtBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtBuffer);
IndicatorShortName("RAVI (" + Period1+ ","+Period2+")");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i=0;
double SMA1,SMA2,result;
//---- TODO: add your code here
for(i=0;i<Bars;i++)
{
SMA1=iMA(NULL,0,Period1,0,MODE_SMA,PRICE_CLOSE,i);
SMA2=iMA(NULL,0,Period2,0,MODE_SMA,PRICE_CLOSE,i);
result=((SMA1-SMA2)/SMA2)*100;
ExtBuffer=result;
}
//----
return(0);
}
//+------------------------------------------------------------------+
 

SwingKing

Well-Known Member
#3
Yes I think AFL is available for this on the net ...

Just search it as bandlab has advised ..

Tc.
 

daitya

Active Member
#4
Hi,
Can any one write an AFL for Range Action Verification Index.
Following is the Metacode sample :

Thanks
Shekhar

//+------------------------------------------------------------------+
//| RAVI.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_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- indicator parameters
extern int Period1=7;
extern int Period2=65;
//---- buffers
double ExtBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtBuffer);
IndicatorShortName("RAVI (" + Period1+ ","+Period2+")");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i=0;
double SMA1,SMA2,result;
//---- TODO: add your code here
for(i=0;i<Bars;i++)
{
SMA1=iMA(NULL,0,Period1,0,MODE_SMA,PRICE_CLOSE,i);
SMA2=iMA(NULL,0,Period2,0,MODE_SMA,PRICE_CLOSE,i);
result=((SMA1-SMA2)/SMA2)*100;
ExtBuffer=result;
}
//----
return(0);
}
//+------------------------------------------------------------------+




use this:

/*
RAVI stands for Range Action Verification Index.
This is a technical indicator that also helps to recognize trending markets, for the same purpose of helping trend following systems
to avoid entering whipsaw trades in sideways markets. The RAVI index is a moving average crossover system itself?it uses a 7-Day fast
average AND a 65-Day slow average. The RAVI index value is defined as the absolute value of the percentage difference between the 7
AND 65 Day averages. When a market is moving sideways, the two averages tend to have the same values, so the difference is small.
Conversely, when the market is trending, the fast average rapidly pulls away from the slow average, producing a larger difference
AND larger index value. Generally speaking, a RAVI value below 3 percent indicates sideways prices, AND above 3 percent, trending prices.
*/

x= MA(C,7)/C;
y= MA(C,65)/C;

z = x- y ;
z1 = z*100;
Plot(z1,"ravi",1,1);
Plot(-1,"",1,1);
Plot(1,"",1,1);
 

shinchan

Well-Known Member
#5
Code posted by Kartik Marar in Experiments in Technical Analysis thread.



_SECTION_BEGIN("RAVI");
P1 = Param("Short Period",7, 0,100,1);
P2 = Param("Long Period",65,0,100,1);
L1=Param("Threshold",4,2,10,1);
U= MA(C,P1)MA(C,P2);
-R=100*U/MA(C,P2);
MyColor=IIf(R>L1, colorLimecolorRed);
,Plot( R,"RAVI",Mycolor, 2| 4);
_SECTION_END();
 

Similar threads