ADX Crossing_alarm_v2
Download scriptThis tool is designed to identify specific momentum shifts in the financial markets by monitoring the relationship between two directional indicators. Instead of looking at simple price movements, it analyzes the "push" and "pull" forces (positive and negative trends) to determine when the market sentiment is flipping from one direction to another.
Core Logic Overview
The script functions by constantly comparing two moving components: the Positive Directional Indicator (which tracks upward momentum) and the Negative Directional Indicator (which tracks downward momentum). It specifically looks for "crossovers"—moments where these two forces switch positions relative to one another.
How it Identifies Signals
The logic scans recent price data to find two specific types of events:
- Sell Signal: The script identifies a moment when the upward momentum was previously stronger than the downward momentum but has now weakened and dropped below it. When this "flip" occurs, the tool recognizes a potential shift toward a downward trend.
- Buy Signal: Conversely, the script looks for moments where the downward momentum was dominant but has suddenly crossed below the upward momentum. This suggests that buying pressure is taking over, signaling a potential move to the upside.
Visual and Audio Alerts
To ensure traders don't miss these transitions in real-time, the script provides three layers of notification:
- Visual Markers: It places specific icons (arrows) directly on your trading chart at the exact candle where the crossover occurs, highlighting the entry point visually.
- Audio Alerts: If enabled, the tool will trigger a sound effect immediately when a crossover is detected, providing an instant notification.
- On-Screen Text: The script can display a detailed data summary on your chart screen at the moment of the signal. This text includes essential trading information such as the current Ask and Bid prices, the exact date and time of the signal, the currency pair being traded, and the current timeframe.
Customization Options
The tool is designed to be flexible, allowing you to adjust:
- Sensitivity: You can change the number of bars used to calculate the indicators, which determines how "fast" or "slow" the tool reacts to market changes.
- History View: You can define how many past candles the indicator should display on your chart.
- Alert Preferences: You can toggle the sound and on-screen text notifications on or off based on your personal trading style.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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;
extern bool UseSound = True;
extern bool TypeChart = True;
extern string NameFileSound = "alert.wav";
//---- 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 (UseSound==1) PlaySound(NameFileSound);
if (TypeChart==1) Comment ("Buy signal at Ask=",Ask,", Bid=",Bid,", Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())," Symbol=",Symbol()," Period=",Period());
}
if (b4plusdi<b4minusdi && nowplusdi>nowminusdi)
{
val2[shift]=High[shift]+5*Point;
if (UseSound==1) PlaySound(NameFileSound);
if (TypeChart==1) Comment ("Sell signal at Ask=",Ask,", Bid=",Bid,", Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime())," Symbol=",Symbol()," Period=",Period());
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments