Forex Alert SystemPlus
Download scriptThis script functions as a technical analysis tool designed to identify specific trend reversals in financial markets by monitoring price momentum. It automates the process of spotting "crossovers" between two key components of the Average Directional Index (ADX), a standard technical indicator used to measure the strength and direction of a market trend.
How the Logic Works
The script constantly analyzes historical and real-time price data over a user-defined period (up to 1,500 bars). It specifically looks for a "cross" in the relationship between two moving averages: the Positive Directional Index (+DI) and the Negative Directional Index (-DI).
1. Identifying Buy Signals The logic looks for a specific shift in momentum where the upward force (Positive DI) was previously stronger than the downward force, but has now dropped below it. When this transition occurs, the script interprets it as a potential shift in sentiment and places a visual marker (a green arrow) below the price candle. Simultaneously, if the user has enabled alerts, the system will trigger a "Buy Signal" notification.
2. Identifying Sell Signals Conversely, the script monitors for moments where the downward force (Negative DI) was previously dominant but has since dropped below the upward force. When this crossover happens, it indicates a potential shift toward an upward move or a reversal of downward pressure. In these instances, the script places a visual marker (a red arrow) above the price candle and triggers a "Sell Signal" notification.
Key Features for the User
- Visual Clarity: Instead of requiring you to manually track complex moving lines, the script simplifies the data into clear visual cues on your chart, highlighting exactly where the trend shift occurred.
- Automated Notifications: The tool can provide real-time alerts, ensuring you are notified immediately when a crossover occurs without needing to watch the screen constantly.
- Customizable Sensitivity: You can adjust the "ADX bars" parameter to change how many previous candles the script considers when calculating momentum, allowing you to tailor the indicator to different trading styles (e.g., faster signals vs. smoother, more stable trends).
- Data Management: The script is designed to automatically handle large amounts of historical data efficiently, ensuring that the markers appear correctly on your chart while maintaining smooth performance.
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//---- input parameters
extern bool AlertON=true;
extern int ADXbars=14;
extern int CountBars=1500;
//---- 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 && i!=1)
{
val1[shift]=Low[shift]-5*Point;
if (AlertON) Alert("Buy Signal","\n","Current time is ",TimeToStr(CurTime()),"\n",Symbol());
i++;
}
if (b4plusdi<b4minusdi && nowplusdi>nowminusdi && i!=1)
{
val2[shift]=High[shift]+5*Point;
if (AlertON) Alert("Sell Signal","\n","Current time is ",TimeToStr(CurTime()),"\n",Symbol());
i++;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments