ADXbars_v1

This tool is designed as a visual trading indicator that analyzes market momentum and price direction to identify specific trends. It works by processing the relationship between two different movement types: "Plus DI" (which tracks upward momentum) and "Minus DI" (which tracks downward momentum).

Core Logic Overview

The script operates through a three-step process to filter and smooth out market noise:

1. Momentum Comparison The indicator constantly monitors the strength of buying pressure versus selling pressure. It looks at whether the "Plus" value is higher than the "Minus" value or vice versa. This serves as the primary trigger for the script's logic.

2. High and Low Identification Instead of just looking at simple price points, the script makes a unique distinction based on the momentum detected in step one:

  • When selling pressure is dominant, it captures the specific high and low prices of those candles to represent the "Low Bar" data.
  • When buying pressure is dominant, it flips that logic, capturing the prices to form the "High Bar" data. Essentially, it categorizes the price action based on which side of the market has the upper hand at any given moment.

3. Smoothing and Visualization To prevent the data from looking erratic or jagged on your chart, the script applies a final mathematical smoothing process (a Simple Moving Average). It takes the high and low points identified in the previous step and averages them over a user-defined number of bars.

Visual Output

The result is displayed as two distinct lines on your trading window:

  • ADXBars: Represents the smoothed trend based on the primary momentum data.
  • Signal: Provides a secondary smoothed line to help users visualize the overall flow of price action.

By using this method, the indicator aims to provide a clearer picture of the market's "true" path by filtering out minor fluctuations and highlighting where the strongest momentum is currently residing.

Indicators Used
Movement directional indexMoving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
ADXbars_v1
//+------------------------------------------------------------------+
//|                                                    ADXBARSsm.mq4  |
//|                                            Perky Aint no turkey  |
//|                                                                  |
//+------------------------------------------------------------------+
#property  copyright "Perky"
#property  link      "Perky_z@yahoo.com"

//---- indicator settings
#property indicator_chart_window
#property  indicator_buffers 2
#property  indicator_color1  Red
#property  indicator_color2  Blue
//---- indicator parameters
extern int ADXPeriod = 14;
extern int ADXBARSPeriod = 5;
//---- 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);
   SetIndexStyle(1, DRAW_LINE);
//---- 
   IndicatorDigits(Digits + 1);  
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("ADXBarsSm");
   SetIndexLabel(0, "ADXBars");
   SetIndexLabel(1, "Signal");           
//---- 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