w35260
Download scriptThis custom indicator is designed to provide visual cues regarding market momentum and trend direction by analyzing price movements through a two-step smoothing process. Instead of looking at raw price alone, the script filters out "noise" to identify the underlying strength of the market.
Core Logic and Methodology
The tool operates by calculating the difference between two distinct sets of moving data. Here is the breakdown of how that logic flows:
1. Dual Momentum Analysis The script looks at two different speeds of market movement simultaneously—one designated as "Fast" and one as "Slow."
- The Fast settings are designed to react quickly to recent price changes.
- The Slow settings are designed to provide a broader, more stable view of the market trend.
2. Calculating the Variance (The Difference) The primary logic works by subtracting the Slow movement data from the Fast movement data. By finding the mathematical difference between these two layers, the indicator identifies whether the current momentum is accelerating or decelerating. This creates a unique "Slope Direction" value that highlights where the price pressure is shifting in real-time.
3. The Signal Smoothing Layer Because market data can sometimes be erratic or "jumpy," the script takes the raw difference calculated in the previous step and applies a final smoothing average (a Simple Moving Average). This second layer of processing acts as a filter, ensuring that the resulting signal line is fluid and easier to read, rather than a jagged set of spikes.
Visual Representation
The indicator displays this information in two distinct ways on your chart:
- The Histogram: Represents the raw difference between the fast and slow movements, allowing you to see the immediate "push" of the market.
- The Signal Line: A smoothed line that represents the averaged trend of that difference, which helps traders identify more consistent directional shifts.
In summary, this script acts as a momentum filter. It measures how much faster the current price is moving compared to its historical average and then smooths that data into a readable visual format to help identify the strength and direction of market trends.
//+------------------------------------------------------------------+
//| w35260.mq4 |
//| IgorS |
//| igor.senych@gmail.com |
//+------------------------------------------------------------------+
#property copyright "IgorS"
#property link "igor.senych@gmail.com"
extern int p_fast = 21;
extern int t_fast = 3;
extern int pr_fast = 0;
extern int p_slow = 34;
extern int t_slow = 3;
extern int pr_slow = 0;
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Purple
#property indicator_color2 Red
#property indicator_width1 2
//---- indicator parameters
extern int Signal=9;
//---- indicator buffers
double sdlBuffer[];
double SignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_LINE);
//---- indicator buffers mapping
SetIndexBuffer(0,sdlBuffer);
SetIndexBuffer(1,SignalBuffer);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("w35260");
SetIndexLabel(0,"sdl_CD");
SetIndexLabel(1,"Signal");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| w35260 |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- sdlcd counted in the 1-st buffer
for(int i=0; i<limit; i++)
sdlBuffer[i]=iCustom(Symbol(),0,"Slope_Direction_Line",p_fast,t_fast,pr_fast,2,i)-iCustom(Symbol(),0,"Slope_Direction_Line",p_slow,t_slow,pr_slow,2,i);
//---- signal line counted in the 2-nd buffer
for(i=0; i<limit; i++)
SignalBuffer[i]=iMAOnArray(sdlBuffer,Bars,Signal,0,MODE_SMA,i);
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments