ADX_Cross_v1
Download scriptThis tool is designed as a visual trading assistant for the MetaTrader platform. Its primary purpose is to identify specific momentum shifts by monitoring the relationship between two market trend indicators: the Positive Directional Index (+DI) and the Negative Directional Index (-DI).
How it Works
The script continuously scans historical price data to find "crossovers"—moments where the leading momentum of the market flips from one direction to another. It specifically looks for two types of signals:
- Bearish Signals: The tool detects when the Positive Directional Index falls below the Negative Directional Index. When this happens, it marks the point on your chart with a specific visual icon (Red), suggesting that downward momentum is becoming dominant.
- Bullish Signals: Conversely, the tool identifies when the Positive Directional Index climbs above the Negative Directional Index. It marks these points with a different visual icon (Lime), indicating that upward momentum is taking over.
Smart Adjustments
To ensure the signals are easy to read and don't clutter your chart, the script includes an intelligent spacing logic. Depending on the timeframe you are viewing (from 1-minute charts up to monthly views), the tool automatically adjusts how far away from the price candles the icons are placed. This ensures that the visual markers remain clear and do not overlap with the price action regardless of how "zoomed in" or "zoomed out" your chart appears.
Key Features
- Automatic Visual Cues: Instead of requiring you to constantly watch fluctuating lines, the script places clear arrows directly on the chart where a trend shift is confirmed.
- Dynamic Timeframe Scaling: The tool identifies the timeframe you are currently using and adjusts its positioning automatically to maintain visual clarity.
- Trend Identification: By focusing on the crossing of the +DI and -DI lines, it helps traders pinpoint potential transition points in market sentiment more quickly than watching raw price movement alone.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
extern int ADXcrossesPeriod = 14;
extern int CountBars=350;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double b4plusdi, b4minusdi, nowplusdi, nowminusdi;
int nShift;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_ARROW, 0, 1);
SetIndexArrow(0, 225);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1, DRAW_ARROW, 0, 1);
SetIndexArrow(1, 226);
SetIndexBuffer(1, ExtMapBuffer2);
IndicatorShortName("ADXcrosses(" + ADXcrossesPeriod + ")");
SetIndexLabel(0, "ADXcrUp");
SetIndexLabel(1, "ADXcrDn");
switch(Period())
{
case 1: nShift = 1; break;
case 5: nShift = 3; break;
case 15: nShift = 5; break;
case 30: nShift = 10; break;
case 60: nShift = 15; break;
case 240: nShift = 20; break;
case 1440: nShift = 80; break;
case 10080: nShift = 100; break;
case 43200: nShift = 200; break;
}
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars = IndicatorCounted();
if(counted_bars < 0)
return(-1);
if(counted_bars > 0)
counted_bars--;
limit = Bars - counted_bars;
for(int i = 0; i < limit; i++)
{
b4plusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_PLUSDI, i - 1);
nowplusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_PLUSDI, i);
b4minusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_MINUSDI, i - 1);
nowminusdi = iADX(NULL, 0, ADXcrossesPeriod, PRICE_CLOSE, MODE_MINUSDI, i);
if(b4plusdi > b4minusdi && nowplusdi < nowminusdi)
ExtMapBuffer1[i] = Low[i] - nShift*Point;
if(b4plusdi < b4minusdi && nowplusdi > nowminusdi)
ExtMapBuffer2[i] = High[i] + nShift*Point;
}
return(0);
}
Comments