Author: Copyright � 2005, MetaQuotes Software Corp.
Ravi_v2

This tool is designed to provide traders with a visual representation of market momentum by measuring the percentage difference between two different moving averages. Instead of looking at price alone, it analyzes how much faster or slower short-term price action is moving compared to long-term trends.

How the Logic Works

The script operates by calculating two distinct "Moving Averages" simultaneously:

  1. Short-Term Average: This tracks the recent price history over a small number of periods (set by the user). It reacts quickly to current market fluctuations.
  2. Long-Term Average: This tracks the price history over a much larger number of periods, representing the broader, smoother trend of the market.

The Calculation Process

The core logic follows three specific steps to generate the data you see on your chart:

  • Comparison: The script looks at the current value of the Short-Term Average and compares it against the Long-Term Average.
  • Percentage Difference: It subtracts the Long-Term value from the Short-Term value and then divides that result by the Long-Term value. By multiplying this by 100, it converts the raw difference into a clear percentage.
  • Visual Output: This percentage is plotted on a separate window below your main price chart as a red line.

What This Means for the Trader

The resulting line acts as a "momentum oscillator."

  • When the line moves upward, it indicates that the short-term price is rising faster than the long-term trend, suggesting increasing bullish momentum.
  • When the line moves downward, it shows that the short-term price is falling relative to the long-term trend, indicating bearish momentum.
  • The magnitude of the line's movement tells you the strength of the trend; a very high or low percentage suggests an aggressive move in one direction, while a flat line near zero suggests that the short-term and long-term trends are in equilibrium.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Ravi_v2
#property link "http://www.forex-instruments.info"
//+------------------------------------------------------------------+
//|                                                         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); 
  if ( SMA2 != 0 )  result=((SMA1-SMA2)/SMA2)*100; 
   ExtBuffer[i]=result; 
   } 
  
//---- 
   return(0); 
  } 
//+------------------------------------------------------------------+ 

Comments