This tool is designed to serve as a visual signaling system for traders who want to identify potential shifts in market momentum. Instead of overwhelming you with complex lines and moving averages, this script simplifies the market's behavior into clear, actionable alerts on your chart.
How it Works
The logic is centered around the ADX (Average Directional Index), a popular technical indicator used to determine the strength and direction of a trend. Specifically, the script monitors two opposing forces: the "Plus" direction (which tracks upward momentum) and the "Minus" direction (which tracks downward momentum).
By analyzing how these two forces interact relative to one another, the tool identifies specific "crossover" moments:
- Buy Signals: The script looks for a moment where the upward momentum was previously stronger than the downward momentum but has suddenly dipped below it. When this shift occurs, the tool places a Lime arrow below the price candle and triggers an alert to notify you of a potential buying opportunity.
- Sell Signals: Conversely, the script monitors for moments where downward momentum was previously weaker than upward momentum but has suddenly overtaken it. When this transition happens, the tool places a Red arrow above the price candle and sends an alert regarding a potential selling opportunity.
Key Features for the User
- Visual Clarity: Rather than forcing you to interpret complex charts manually, the script highlights the exact moment of the crossover with distinct arrows on your screen.
- Real-Time Notifications: To ensure you don't miss a market move while away from your screen, the script generates an instant "Alert" popup whenever a crossover is detected, providing the current time and the specific currency pair being traded.
- Customizable Sensitivity: You can adjust the look-back period (how many past bars the tool considers) to tune the indicator to your preferred trading style—whether you prefer to catch fast, short-term moves or slower, more established trends.
In essence, this script acts as a digital scout: it constantly scans the "push and pull" of market forces in the background and only speaks up when it detects a significant change in which direction the momentum is leaning.
//+------------------------------------------------------------------+
//| 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 && i!=1)
{
val1[shift]=Low[shift]-5*Point;
Alert("Buy Arrow","\n","Current time is ",TimeToStr(CurTime()),"\n",Symbol());
i++;
}
if (b4plusdi<b4minusdi && nowplusdi>nowminusdi && i!=1)
{
val2[shift]=High[shift]+5*Point;
Alert("Sell Arrow","\n","Current time is ",TimeToStr(CurTime()),"\n",Symbol());
i++;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments