Author: DragoTrade
S-RoC

The S-RoC is a specialized technical analysis tool designed to help traders visualize and interpret the momentum of an asset's price over time. Instead of looking at raw price fluctuations, this indicator smooths out "market noise" to reveal the underlying trend velocity.

Core Methodology

The logic behind the script relies on two distinct types of mathematical averages:

  1. Moving Averages: The script utilizes a specific type of moving average (Exponential Moving Average) to identify the "smoothed" price of the asset. By using these averages rather than raw prices, the indicator ignores minor, insignificant price flickers and focuses on the broader direction of the market.
  2. Comparative Analysis: The tool functions by comparing the current smoothed price against a previous smoothed price from a set distance back in time (determined by the user-defined periods).

How it Works in Practice

The indicator calculates the percentage difference between these two points:

  • It takes the current smoothed value.
  • It looks back at the smoothed value from a specific number of bars ago.
  • It then determines the mathematical rate of change (the "Rate of Change" or RoC) between those two points as a percentage.

Visual Representation and Interpretation

The result is plotted in a separate window below your main price chart as a continuous line.

  • Trend Strength: A rising line suggests that the current price momentum is strengthening relative to where it was in the past.
  • Trend Weakness: A falling line indicates that the momentum is decelerating or reversing.
  • Stability: Because the logic uses smoothed averages for both the current and past points, the resulting line is designed to be more stable and less erratic than standard price oscillators, making it easier for a trader to identify sustained shifts in market behavior.

By adjusting the two primary periods (the Smoothing Period and the Lookback Period), users can customize the sensitivity of the indicator—choosing whether they want to see short-term, rapid momentum shifts or long-term, structural trend changes.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
S-RoC
//+------------------------------------------------------------------+
//|                                                        S-RoC.mq4 |
//|                                    Copyright (C) 2009 DragoTrade |
//|                        Licensed under GNU General Public License |
//+------------------------------------------------------------------+
#property copyright "DragoTrade" 

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int MA_Period=13;
extern int ROC_Period=21;
//---- buffers
double b[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,b);
   IndicatorShortName("S-RoC("+MA_Period+", "+ROC_Period+")");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i=Bars-(ROC_Period+MA_Period)-1;
   double t,curr,prev;
   while(i>=0)
   {
      curr=iMA(NULL,0,MA_Period,0,MODE_EMA,PRICE_CLOSE,i);
      prev=iMA(NULL,0,MA_Period,0,MODE_EMA,PRICE_CLOSE,i+ROC_Period);
      if(prev!=0)
      {
         t=(curr-prev)/prev;
      }
      b[i]=t;
      i--;
   }
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments