FILTER_ADX_(AM)
Download scriptThe FILTER_ADX (AM) is a specialized technical analysis tool designed to help traders identify high-probability trend movements by filtering out market noise. It functions by analyzing the relationship between three specific components of the ADX (Average Directional Index) indicator: the main trend strength, and two directional movement lines (Plus DI and Minus DI).
How the Logic Works
The script works by comparing current market momentum against the previous data point to determine if a move is gaining or losing steam. It evaluates four specific scenarios based on the interaction between trend strength and direction:
- Strong Upward Momentum: The tool identifies instances where the upward directional force is stronger than the downward force, and the overall trend strength is actively increasing.
- Weakening Upward Movement: It flags situations where the upward force still leads, but the overall trend strength is starting to decrease (indicating a potential slowdown).
- Strong Downward Momentum: The script detects when the downward directional force outweighs the upward movement while the overall trend strength is also increasing.
- Weakening Downward Movement: It highlights moments where the downward force is dominant but the overall trend strength is beginning to drop, suggesting a possible reversal or consolidation.
Key Features for the User
- Multi-Timeframe Analysis: You can choose to view these signals on various timeframes (from 1-minute charts up to monthly charts), allowing you to align your short-term trades with broader market trends.
- Visual Clarity: The logic translates complex mathematical calculations into a clear visual histogram. By separating the four conditions into different colors and thicknesses, it allows for an immediate "at-a-glance" understanding of whether the market is trending aggressively, stalling, or shifting direction.
- Customizable Sensitivity: Users can adjust the calculation period and the price source, making it adaptable to different types of assets—whether you are trading volatile forex pairs or more stable commodities.
In essence, this tool acts as a sophisticated filter that distinguishes between "strong" directional moves and "weak" fluctuations, helping you stay on the right side of the market trend.
//+------------------------------------------------------------------+
//| FILTER_ADX_(AM).mq4 |
//+------------------------------------------------------------------+
#property copyright "Andrey Matvievskiy"
#property link ""
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 4
//---- input parameters
extern int TF=0;
extern int ADXPeriod=14;
extern int PRICE=0;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ADX1,pDI1,mDI1;
double ADX2,pDI2,mDI2;
string TimeFrameStr;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Red);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,Green);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1,Red);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1,Green);
SetIndexBuffer(3,ExtMapBuffer4);
switch(TF)
{
case 1 : TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current Timeframe"; TF=0;
}
IndicatorShortName("FILTER ADX(AM) ("+TimeFrameStr+")");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(), limit, i;
if(counted_bars<0) return(-1);
limit=Bars-counted_bars;
for(i=limit; i>=0; i--)
{
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=0;
ExtMapBuffer3[i]=0;
ExtMapBuffer4[i]=0;
ADX1=iADX (NULL,TF,ADXPeriod,PRICE,0,i);
pDI1=iADX (NULL,TF,ADXPeriod,PRICE,1,i);
mDI1=iADX (NULL,TF,ADXPeriod,PRICE,2,i);
ADX2=iADX (NULL,TF,ADXPeriod,PRICE,0,i+1);
pDI2=iADX (NULL,TF,ADXPeriod,PRICE,1,i+1);
mDI2=iADX (NULL,TF,ADXPeriod,PRICE,2,i+1);
if (pDI1 < mDI1 && ADX1 > ADX2){
ExtMapBuffer1[i] = 1;
}
if (pDI1 > mDI1 && ADX1 > ADX2){
ExtMapBuffer2[i] = 1;
}
if (pDI1 < mDI1 && ADX1 < ADX2){
ExtMapBuffer3[i] = 1;
}
if (pDI1 > mDI1 && ADX1 < ADX2){
ExtMapBuffer4[i] = 1;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments