ADX Crossing_v2
Download scriptThis tool is designed for traders who want to identify specific momentum shifts in the market by monitoring the relationship between two directional indicators. Instead of just showing a continuous line, this script simplifies market data into visual signals (arrows) that highlight potential turning points in price action.
How the Logic Works
The script functions by analyzing two specific components of the ADX (Average Directional Index), which is a common technical tool used to measure the strength and direction of a trend:
- The Plus DI (+DI): This measures the upward momentum or buying pressure in the market.
- The Minus DI (-DI): This measures the downward momentum or selling pressure in the market.
The core logic revolves around "crossings." Rather than looking at just one indicator, the script constantly compares the current values of these two components against their previous values from one bar back.
Identifying the Signals
The tool places visual markers on your chart based on two specific conditions:
-
Bearish Signal (Downward Turn): The script looks for a moment where the "Buying Pressure" was previously stronger than the "Selling Pressure," but has now flipped, with "Selling Pressure" becoming the dominant force. When this crossover occurs, the script places a signal on the chart to alert you to a potential shift toward a downward trend.
-
Bullish Signal (Upward Turn): Conversely, the script monitors for moments where "Selling Pressure" was previously stronger than "Buying Pressure," but has now flipped, with "Buying Pressure" taking the lead. When this crossover occurs, it places a signal on the chart to alert you to a potential shift toward an upward trend.
Key Features for the User
- Visual Clarity: Instead of forcing you to interpret complex overlapping lines, the script filters out the noise and only highlights the exact moments where these momentum flips occur.
- Customizable Depth: You can define how many past bars the script should analyze, allowing you to balance historical context with current market activity.
- Precise Placement: The signals are plotted slightly above or below the price candles (Highs and Lows) to ensure they are clearly visible without obstructing your view of the price action.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| ADX Crossing.mq4
//| Amir
//+------------------------------------------------------------------+
#property copyright "Author - Amir"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//---- input parameters
extern int ADXbars=14;
extern int CountBars=350;
//---- buffers
double val1[];
double val2[];
double b4plusdi,nowplusdi,b4minusdi,nowminusdi;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,108);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,108);
SetIndexBuffer(0,val1);
SetIndexBuffer(1,val2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2 |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>=Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars);
SetIndexDrawBegin(1,Bars-CountBars);
int i,shift,counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=CountBars;i++) val1[CountBars-i]=0.0;
for(i=1;i<=CountBars;i++) val2[CountBars-i]=0.0;
}
for (shift = CountBars; shift>=0; shift--)
{
b4plusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift-1);
nowplusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift);
b4minusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift-1);
nowminusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift);
if (b4plusdi>b4minusdi && nowplusdi<nowminusdi)
{
val1[shift]=Low[shift]-5*Point;
}
if (b4plusdi<b4minusdi && nowplusdi>nowminusdi)
{
val2[shift]=High[shift]+5*Point;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments