ADX Crossing v.2.0
Download scriptThis tool is designed to assist traders by identifying specific shifts in market momentum, helping to highlight potential entry points where the "strength" of the price movement changes direction. It works by analyzing two distinct components of market trend strength: the upward pressure (Positive Directional Indicator) and the downward pressure (Negative Directional Indicator).
How the Logic Works
The script constantly monitors these two pressures to see if one overcomes the other. Instead of just looking at where the price is currently moving, it looks for a "crossover" event—a moment when the lead changes from one direction to another.
- Buy Signals: The tool looks for a specific moment when the upward pressure was previously lower than the downward pressure but has now climbed above it. When this crossover occurs, the script identifies it as a potential bullish move and places a visual marker (a green arrow) just below the price candle.
- Sell Signals: Conversely, it monitors for moments where the downward pressure was previously lower than the upward pressure but has now surged above it. When this happens, the script identifies it as a potential bearish move and places a visual marker (a red arrow) just above the price candle.
Key Features for the User
- Visual Alerts: Rather than forcing you to watch the charts constantly, the script provides immediate visual cues on your screen. It places markers at the exact point where the trend crossover is detected.
- Audio Notifications: To ensure you don't miss a momentum shift while away from your screen, the tool includes an optional audio alert. It is programmed to play a sound only once per signal to avoid repetitive noise.
- Customizable Sensitivity: The logic allows you to adjust the "lookback" period (the number of past candles analyzed). This means you can choose whether you want the tool to react quickly to minor price fluctuations or wait for more significant, established momentum shifts.
In summary, this script acts as a momentum scout. It filters through the noise of price action to notify you specifically when the "tug-of-war" between buyers and sellers tips in favor of one side over the other.
//+------------------------------------------------------------------+
//| 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=20;
extern int CountBars=1000;
extern bool UseSound = True;
extern string SoundFile = "alert.wav";
//---- buffers
double val1[];
double val2[];
double b4plusdi,nowplusdi,b4minusdi,nowminusdi;
bool SoundBuy = False;
bool SoundSell = False;
//+------------------------------------------------------------------+
//| 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,limit,CountedBars = IndicatorCounted();
if (CountedBars < 1)
{
for (i=0; i<=CountBars; i++) {val1[i] = 0.0; val2[i] = 0.0;}
}
if(CountedBars > 0) CountedBars--;
limit = Bars - CountedBars;
for (shift = limit; 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;
}
}
if (val1[0] != EMPTY_VALUE && val1[0] != 0 && SoundBuy)
{
SoundBuy = False;
if (UseSound) PlaySound (SoundFile);
}
if (!SoundBuy && (val1[0] == EMPTY_VALUE || val1[0] == 0)) SoundBuy = True;
if (val2[0] != EMPTY_VALUE && val2[0] != 0 && SoundSell)
{
SoundSell = False;
if (UseSound) PlaySound (SoundFile);
}
if (!SoundSell && (val2[0] == EMPTY_VALUE || val2[0] == 0)) SoundSell = True;
return(0);
}
//+------------------------------------------------------------------+
Comments