RSI-Alert_001
Download scriptThis tool is designed to function as a visual and audible monitoring assistant for traders who use the Relative Strength Index (RSI), a common momentum indicator used to identify whether an asset is being overbought or oversold.
Core Functionality
The script automates the process of watching price movements and identifying specific "turning points." Instead of requiring you to constantly watch the screen to see if the RSI reaches extreme levels, this tool monitors the data in the background and provides immediate feedback when certain conditions are met.
How the Logic Works
The logic follows a straightforward three-step process:
1. Data Tracking The script continuously calculates the RSI based on a specific timeframe (the "Period"). It plots this data as a line on your chart so you can visually see the momentum of the market.
2. Setting Boundaries The tool uses two specific thresholds to determine market extremes:
- Overbought Level: A high value indicating that the price may have risen too quickly and could be due for a pullback or reversal.
- Oversold Level: A low value indicating that the price may have dropped too sharply and could be due for a bounce.
3. Automated Alerts The "intelligence" of the script lies in its ability to detect a change in direction at these boundaries. It looks for specific crossovers:
- Sell Signals: If the RSI was previously below the "Overbought" line but moves upward to cross or touch it, the script triggers an alert suggesting the asset may be overextended to the upside.
- Buy Signals: If the RSI was previously above the "Oversold" line but moves downward to cross or touch it, the script triggers an alert suggesting the asset may be overextended to the downside.
User Experience
When these specific conditions occur, the tool generates a pop-up notification on your trading platform. These alerts are designed to capture your attention instantly, providing you with a "Buy" or "Sell" warning based on the momentum data, helping you react more quickly to potential market reversals.
//+------------------------------------------------------------------+
//| RSI-Alert.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_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_DOT
#property indicator_style3 STYLE_DOT
//---- input parameters
extern int RSIPeriod=2;
extern int ApplyTo=0;
extern bool AlertMode=true;
extern int OverBought=97;
extern int OverSold=3;
//---- buffers
double RSIBuffer[];
double RSIOBBuffer[];
double RSIOSBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator lines
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,RSIBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,RSIOBBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,RSIOSBuffer);
//---- name for DataWindow and indicator subwindow label
short_name="RSI-Alert("+RSIPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
SetIndexLabel(1,"OverBought");
SetIndexLabel(2,"OverSold");
//----
SetIndexDrawBegin(0,RSIPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
if(Bars<=RSIPeriod) return(0);
//----
i=Bars-RSIPeriod-1;
if(counted_bars>=RSIPeriod) i=Bars-counted_bars-1;
while(i>=0)
{
RSIBuffer[i]=iRSI(NULL,0,RSIPeriod,ApplyTo,i);
RSIOBBuffer[i]=OverBought;
RSIOSBuffer[i]=OverSold;
i--;
}
if(AlertMode)
{
if(RSIBuffer[1]<OverBought && RSIBuffer[0]>=OverBought)
Alert("RSI = "+RSIBuffer[i]+"", "Sell.", Symbol ());
else if(RSIBuffer[1]>OverSold && RSIBuffer[0]<=OverSold)
Alert("RSI = "+RSIBuffer[i]+"", "Buy.", Symbol ());
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments