ADXbars_v5
Download scriptThis tool is designed to provide a visual representation of market momentum by identifying the relationship between upward and downward price movements. It works by analyzing specific technical data points to determine which direction the market is currently favoring and then highlights those results directly on your chart.
How the Logic Works
The script operates by constantly comparing two primary indicators: the Plus Directional Index (PLUSDI) and the Minus Directional Index (MINUSDI). In simpler terms, these represent the strength of "buying pressure" versus "selling pressure."
1. Data Analysis The tool looks at a specific window of time (the default being 14 bars) to see how price has moved. It calculates whether the current momentum is leaning toward a rise in price or a fall.
2. Visual Identification Once the script determines which pressure is stronger, it reacts by coloring and plotting "bars" on your screen:
- Downward Momentum: If the script detects that the selling pressure (MinusDI) is stronger than the buying pressure (PlusDI), it applies one set of visual markers to the high and low prices.
- Upward Momentum: Conversely, if the buying pressure (PlusDI) exceeds the selling pressure, it switches the visual markers.
The Result for the User
Instead of looking at complex lines or overlapping numbers, this script simplifies the market's behavior into a clear visual histogram. It allows you to see at a glance whether the "bulls" (buyers) or the "bears" (sellers) are currently in control of the price action based on the prevailing directional strength.
//+------------------------------------------------------------------+
//| ADX BARS .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 DodgerBlue
//---- indicator parameters
extern int ADXPeriod=14;
//---- indicator buffers
double ind_buffer1[];
double ind_buffer2[];
//double ind_buffer3[];
double HighBarBuffer[];
double LowBarBuffer[];
double ArOscBuffer[];
double b4plusdi,b4minusdi,nowplusdi,nowminusdi;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//----additional buffers are used for counting.
IndicatorBuffers(5);
SetIndexBuffer(2,HighBarBuffer);
SetIndexBuffer(3,LowBarBuffer);
SetIndexBuffer(4,ArOscBuffer);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2);
//SetIndexDrawBegin(0,1500);
//SetIndexDrawBegin(1,1500);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
//---- indicator buffers mapping
SetIndexBuffer(0,ind_buffer1);
SetIndexBuffer(1,ind_buffer2);
SetIndexBuffer(2,HighBarBuffer);
SetIndexBuffer(3,LowBarBuffer);
SetIndexBuffer(4,ArOscBuffer);
//---- name for DataWindow and indicator subwindow label
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Aroon Oscilator |
//+------------------------------------------------------------------+
int start()
{
double ArOsc=0;
int ArPer,i;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
if(counted_bars==0) limit-=1+ADXPeriod;
//----Calculation---------------------------
for(i=0; i<limit; i++)
{
// b4plusdi = iADX( NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,i-1);
nowplusdi=iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_PLUSDI,i);
//b4minusdi = iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,i-1);
nowminusdi=iADX(NULL,0,ADXPeriod,PRICE_CLOSE,MODE_MINUSDI,i);
//----
if(nowminusdi>nowplusdi)
{
ind_buffer2[i]=Low[i];
ind_buffer1[i]=High[i];
}
if(nowplusdi>nowminusdi)
{
ind_buffer1[i]=Low[i];
ind_buffer2[i]=High[i];
}
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments