ADX Crossing_alarm_v1

Download script
ADX Crossing_alarm_v1

This tool is designed as a technical indicator for the MetaTrader trading platform to help identify potential shifts in market momentum. It focuses on analyzing two specific moving components of the ADX (Average Directional Index), which is a common technical analysis tool used to measure the strength and direction of a trend.

Core Logic and Functionality

The script continuously monitors the interaction between two trend lines: one that tracks upward price pressure (Plus DI) and one that tracks downward price pressure (Minus DI). Instead of looking at just one value, the logic specifically looks for "crossovers"—moments where these two opposing forces switch positions relative to each other.

How it Identifies Signals

The script evaluates the current market data against the data from the previous bar to detect a change in sentiment:

  • Buy Signal: The logic triggers a signal when the upward pressure line was previously above the downward line but has recently dipped below it. When this specific reversal occurs, the tool places a visual marker (a lime-colored arrow) below the price candle.
  • Sell Signal: Conversely, the logic triggers a signal when the downward pressure line was previously below the upward line but has recently surged above it. In this instance, it places a red arrow above the price candle.

User Notifications and Visuals

To ensure the user does not miss these shifts in momentum, the script includes several automated feedback features:

  • Visual Markers: It automatically draws arrows on the chart to highlight exactly where the crossover occurred within a specific historical range (defined by the user).
  • Audio Alerts: If enabled, the tool will play a sound file immediately when a crossover is detected, providing an audible notification of a potential trade setup.
  • On-Screen Information: The script can display a real-time text comment on the chart area. This message provides comprehensive details for each signal, including the current Ask and Bid prices, the exact date and time of the occurrence, the currency symbol being traded, and the timeframe.

Customization Options

The tool is designed to be flexible, allowing users to adjust how much historical data is displayed, the sensitivity of the ADX calculation (via the number of bars analyzed), and whether they prefer visual, audio, or text-based notifications.

Price Data Components
Series array that contains open time of each bar
Indicators Used
Movement directional index
Miscellaneous
Implements a curve of type %1It plays sound alerts
13 Views
0 Downloads
0 Favorites
ADX Crossing_alarm_v1
//+------------------------------------------------------------------+
//| 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;
extern bool UseSound = True;
extern bool TypeChart = True;
extern string NameFileSound = "alert.wav";

//---- 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 (UseSound==1) PlaySound(NameFileSound);
   if (TypeChart==1) Comment ("Buy signal at Ask=",Ask,", Bid=",Bid,", Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())," Symbol=",Symbol()," Period=",Period());
   
}
if (b4plusdi<b4minusdi && nowplusdi>nowminusdi) 
{
	val2[shift]=High[shift]+5*Point;
	if (UseSound==1) PlaySound(NameFileSound);
   if (TypeChart==1) Comment ("Sell signal at Ask=",Ask,", Bid=",Bid,", Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())," Symbol=",Symbol()," Period=",Period());
   
}


}
   return(0);
  }
//+------------------------------------------------------------------+

Comments