ADX_Cross_v1

Download script
Author: Copyright � 2004, MetaQuotes Software Corp.
ADX_Cross_v1

This indicator is designed to help traders identify specific momentum shifts in the market by tracking the interaction between two key trend components: the Positive Directional Indicator (PLUSDI) and the Negative Directional Indicator (MINUSDI). Instead of providing a continuous line, it acts as a visual signaling tool that marks "crossover" points on your chart.

How the Logic Works

The script continuously monitors the relationship between bullish (upward) and bearish (downward) momentum. It looks for specific moments where these two forces flip their positions relative to one another:

  • Bearish Signal: The indicator looks for a moment where the previous data point showed bullish momentum was stronger than bearish momentum, but the current data point shows that bearish momentum has overtaken it. When this "cross down" occurs, the script places a visual marker below the price candle.
  • Bullish Signal: Conversely, it looks for moments where bearish momentum was previously dominant but has been overtaken by bullish momentum. When this "cross up" occurs, the script places a visual marker above the price candle.

Key Features

  • Dynamic Visual Offsets: To ensure the signals are easy to read and do not overlap with the price candles, the script automatically adjusts how far away from the price the arrows appear based on the timeframe you are using. It calculates a specific "shift" value—meaning on shorter timeframes (like 1 minute), the arrows stay closer to the candle, while on longer timeframes (like daily charts), they move further away to maintain clarity.
  • Customizable Sensitivity: The logic relies on a defined period (defaulting to 14), which determines how much historical data the script analyzes to calculate the trend strength. You can adjust this sensitivity to smooth out market noise or make the signals more reactive.
  • Historical Analysis: The tool processes a significant amount of historical data (up to 350 bars) upon loading, allowing you to see past crossover points and analyze how the indicator performed during previous market movements.

Summary for Traders

Essentially, this script filters out the constant "noise" of the market to highlight only those moments where the trend's primary direction flips. It acts as an early warning system, providing clear visual cues when bullish pressure turns into bearish pressure, or vice versa.

Indicators Used
Movement directional index
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
ADX_Cross_v1
/*-----------------------------+
|			       |
| 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