ma_2MA_Slope_SigMA_roc

Download script
Author:
ma_2MA_Slope_SigMA_roc

This technical indicator is designed to help traders visualize and smooth out the momentum changes of two different Moving Averages (MA). Instead of looking at the price directly, this tool analyzes how much the "averages" themselves are shifting over time, providing a cleaner look at trend acceleration.

Here is a breakdown of the logic used by the script:

1. The Foundation: Dual Moving Averages

The script begins by identifying two primary Moving Averages. These are standard indicators that smooth out price action to reveal the underlying trend. By using two different periods (for example, one short-term and one medium-term), the script can track both immediate momentum and broader market direction simultaneously.

2. Calculating "Rate of Change" (ROC)

Rather than simply plotting these Moving Averages on your chart, the script calculates the Rate of Change (ROC) for each of them.

  • It looks at the difference between the current value of a Moving Average and its value from a specific number of bars ago.
  • By dividing this difference by the current value, it determines the percentage of growth or decline.
  • The Goal: This tells you how "fast" the trend is moving. A high ROC indicates a surging trend, while a low or flat ROC suggests the trend is losing steam or moving sideways.

3. Signal Smoothing (SigMA)

Because raw Rate of Change data can sometimes be "jittery" or produce noisy signals, the script applies an additional layer of processing. It takes the ROC results calculated in the previous step and runs them through a second Moving Average (referred to as the "Signal MA").

This smoothing process filters out minor market noise, leaving you with a much cleaner line that highlights the significant shifts in momentum.

Summary of the Visual Output

The indicator produces four distinct data lines based on this logic:

  • Two Primary ROC Lines: These show the raw percentage change for your two chosen Moving Averages.
  • Two Signal Lines: These are the smoothed versions of those changes, designed to help you identify more reliable trend turns and momentum shifts.

In essence, this script transforms standard moving averages into a dynamic "speedometer" for the market, helping you see not just where the price is going, but how much power is behind its current movement.

Indicators Used
Moving average indicatorMoving average indicator
11 Views
0 Downloads
0 Favorites
ma_2MA_Slope_SigMA_roc
//+------------------------------------------------------------------+
//|                                        ma_2MA_Slope_smz_roc.mq4  |
//|                                                                  |
//+------------------------------------------------------------------+
// 2mas roc sig ma

#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers    4
#property indicator_color1     Blue
#property indicator_color2     DodgerBlue //
#property indicator_color3     Maroon
#property indicator_color4     Red

//#property indicator_width1     2
//#property indicator_width2     2

//#property indicator_minimum    -350
//#property indicator_maximum     350

//#property indicator_level1     100
//#property indicator_level2     -100
//#property indicator_levelcolor DarkSlateGray



extern int MA1_Period      = 21;
extern int MA1_Mode        = 1;
extern int MA1_Price       = 0;


extern int MA2_Period      = 34;
extern int MA2_Mode        = 1;
extern int MA2_Price       = 0;

extern int roc_length      = 1;


extern int      SigMA_Period  = 11;
extern int      SigMA_Mode    = 1;


double buffer1[];
double buffer2[];

double buffer11[];
double buffer21[];

double buffer12[];
double buffer22[];

//+------------------------------------------------------------------+


int init()
{
   IndicatorBuffers(6);

   SetIndexBuffer(4,buffer1);
   SetIndexBuffer(0,buffer11);
   SetIndexBuffer(1,buffer12);
  
   SetIndexBuffer(5,buffer2);  
   SetIndexBuffer(2,buffer21);
   SetIndexBuffer(3,buffer22);

   SetIndexLabel(0,"MA1 "+MA1_Period+" roc");
   SetIndexLabel(1,"MA1rocSigMA "+SigMA_Period+"");
   SetIndexLabel(2,"MA2 "+MA2_Period+" roc");
   SetIndexLabel(3,"MA2rocSigMA "+SigMA_Period+"");

   IndicatorShortName("MA roc ("+MA1_Period+","+MA2_Period+") SigMA ("+SigMA_Period+") ");


   return(0);
}

//---

int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+


int start()
{
   int counted_bars=IndicatorCounted();
   int limit,i;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;
//limit=MathMax(limit,SigMA_Period);


   for(i=limit; i>=0; i--)
   {
   buffer1[i] =iMA(NULL,0,MA1_Period,0,MA1_Mode,MA1_Price,i);
   buffer2[i] =iMA(NULL,0,MA2_Period,0,MA2_Mode,MA2_Price,i);
   }
     for(i=limit; i>=0; i--)
      {
  
      if (buffer1[i]!=0)
      buffer11[i] =   (buffer1[i]-buffer1[i+roc_length])/(buffer1[i]);

      if (buffer2[i]!=0)
      buffer21[i] =   (buffer2[i]-buffer2[i+roc_length])/buffer2[i];
      
      }  

   
   for(i=limit; i>=0; i--)
  
      buffer12[i] = iMAOnArray(buffer11,0,SigMA_Period,0,SigMA_Mode,i);
     
    
   for(i=limit; i>=0; i--)
         
      buffer22[i] = iMAOnArray(buffer21,0,SigMA_Period,0,SigMA_Mode,i);
  
   


   return(0);
}

Comments