Author: Vladislav Goshkov
ROC2_VG_v1

This tool is designed to help traders visualize the speed and direction of price movements by comparing current market prices against historical data over two different timeframes simultaneously. Instead of just looking at where the price is, this script helps you see how fast it is moving.

How it Works

The logic operates by calculating "Rate of Change" values across two independent settings. It identifies specific price points in the past and compares them to the current closing prices to determine momentum.

1. Dual-Layer Analysis The script tracks two separate lines on your chart:

  • Line 1 (Short-term): Typically set to a faster timeframe to capture immediate market reactions.
  • Line 2 (Long-term): Typically set to a slower timeframe to identify the broader trend.

2. Customizable Momentum Types The tool is highly versatile because it allows you to choose different mathematical ways to measure "change." Depending on your preference, it can calculate:

  • Simple Momentum: The raw difference between two prices.
  • Percentage Change: The speed of price movement expressed as a percentage (useful for comparing different assets).
  • Ratio Analysis: The relative proportion of the current price compared to the past price.

3. Visual Cues and Thresholds To make the data easy to read at a glance, the script includes pre-defined horizontal levels (marked on your screen). These act as "zones":

  • When the lines move above these positive thresholds, it indicates accelerating upward momentum.
  • When the lines drop below the negative thresholds, it suggests accelerating downward pressure.
  • The zero line serves as the baseline; staying near it indicates a stabilizing or sideways market, while large swings away from it signal high volatility.

Summary for the User

By looking at these two lines together, you can see if the "fast" momentum matches the "slow" momentum. If both lines are moving in the same direction and increasing in intensity, it suggests a strong trend is forming. If they diverge—for example, if the fast line drops while the slow line stays high—it may signal that the current trend is losing steam or about to reverse.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
ROC2_VG_v1
//+------------------------------------------------------------------+
//|                                                      ROC2_VG.mq4 |
//|                        Copyright © 2006, Vladislav Goshkov (VG). |
//|                                                      4vg@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Vladislav Goshkov"
#property link      "4vg@mail.ru"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  Red
#property indicator_color2  Blue
#property indicator_level1  0.005
#property indicator_level2  0.002
#property indicator_level3  0.00
#property indicator_level4  -0.002
#property indicator_level5  -0.005

//---- input parameters
extern int ROCPeriod1  = 8;
extern int ROCPeriod2  = 14;
extern int ROCType1    = 0;
extern int ROCType2    = 0;
//---- buffers
double Buffer1[];
double Buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Buffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Buffer2);
//---- name for DataWindow and indicator subwindow label
   string Type1="",Type2="";
   switch(ROCType1){
     case 1 : Type1="MOM";     break; 
     case 2 : Type1="ROC";     break; 
     case 3 : Type1="ROCP";    break; 
     case 4 : Type1="ROCR";    break; 
     case 5 : Type1="ROCR100"; break; 
     default: Type1="ROCP";    break;
     }

   switch(ROCType2){
     case 1 : Type2="MOM";     break; 
     case 2 : Type2="ROC";     break; 
     case 3 : Type2="ROCP";    break; 
     case 4 : Type2="ROCR";    break; 
     case 5 : Type2="ROCR100"; break; 
     default: Type2="ROCP";    break;
     }
   short_name="ROC2_VG( "+Type1+" = "+ROCPeriod1+" and "+Type2+" = "+ROCPeriod2+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,MathMax(ROCPeriod1,ROCPeriod2));
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Rate-Of-Change (ROC)                                             |
//+------------------------------------------------------------------+
int start(){
int i,counted_bars=IndicatorCounted();
double price=0.0, prevPrice = 0.0;
//----
   if(Bars<=MathMax(ROCPeriod1,ROCPeriod2)) return(0);
//---- initial zero
   if(counted_bars<1){
      for(i=1;i<=ROCPeriod1;i++) Buffer1[Bars-i]=0.0;
      for(i=1;i<=ROCPeriod2;i++) Buffer2[Bars-i]=0.0;
      }
//----
   i=Bars-ROCPeriod1-1;
   if(counted_bars>=ROCPeriod1) i=Bars-counted_bars-1;
   while(i>=0){
      price     = Close[i];
      prevPrice = Close[i+ROCPeriod1];
      switch(ROCType1){
         case 1 : Buffer1[i]= (price - prevPrice);         break; //"MOM"
         case 2 : Buffer1[i]= ((price/prevPrice)-1)*100;   break; //"ROC"
         case 3 : Buffer1[i]= (price-prevPrice)/prevPrice; break; //"ROCP"
         case 4 : Buffer1[i]= (price/prevPrice);           break; //"ROCR"
         case 5 : Buffer1[i]= (price/prevPrice)*100;       break; //"ROCR100"
         default: Buffer1[i]= (price-prevPrice)/prevPrice; break;
         }
      i--;
     }
//----
   i=Bars-ROCPeriod2-1;
   if(counted_bars>=ROCPeriod2) i=Bars-counted_bars-1;
   while(i>=0){
      price     = Close[i];
      prevPrice = Close[i+ROCPeriod2];
      switch(ROCType2){
         case 1 : Buffer2[i]= (price - prevPrice);         break; //"MOM"
         case 2 : Buffer2[i]= ((price/prevPrice)-1)*100;   break; //"ROC"
         case 3 : Buffer2[i]= (price-prevPrice)/prevPrice; break; //"ROCP"
         case 4 : Buffer2[i]= (price/prevPrice);           break; //"ROCR"
         case 5 : Buffer2[i]= (price/prevPrice)*100;       break; //"ROCR100"
         default: Buffer2[i]= (price-prevPrice)/prevPrice; break;
         }
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments