RSI-Alert_004

Download script
Author: Copyright � 2004, MetaQuotes Software Corp.
RSI-Alert_004

This script is a specialized technical analysis tool designed for the MetaTrader trading platform. Its primary purpose is to monitor price momentum and automatically notify the trader when market conditions reach extreme levels, potentially indicating that a trend is exhausted and a reversal may be occurring.

Core Functionality

The tool focuses on the Relative Strength Index (RSI), a common momentum oscillator. By analyzing price movements over a specific timeframe, the RSI helps identify whether an asset is being bought or sold too aggressively.

To make this data actionable, the script utilizes three distinct visual layers:

  • Momentum Tracking: It plots a continuous line representing the current RSI value.
  • Upper Boundary (Overbought): It establishes a ceiling—a specific high point where the price might be considered "overextended" to the upside.
  • Lower Boundary (Oversold): It establishes a floor—a specific low point where the price might be considered "oversold" to the downside.

Automated Logic & Alerts

The most significant feature of this script is its automated monitoring system. Rather than requiring the trader to watch the screen constantly, the script performs the following logic in real-time:

  1. Constant Surveillance: The script continuously scans the relationship between the current momentum line and the pre-defined boundaries.
  2. Buy Signal Detection: If the momentum line was previously above the "Oversold" floor but then drops to meet or cross below it, the script identifies a potential buying opportunity.
  3. Sell Signal Detection: Conversely, if the momentum line was previously below the "Overbought" ceiling but then rises to meet or cross above it, the script identifies a potential selling opportunity.
  4. Instant Notification: When these specific conditions are met, the script triggers an immediate audible and visual alert on the platform, informing the trader of the signal along with the current RSI value and the suggested action (Buy or Sell).

Customization Options

The script is designed with flexibility to suit different trading styles:

  • Sensitivity: Users can adjust the "Period" to determine how much historical data the script looks at to calculate momentum.
  • Thresholds: Traders can move the "Overbought" and "Oversold" boundaries up or down depending on the volatility of the specific currency pair or asset they are trading.
  • Alert Toggle: There is an option to enable or disable the automated notifications, allowing users to choose between a purely visual reference tool or an active alert system.
Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
6 Views
0 Downloads
0 Favorites
RSI-Alert_004
//+------------------------------------------------------------------+
//|                                                    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 Black
#property indicator_color3 Black
#property indicator_width1 2
#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.");
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments