Author: Copyright � 2004, MetaQuotes Software Corp.
RSI-Alert

This tool is a specialized technical analysis indicator designed to help traders monitor market momentum and receive real-time notifications when price action reaches specific "extreme" zones. It simplifies the process of identifying potential reversal points by automating the observation of the Relative Strength Index (RSI), a common momentum oscillator.

Core Functionality

The script functions by calculating the RSI based on a user-defined timeframe (the period). It visualizes this data in a dedicated window, plotting three distinct lines:

  • The Momentum Line: Tracks the current strength of price movements.
  • The Overbought Threshold: A horizontal boundary representing a level where an asset might be considered "overpriced."
  • The Oversold Threshold: A horizontal boundary representing a level where an asset might be considered "undersold."

Automated Logic & Alerts

The primary purpose of this script is its proactive alert system. Instead of requiring a trader to constantly watch the screen, the logic performs the following checks automatically:

  1. Sell Signal Detection: The script monitors the momentum line. If the line moves from below the "Overbought" level to above it (crossing upward), the tool triggers an alert. This suggests that the asset may be entering a state of excessive buying pressure, potentially signaling a future price drop.
  2. Buy Signal Detection: Conversely, if the momentum line moves from above the "Oversold" level to below it (crossing downward), the tool triggers an alert. This suggests that the asset may be experiencing extreme selling pressure, potentially signaling a future price increase.

User Customization

The logic is designed to be flexible, allowing users to define their own parameters to suit different trading styles:

  • Sensitivity: Users can adjust the look-back period of the RSI calculation.
  • Threshold Levels: The "Overbought" and "Oversold" boundaries can be moved up or down depending on the specific asset being traded.
  • Alert Toggling: A simple switch allows users to turn the notification system on or off, providing the choice between active alerts or purely visual analysis.

When a signal is triggered, the script provides a comprehensive notification window that displays the specific asset name, the timeframe, the price at the moment of the alert, and the specific level reached.

Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
16 Views
0 Downloads
0 Favorites
RSI-Alert
//+------------------------------------------------------------------+
//|                                                    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 DodgerBlue
#property indicator_color2 LightGray
#property indicator_color3 LightGray
#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=14;
extern int ApplyTo=0;
extern bool AlertMode=true;
extern int OverBought=70;
extern int OverSold=30;
//---- 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 "+RSIPeriod+ ", Sell @ Level "+OverBought+" - "+Symbol()+" M"+Period()+" @ "+DoubleToStr(Bid,Digits)+"");
      else if(RSIBuffer[1]>OverSold && RSIBuffer[0]<=OverSold)
         Alert("RSI "+RSIPeriod+ ", Buy @ Level "+OverSold+" - "+Symbol()+" M"+Period()+" @ "+DoubleToStr(Bid,Digits)+"");
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments