ma_MA_Slope_SigMA_roc
Download scriptThis technical indicator is designed to analyze price momentum by measuring the rate of change in a Moving Average. Instead of looking at the raw price of an asset, it focuses on how fast a specific trend is accelerating or decelerating.
The logic operates through three distinct layers:
1. Trend Identification (The Base Layer) The first step involves calculating a standard Moving Average based on a user-defined period (defaulting to 21). This acts as the foundation of the indicator, smoothing out market noise to reveal the underlying trend of the price.
2. Rate of Change Calculation (The Momentum Layer) Once the moving average is established, the script calculates the "Rate of Change" (ROC) of that average. It compares the current value of the moving average against its previous value (based on a specific distance). By calculating the difference between these two points and dividing it by the current value, the indicator produces a percentage-like figure. This tells you how aggressively the trend is moving upward or downward at any given moment.
3. Signal Smoothing (The Final Layer) To ensure that the momentum data is easy to read and doesn't fluctuate too wildly, the script applies a second Moving Average specifically to the Rate of Change values. This "Signal" line smooths out the volatility of the momentum jumps, making it easier for a user to identify sustained shifts in trend strength.
Summary for the Trader In practical terms, this tool doesn't just show you where the price is; it shows you how "energetic" the current trend is. When the resulting lines move significantly, it indicates strong momentum. When they flatten out, it suggests the trend is losing steam, providing a visual cue of potential exhaustion or stabilization in the market.
//+------------------------------------------------------------------+
//| ma_MA_Slope_smz_roc.mq4 |
//| |
//+------------------------------------------------------------------+
// ma roc sig ma
#property copyright ""
#property link ""
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 DodgerBlue //
// #property indicator_width1 2
#property indicator_width2 2
extern int MA_Period = 21;
extern int MA_Mode = 1;
extern int MA_Price = 0;
extern int roc_length = 1;
extern int SigMA_Period = 11;
extern int SigMA_Mode = 1;
double buffer1[];
double buffer11[];
double buffer12[];
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
SetIndexBuffer(2,buffer1);
SetIndexBuffer(0,buffer11);
SetIndexBuffer(1,buffer12);
SetIndexLabel(0,"MA1 "+MA_Period+" roc");
SetIndexLabel(1,"MA1rocSigMA "+SigMA_Period+"");
IndicatorShortName("MA roc ("+MA_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,MA_Period,0,MA_Mode,MA_Price,i);
for(i=limit; i>=0; i--)
{
if (buffer1[i]!=0)
buffer11[i] = (buffer1[i]-buffer1[i+roc_length])/(buffer1[i]);
}
for(i=limit; i>=0; i--)
buffer12[i] = iMAOnArray(buffer11,0,SigMA_Period,0,SigMA_Mode,i);
return(0);
}
Comments