ADXcrosses_v1
Download scriptThis script is designed as a visual trading tool for the MetaTrader platform, specifically created to identify potential shifts in market momentum by tracking two opposing forces: upward pressure and downward pressure.
How the Logic Works
The tool monitors a specific technical analysis component known as the Directional Movement Index (ADX). Instead of looking at the overall trend alone, it breaks down the movement into two distinct streams:
- Plus DI: This tracks the strength of upward price movement.
- Minus DI: This tracks the strength of downward price movement.
Signal Detection
The script constantly scans recent historical data to compare these two forces against each other. It looks for specific "crosses"—moments where one force overtakes the other:
- Bearish Signals (Red): The script identifies a potential shift to the downside when the upward force was previously stronger than the downward force but has suddenly dropped below it. When this crossover occurs, the tool places a visual marker above the price candle.
- Bullish Signals (Green): Conversely, the script looks for moments where the downward force was dominant but has been overtaken by the upward force. When this happens, it places a visual marker below the price candle.
User Experience
For a trader, this means the chart will automatically highlight these specific turning points with arrows. Rather than requiring you to manually calculate complex moving averages or pressure indices, the script does the heavy lifting by monitoring every candle and notifying you visually when the momentum "flips" from one direction to the other.
By using a user-adjustable period (the default being 14), the tool allows you to balance how sensitive or stable these signals are based on your specific trading style.
//+------------------------------------------------------------------+
//| FirstIndicator.mq4 |
//| 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 LimeGreen
#property indicator_color2 Red
//---- input parameters
extern int a=14;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double b4plusdi,b4minusdi,nowplusdi,nowminusdi;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW,EMPTY);
SetIndexArrow(0,233);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1,DRAW_ARROW,EMPTY);
SetIndexArrow(1,234);
SetIndexBuffer(1, ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
ObjectDelete("up cross");
ObjectDelete("down cross");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=1000-counted_bars;
//---- macd counted in the 1-st buffer
for(int i=limit; i>=0; i--)
{
b4plusdi=iADX(NULL,0,a,PRICE_CLOSE,MODE_PLUSDI,i-1);
nowplusdi=iADX(NULL,0,a,PRICE_CLOSE,MODE_PLUSDI,i);
b4minusdi=iADX(NULL,0,a,PRICE_CLOSE,MODE_MINUSDI,i-1);
nowminusdi=iADX(NULL,0,a,PRICE_CLOSE,MODE_MINUSDI,i);
if(b4plusdi>b4minusdi &&
nowplusdi<nowminusdi)
// {
ExtMapBuffer1[i]=Low[i]-5*Point;
// }
if(b4plusdi<b4minusdi &&
nowplusdi>nowminusdi)
// {
ExtMapBuffer2[i]=High[i]+5*Point;
// }
}
//----
return(0);
}
Comments