Advanced_ADX_WithAlert_001

Download script
Author: Waddah Attar
Advanced_ADX_WithAlert_001

This script serves as a visual trend-tracking tool designed to help traders identify the strength and direction of market movements. It operates by analyzing three specific mathematical components of the Average Directional Index (ADX), which is a standard technical indicator used to measure whether a market is trending or moving sideways.

How the Logic Works

The tool processes historical price data to calculate three distinct values at every point on your chart:

  1. The Main Trend Strength: This measures the overall magnitude of the current movement, regardless of direction.
  2. The Positive Momentum (PlusDI): This tracks the strength of upward price movements.
  3. The Negative Momentum (MinusDI): This tracks the strength of downward price movements.

Visual Representation and Behavior

Instead of simply showing a single line, the script interprets the relationship between the "Positive" and "Negative" momentum to decide how to display information on your screen:

  • Uptrend Identification: When the upward momentum is stronger than or equal to the downward momentum, the tool highlights the trend strength in Green. This signals that the prevailing price action is leaning toward the bullish side.
  • Downtrend Identification: Conversely, if the downward momentum exceeds the upward momentum, the tool highlights the trend strength in Red, indicating that the market is showing a bearish bias.

Automated Alerts

To ensure you don't have to watch the charts constantly, the script includes an automated notification system. Every time the indicator detects a shift or a specific data point based on these calculations, it triggers an audible "alert" sound. This allows for real-time awareness of market changes as they happen.

Summary for the User

In short, this tool acts as a "filter" for market noise. It takes complex trend data and simplifies it into a clear color-coded visual: Green for bullish pressure and Red for bearish pressure, while providing an audio cue to notify you of the current market state instantly.

Indicators Used
Movement directional index
Miscellaneous
Implements a curve of type %1It plays sound alerts
15 Views
1 Downloads
0 Favorites
Advanced_ADX_WithAlert_001
//+------------------------------------------------------------------+
//|                                                 Advanced_ADX.mq4 |
//|                              Copyright © 2006, Eng. Waddah Attar |
//|                                          waddahattar@hotmail.com |
//+------------------------------------------------------------------+
#property copyright "Waddah Attar"
#property link      "waddahattar@hotmail.com"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//----
extern int ADXPeriod = 13;
//----
double ExtBuffer1[];
double ExtBuffer2[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0, ExtBuffer1);
   SetIndexStyle(0, DRAW_HISTOGRAM, 0, 2);
//----
   SetIndexBuffer(1, ExtBuffer2);
   SetIndexStyle(1, DRAW_HISTOGRAM, 0, 2);
//----
   IndicatorShortName("Advanced_ADX (" + ADXPeriod + ")");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i, limit;
   double ADX0,ADX1,ADX2;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) 
       return(-1);
   if(counted_bars > 0) 
       counted_bars--;
   limit = Bars - counted_bars; 
//----   
   for(i = 0; i < limit ; i++)
     {
       ADX0 = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_MAIN, i);
       ADX1 = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_PLUSDI, i);
       ADX2 = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_MINUSDI, i);
       //----
       if(ADX1 >= ADX2)
         {
           ExtBuffer1[i] = ADX0;
           ExtBuffer2[i] = 0;
           PlaySound("alert.wav");   //  <<<<========
         }
       else
         {
           ExtBuffer1[i] = 0;
           ExtBuffer2[i] = ADX0;
           PlaySound("alert.wav");   //  <<<<========
         }
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments