Advanced_ADX_v2

Download script
Author: Waddah Attar
Advanced_ADX_v2

This tool is designed to help traders visualize and interpret market trends by filtering the Average Directional Index (ADX), a common technical indicator used to measure the strength of a market's momentum. While the standard ADX shows how strongly a price is moving regardless of direction, this specific script adds a layer of intelligence by separating that strength into clear visual signals based on whether the market is leaning bullish or bearish.

How the Logic Works

The script operates by analyzing three distinct components of the ADX data simultaneously:

  1. Trend Strength: The core value of the ADX, which tells you how powerful the current price movement is.
  2. Positive Momentum (Plus DI): A measure of upward pressure in the market.
  3. Negative Momentum (Minus DI): A measure of downward pressure in the market.

Visual Interpretation

Instead of showing all these values mixed together, the script compares the Positive and Negative momentum to determine which direction is currently dominating. It then displays the results in a separate window on your chart using a color-coded histogram:

  • Green Histogram (Bullish Strength): When the upward momentum (Plus DI) is higher than the downward momentum (Minus DI), the script identifies the trend as having "bullish" characteristics. It plots the strength of the trend in green, indicating that the current price movement is primarily driven by buyers.
  • Red Histogram (Bearish Strength): When the downward momentum (Minus DI) outweighs the upward momentum (Plus DI), the script identifies the trend as having "bearish" characteristics. It plots the strength of the trend in red, signifying that the move is being driven by sellers.

Summary for Traders

Essentially, this script acts as a visual filter. Rather than forcing you to manually compare different lines to see who is winning the "tug-of-war" between buyers and sellers, it does the math for you. It provides an immediate, color-coded view of whether the current market strength is biased toward the upside (Green) or the downside (Red), helping you stay aligned with the prevailing trend at a glance.

Indicators Used
Movement directional index
Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
Advanced_ADX_v2
//+------------------------------------------------------------------+
//|                                                 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;
         }
       else
         {
           ExtBuffer1[i] = 0;
           ExtBuffer2[i] = ADX0;
         }
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments