ADX Crossing_v1
Download scriptThis tool is designed to help traders identify specific momentum shifts in the financial markets by monitoring the relationship between two different trend components: the Positive Directional Index (Plus DI) and the Negative Directional Index (Minus DI). Instead of just looking at the general strength of a trend, this script focuses on the "crossover" moments where the dominant direction of the price movement flips.
How it Works
The logic operates by continuously scanning historical price data to see how these two directional indicators interact with each other. Here is the step-by-step breakdown of its behavior:
- Monitoring Trend Strength: The script looks at the Plus DI (which tracks upward momentum) and the Minus DI (which tracks downward momentum). It calculates these based on a user-defined number of candles (defaulting to 14).
- Identifying Bearish Signals: The tool looks for a specific "cross" where the upward momentum was previously stronger than the downward momentum but has just dropped below it. When this happens, it marks a potential shift toward a sell side, placing a visual indicator (a red arrow) just above the high of that candle.
- Identifying Bullish Signals: Conversely, the tool looks for moments where the downward momentum was previously dominant but has just been overtaken by upward momentum. When this crossover occurs, it marks a potential shift toward a buy side, placing a visual indicator (a lime green arrow) just below the low of that candle.
- Visual Feedback: Rather than creating complex lines or curves that can clutter your screen, the script simplifies the data into clear visual markers. By highlighting exactly where these directional "flips" occur, it allows you to see at a glance where the market sentiment may be changing from one direction to another.
Key Features
- Dynamic History: You can adjust how many past bars the tool analyzes to ensure it fits your specific trading timeframe and historical perspective.
- Clean Interface: The script is designed to remain out of the way, only appearing on your chart when the specific mathematical crossover conditions are met.
- Real-Time Monitoring: It automatically updates as new price data arrives, allowing you to see these trend shifts as they happen in real-time.
//+------------------------------------------------------------------+
//| ADX Crossing.mq4
//| Amir
//+------------------------------------------------------------------+
#property copyright "Author - Amir"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//---- input parameters
extern int ADXbars=14;
extern int CountBars=350;
//---- buffers
double val1[];
double val2[];
double b4plusdi,nowplusdi,b4minusdi,nowminusdi;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,108);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,108);
SetIndexBuffer(0,val1);
SetIndexBuffer(1,val2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| AltrTrend_Signal_v2_2 |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>=Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars);
SetIndexDrawBegin(1,Bars-CountBars);
int i,shift,counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=CountBars;i++) val1[CountBars-i]=0.0;
for(i=1;i<=CountBars;i++) val2[CountBars-i]=0.0;
}
for (shift = CountBars; shift>=0; shift--)
{
b4plusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift-1);
nowplusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_PLUSDI,shift);
b4minusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift-1);
nowminusdi=iADX(NULL,0,ADXbars,PRICE_CLOSE,MODE_MINUSDI,shift);
if (b4plusdi>b4minusdi && nowplusdi<nowminusdi)
{
val1[shift]=Low[shift]-5*Point;
}
if (b4plusdi<b4minusdi && nowplusdi>nowminusdi)
{
val2[shift]=High[shift]+5*Point;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments