ADX_100_V3

This script is a custom technical indicator designed for the MetaTrader 4 platform. Its primary purpose is to identify specific shifts in market momentum by monitoring the relationship between two key trend components: the "Plus Directional Indicator" and the "Minus Directional Indicator."

Core Functionality

The tool scans historical price data to detect moments where the prevailing direction of the market changes. It does this by comparing the current strength of upward momentum against downward momentum across consecutive bars on a chart.

How the Logic Works

The script operates by performing the following steps:

  • Trend Component Analysis: It evaluates two specific indicators that measure the strength and direction of price movement. One tracks "positive" pressure (upward), while the other tracks "negative" pressure (downward).
  • Crossover Detection: The logic looks for a "cross." Specifically, it identifies situations where the positive indicator was previously higher than the negative one but has now dropped below it, or vice versa.
  • Signal Identification:
    • Bearish Signal: If the script detects that the upward momentum has weakened while the downward momentum has gained strength (a "cross-under"), it identifies a potential shift toward a downward trend.
    • Bullish Signal: If it detects that the downward momentum has weakened while the upward momentum has gained strength (a "cross-over"), it identifies a potential shift toward an upward trend.
  • Visual Output: Rather than just showing lines, this script places specific visual markers (arrows) on your chart at the exact point where these momentum shifts occur.
    • When a downward shift is detected, it marks the lowest price point of the recent local range.
    • When an upward shift is detected, it marks the highest price point of the recent local range.

User Perspective

For a trader, this script acts as a "momentum scout." Instead of you having to manually watch whether trend lines are crossing or momentum is fading, the script automatically scans the data and places visual alerts on the chart to highlight where the market's "push" has switched directions.

Indicators Used
Movement directional index
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
ADX_100_V3
//+------------------------------------------------------------------+
//| ADX Crossing.mq4 
//| Amir
//+------------------------------------------------------------------+
#property  copyright "Author - Amir"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Sienna
#property indicator_color2 Blue

//---- input parameters
extern int ADXbars=14;
extern int CountBars=650;

//---- buffers
double val1[];
double val2[];
double b4plusdi,nowplusdi,b4minusdi,nowminusdi,adxp,adxpp,adxm,adxmp,HI,LO;

//+------------------------------------------------------------------+
//| 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--) 
{ 

  // mom = iMomentum(NULL,0,ADXbars,PRICE_CLOSE,shift-1);
  // momp = iMomentum(NULL,0,ADXbars,PRICE_CLOSE,shift);
   adxp = iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,shift-1);
   adxpp = iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,shift);
   adxm = iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,shift-1);
   adxmp = iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,shift);

if (adxp>adxm && adxpp<adxmp )	
//if (b4plusdi>b4minusdi && nowplusdi<nowminusdi)
{
   //HI = (High[iHighest(NULL,0,MODE_HIGH,5,shift-1)]-Ask);
  // LO = (Low[iLowest(NULL,0,MODE_LOW,5,shift-1)]);
   LO = (Low[iLowest(NULL,0,MODE_LOW,5,shift-1)]);
	//val1[shift-1]=Low[shift]+HI;
	val1[shift-1]=LO;
}
if (adxp<adxm && adxpp>adxmp )
//if (b4plusdi<b4minusdi && nowplusdi>nowminusdi) 
{
   //LO = (Ask-Low[iLowest(NULL,0,MODE_LOW,5,shift-1)]);
 //  HI = (High[iHighest(NULL,0,MODE_HIGH,5,shift-1)]);
   HI = (High[iHighest(NULL,0,MODE_HIGH,5,shift-1)]);
	//val2[shift-1]=High[shift]-LO;
	val2[shift-1]=HI;
}


}
   return(0);
  }
//+------------------------------------------------------------------+

Comments