ADXbarsSmd[sw]

Download script
ADXbarsSmd[sw]

This tool is a specialized technical analysis indicator designed to visualize market trend strength and momentum by combining two distinct trading concepts: the ADX (Average Directional Index) and Moving Averages.

Core Logic Overview

The script functions by analyzing the relationship between "buying pressure" and "selling pressure." Instead of just showing you a simple line, it identifies which direction the market is currently favoring and then applies a smoothing filter to that data to make it easier for a trader to read.

How It Works Step-by-Step

1. Identifying Market Dominance The script constantly monitors two specific components of the ADX indicator: the Plus Directional Index (which tracks upward momentum) and the Minus Directional Index (which tracks downward momentum).

  • If selling pressure is stronger than buying pressure, the script "captures" the current high and low prices of the candle.
  • If buying pressure is stronger, it effectively flips that logic to capture the relevant price boundaries for that specific moment in time.

2. Dynamic Data Sorting Unlike standard indicators that simply track a single price point (like the closing price), this script creates a dynamic internal list of "High" and "Low" values based on which side of the market is currently winning. This allows the tool to react to the actual extremes of price movement rather than just the average.

3. Smoothing the Signal Once the script has identified these price points based on market dominance, it applies a Simple Moving Average (SMA) to those values. This is the "Smoothed" part of the logic.

  • By averaging these captured highs and lows over a specific number of bars (defined by your settings), the tool filters out "market noise"—the tiny, erratic price flickers that can often lead to false signals.

Visual Representation on Your Chart

The result is displayed in a separate window below your main price chart. You will see two primary lines:

  • The Main Line: Represents the smoothed trend of the market's dominant price action.
  • The Signal Line: Acts as a secondary guide to help you identify when the trend is gaining strength, slowing down, or potentially reversing.

Summary for the Trader

In simple terms, this script looks at whether the bulls or the bears are in control. It then takes the price "ceiling" and "floor" of that dominant side and smooths them out into a clean, readable line. This helps you stay on the right side of the trend while ignoring the minor fluctuations that often distract manual traders.

Indicators Used
Movement directional indexMoving average indicator
Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
ADXbarsSmd[sw]
//+------------------------------------------------------------------+
//|                                              ADXBARSsmd[sw].mq4  |
//|               ADX Bars  Smoothed  [ss]    Perky Ate no turkey    |
//|                                                                  |
//+------------------------------------------------------------------+
#property  copyright "Perky"
#property  link      "Perky_z@yahoo.com"

//---- indicator settings
#property indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Red
#property  indicator_color2  Blue
//---- indicator parameters
extern int ADXPeriod = 14;
extern int ADXBARSPeriod = 5;
extern int Shift=0;
extern int slShift=0;
//---- indicator buffers
double ind_buffer1[];
double ind_buffer2[];
double HighBarBuffer[];
double LowBarBuffer[];
double b4plusdi, b4minusdi, nowplusdi, nowminusdi;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//----additional buffers are used for counting.
   IndicatorBuffers(4);
//---- indicator buffers mapping
   if(!SetIndexBuffer(0,ind_buffer1) && !SetIndexBuffer(1,ind_buffer2) && 
      !SetIndexBuffer(2,HighBarBuffer) && !SetIndexBuffer(3,LowBarBuffer))
       Print("cannot set indicator buffers!");
//---- drawing settings
   SetIndexStyle(0, DRAW_LINE);
     SetIndexShift(0, Shift+slShift+1); 
   SetIndexStyle(1, DRAW_LINE);
       SetIndexShift(1, Shift);
//---- 
   IndicatorDigits(Digits + 1);  
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("ADXBarsSmd[sw]");
   SetIndexLabel(0, "ADXBarsSmd[sw]("+ADXPeriod+","+ADXBARSPeriod+"s"+Shift+"sls"+slShift+")");
   SetIndexLabel(1, "SignalADXsmd[sw]("+ADXPeriod+","+ADXBARSPeriod+"s"+Shift+")");           
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|  ADX BARS                                                        |
//+------------------------------------------------------------------+
int start()
  {
    double ArOsc = 0;
    int    ArPer, limit, i; 
    int    counted_bars = IndicatorCounted();
//---- check for possible errors
    if(counted_bars < 0) 
        return(-1);
//---- last counted bar will be recounted
    if(counted_bars > 0) 
        counted_bars--;
    limit = Bars - counted_bars;
//----Calculation---------------------------
    for(i = 0; i < limit; i++)
      {
        nowplusdi = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_PLUSDI, i);
        nowminusdi = iADX(NULL, 0, ADXPeriod, PRICE_CLOSE, MODE_MINUSDI, i);
        if(nowminusdi > nowplusdi) 
          {
            LowBarBuffer[i] = Low[i];
            HighBarBuffer[i] = High[i];
          }
        if(nowplusdi > nowminusdi) 
          {
            HighBarBuffer[i] = Low[i];
            LowBarBuffer[i] = High[i];
          }
      }
    for(i = limit - 1; i >=0 ; i--)
      {
        ind_buffer1[i] = iMAOnArray(HighBarBuffer, 0, ADXBARSPeriod, 0, MODE_SMA, i); 
        ind_buffer2[i] = iMAOnArray(LowBarBuffer, 0, ADXBARSPeriod, 0, MODE_SMA, i); 
      }
//---- done
    return(0);
  }

Comments