ADX_Crossing_v.2.0

Download script
ADX_Crossing_v.2.0

This tool is designed as a visual aid for traders to identify potential shifts in market momentum by monitoring the interaction between two specific trend indicators: the Plus Directional Index (+DI) and the Minus Directional Index (-DI).

Core Logic and Functionality

The script continuously scans historical and real-time price data to detect "crosses" between these two directional trends. In trading, these lines help represent the strength of upward pressure versus downward pressure. The logic operates as follows:

  • Buy Signal Identification (Bullish Momentum): The tool looks for a specific moment where the "Plus DI" line moves from being below the "Minus DI" line to crossing above it. When this transition occurs, the script places a green arrow marker just below the current price candle, signaling a potential shift toward upward momentum.

  • Sell Signal Identification (Bearish Momentum): Conversely, the tool monitors for the "Plus DI" line moving from above the "Minus DI" line to crossing below it. When this happens, the script places a red arrow marker just above the current price candle, signaling a potential shift toward downward momentum.

Customization and User Experience

To ensure the tool is useful in various market conditions, the script includes several adjustable settings:

  • Sensitivity: Users can define the "ADX bars" to determine how many previous data points are used to calculate the trend strength, allowing for a balance between fast and slow signal detection.
  • Visual Range: You can set how many historical bars the tool should display on your chart at one time.
  • Audio Alerts: The script includes an optional sound notification feature. When a new signal (buy or sell) is detected in real-time, the software can play a specific alert sound to notify the trader immediately without them having to watch the screen constantly.

Summary for the Trader

Essentially, this script automates the tedious task of watching two trend lines simultaneously. Instead of manually checking for every intersection of the Plus and Minus DI lines, the tool highlights these "crossover" points automatically with clear visual markers and optional audio cues, helping you identify potential entry or exit points based on changes in market direction.

Indicators Used
Movement directional index
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
ADX_Crossing_v.2.0
//+------------------------------------------------------------------+
//| 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=50;
extern int CountBars=350;
extern bool UseSound=True;
extern string SoundFile="wait.waw";
//---- 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