RSI-Alert_003

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

This tool is designed to monitor market momentum and provide real-time notifications when trading conditions reach specific thresholds. It functions as an automated "watchdog" that scans price data to help traders identify potential reversal points in the market.

Core Functionality

The script utilizes a technical indicator known as the Relative Strength Index (RSI). In simple terms, this indicator measures the speed and change of price movements to determine whether an asset is being overvalued or undervalued.

The logic operates through three primary components:

  • Momentum Tracking: The script constantly calculates the RSI value based on a specific timeframe (defaulting to 14 periods). This creates a visual representation of the market's current strength.
  • Boundary Setting: It establishes two critical "warning zones" known as OverBought and OverSold levels. By default, these are set at 70 and 30, respectively. When the momentum pushes past these limits, it suggests that the market may be overextended in one direction.
  • Alert Triggering: The script is programmed to watch for a specific "cross-over" event. Rather than alerting every time the price is high or low, it waits for the exact moment the momentum shifts from neutral into these warning zones.

How it Works in Practice

The logic follows a specific set of rules to decide when to notify you:

  1. Sell Signals: If the momentum was below the "OverBought" threshold but suddenly crosses above it, the script recognizes that the market may be becoming overextended on the upside and triggers an alert to consider a "Sell."
  2. Buy Signals: Conversely, if the momentum was above the "OverSold" threshold but suddenly drops below it, the script recognizes that the market may be undervalued and triggers an alert to consider a "Buy."

Summary for the User

Instead of requiring you to stare at charts constantly to see when price action becomes extreme, this script acts as an automated monitor. It tracks the underlying momentum of the market and sends you a direct notification the moment the data suggests a potential shift in direction, allowing for more timely reactions to market movements.

Indicators Used
Relative strength index
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
9 Views
0 Downloads
0 Favorites
RSI-Alert_003
//+------------------------------------------------------------------+
//|                                                    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 = "+ RSIBuffer[i]+ ", Sell.");
      else if(RSIBuffer[1]>OverSold && RSIBuffer[0]<=OverSold)
         Alert("RSI = "+ RSIBuffer[i]+ ", Buy.");
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments