RSI_Cross50_Alert
Download scriptThis tool is designed to monitor market momentum by tracking a specific technical indicator known as the Relative Strength Index (RSI). Its primary purpose is to provide real-time notifications when the price momentum shifts from one direction to another, specifically when it crosses the middle "neutral" zone of the chart.
How it Works
The script continuously analyzes the RSI value, which measures how quickly and significantly an asset's price is changing. It focuses on a specific threshold: the number 50. In technical analysis, 50 often acts as a balance point between bullish (upward) and bearish (downward) pressure.
The logic follows these specific steps:
- Monitoring Momentum Shifts: The tool looks at two consecutive data points: the current RSI value and the previous one. It is looking for a "cross," which happens when the indicator moves from one side of the 50-line to the other.
- Identifying Upward Crosses: If the RSI was previously below 50 and has just moved above 50, the script recognizes this as a potential shift toward upward momentum.
- Identifying Downward Crosses: Conversely, if the RSI was previously above 50 and has just dropped below 50, the script recognizes this as a potential shift toward downward momentum.
Notifications and Alerts
To ensure you don't miss these movements, the script is programmed to take action automatically the moment a cross is detected:
- Audio Cues: The script will play a specific sound file (
news.wav) to provide an immediate audible signal of the crossover. - Visual Alerts: A pop-up alert window will appear on your trading platform, displaying the name of the currency or asset (Symbol) and the timeframe being watched, clearly stating whether the RSI has crossed above or below the 50 level.
- Smart Filtering: The logic includes a built-in filter to ensure that you are not bombarded with multiple alerts for the same movement. It tracks the specific time of the candle to make sure it only triggers one alert per occurrence until a new price movement occurs.
//+------------------------------------------------------------------+
//| RSI-Cross50_Alert.mq4 |
//| Copyright © 2006, Robert Hill |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Robert Hill"
#property link ""
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_width1 1
extern int RSI_Period=14;
double rsi[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
SetIndexBuffer(0, rsi);
SetIndexLabel (0, "RSI" + "("+RSI_Period+")");
SetLevelStyle(STYLE_DASH, 1, Silver);
SetLevelValue(0, 50);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, i;
double RSInow, RSIprevious;
datetime alertTag;
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=Bars-counted_bars;
for(i = 0; i <= limit; i++)
{
RSInow = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i);
RSIprevious = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i+1);
rsi[i] = RSInow;
if (RSInow > 50 && RSIprevious < 50.0)
{
if ( alertTag!=Time[0])
{
PlaySound("news.wav");// buy wav
Alert(Symbol()," M",Period()," RSI cross above 50");
}
alertTag = Time[0];
}
else if (RSInow < 50.0 && RSIprevious > 50.0)
{
if ( alertTag!=Time[0])
{
PlaySound("news.wav"); //sell wav
Alert(Symbol()," M",Period()," RSI cross below 50");
}
alertTag = Time[0];
}
}
return(0);
}
Comments