mad
Download scriptThis tool is designed to help traders visualize the momentum of price trends by measuring the "slope" or rate of change of a Moving Average. Instead of looking at the price itself, this indicator focuses on how quickly the average price is shifting in a specific direction.
Core Concept: Measuring Momentum
The primary goal of this script is to quantify the "steepness" of a trend. In trading, a moving average helps smooth out market noise to show the general direction of the price. However, knowing the direction isn't always enough; traders often want to know how strongly that direction is being pushed. This indicator provides that specific data point by calculating the distance moved between consecutive points on the moving average.
How the Logic Works
To produce its visual output, the script follows a structured three-step logic:
- Establishing the Baseline: The tool identifies a Simple Moving Average (SMA) based on a user-defined period (the default is 50). This represents the "smoothed" path of the market price over that timeframe.
- Calculating the Delta (Change): The script looks at two consecutive points on this moving average. It calculates the mathematical difference between the current value and the previous value. By subtracting the old value from the new one, it determines the magnitude of the move.
- Normalizing the Movement: To ensure the results are readable and consistent across different types of assets (like currencies with very small price movements or stocks with larger ones), the script converts this difference into "Points." This standardizes the measurement, allowing you to see a clear numerical representation of the slope.
What it Shows on Your Chart
The result is displayed in a separate window below your main price chart. Rather than a jagged price line, you will see a continuous line representing the velocity of the trend:
- Upward Movement: When the moving average is climbing, the indicator reflects a positive slope.
- Downward Movement: When the moving average is falling, the indicator reflects a negative slope.
- Flat Movement: If the moving average is moving sideways (horizontal), the indicator will stay near zero, signaling a lack of momentum or a period of consolidation.
By using this logic, you can quickly identify whether a trend is accelerating, decelerating, or losing steam, providing a clearer picture of market dynamics than a standard moving average alone.
//+------------------------------------------------------------------+
//| MovingAverage Steigung.mq4 |
//| Copyright © 2010, Thomas Quester |
//| www.olfolders.de |
//+------------------------------------------------------------------+
// mad = Moving Average Delta
#property copyright "Copyright © 2010, Thomas Quester"
#property link "www.olfolders.de"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int Periode=50;
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i;
int col;
string name;
double p,d;
double a,b,c;
//p = iMA(NULL,0,Periode,0,MODE_SMMA,PRICE_MEDIAN,Bars-counted_bars);
for (i=Bars;i>0;i--)
{
d = iMA(NULL,0,Periode,0,MODE_SMA,PRICE_OPEN,i-1);
//p = iMA(NULL,0,Periode,0,MODE_SMA,PRICE_OPEN,i);
ExtMapBuffer1[i-1] = (d-p)/Point;
p=d;
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+
Comments