DT_ZZ_Impuls_Slope
Download scriptThis technical indicator is designed to measure and visualize the "momentum" or the intensity of price movements on a trading chart. Instead of simply looking at whether the price is going up or down, this tool focuses on how aggressively the market is moving over a specific period of time.
How it Works
The logic behind this script can be broken down into three main processes:
1. Identifying Key Price Points (ZigZag Logic) The indicator first scans the historical price data to identify significant "peaks" (highs) and "troughs" (lows). It looks back over a user-defined period (the Depth) to determine if a price point is high or low enough to be considered a meaningful turn in the market. This prevents the indicator from reacting to minor, insignificant price flickers, focusing instead on the major "swings."
2. Measuring the Movement Once the script identifies a significant peak and its corresponding trough, it calculates two specific values:
- The Height (h): The vertical distance between the high and the low. This represents how much price was actually moved.
- The Speed (s): The horizontal distance (time) it took for that move to happen.
By combining these two values, the tool determines the "slope" of the price movement—essentially calculating how "fast" the market traveled from point A to point B.
3. Visualizing the Impulse The final output is a visual representation of this momentum. The script converts the calculated slope into a mathematical arc (using a trigonometric function).
- If the price moved upward rapidly, the indicator reflects that strength.
- If the price moved downward rapidly, it reflects that intensity in the opposite direction.
Summary for Traders
Essentially, this tool acts as a momentum speedometer. It filters out the "noise" of the market to find significant structural turns and then calculates the force behind those moves. For a user, this helps in understanding whether a current trend is driven by strong, aggressive momentum or if it is moving slowly and weakly.
//+------------------------------------------------------------------+
//| DT_ZZ_Impuls.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, klot."
#property link "klot@mail.ru"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Gold
#property indicator_level1 0.0
//---- indicator parameters
extern int ExtDepth=6;
extern double scale=3000;
//---- indicator buffers
double zzL[];
double zzH[];
double zz[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
//---- indicator buffers mapping
SetIndexBuffer(0,zz);
SetIndexBuffer(1,zzH);
SetIndexBuffer(2,zzL);
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexEmptyValue(2,0.0);
//---- indicator short name
IndicatorShortName("DT_Impuls("+ExtDepth+")");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int i,shift,pos,lasthighpos,lastlowpos,curhighpos,curlowpos;
double curlow,curhigh,lasthigh,lastlow;
double min, max;
int s;
double h;
ArrayInitialize(zz,0.0);
ArrayInitialize(zzL,0.0);
ArrayInitialize(zzH,0.0);
lasthighpos=Bars; lastlowpos=Bars;
lastlow=Close[Bars];lasthigh=Close[Bars];
for(shift=Bars-ExtDepth; shift>0; shift--)
{
curlowpos=iLowest(NULL,0,MODE_CLOSE,ExtDepth,shift);
curlow=Close[curlowpos];
curhighpos=iHighest(NULL,0,MODE_CLOSE,ExtDepth,shift);
curhigh=Close[curhighpos];
//------------------------------------------------
if( curlow>=lastlow ) { lastlow=curlow; }
else {
//èäåì âíèç
if( lasthighpos>curlowpos ) {
zzL[curlowpos]=curlow;
min=100000; pos=lasthighpos;
for(i=lasthighpos; i>=curlowpos; i--) {
if (zzL[i]==0.0) continue;
if (zzL[i]<=min) { min=zzL[i]; pos=i; }
}
}
lastlowpos=curlowpos;
lastlow=curlow;
}
//--- high
if( curhigh<=lasthigh ) { lasthigh=curhigh;}
else {
// èäåì ââåðõ
if( lastlowpos>curhighpos ) {
zzH[curhighpos]=curhigh;
max=-100000; pos=lastlowpos;
for(i=lastlowpos; i>=curhighpos; i--) {
if (zzH[i]==0.0) continue;
if (zzH[i]>=max) { max=zzH[i]; pos=i; }
}
}
lasthighpos=curhighpos;
lasthigh=curhigh;
}
//---
if( lasthighpos>=lastlowpos ) {
h=(zzH[lasthighpos]-zzL[lastlowpos]);
s=(lasthighpos-shift);
zz[shift]=-MathArctan(scale*(h/(1.0*s)));
}
if( lastlowpos>=lasthighpos ) {
h=(zzH[lasthighpos]-zzL[lastlowpos]);
s=(lastlowpos-shift);
zz[shift]=MathArctan(scale*(h/(1.0*s)));
}
//----------------------------------------------------------------------
}
return(0);
}
//+------------------------------------------------------------------+
Comments