MA RSI Alert

Download script
Author: Copyright � 2006, Eli hayun
MA RSI Alert

This script is a financial analysis tool designed for the MetaTrader platform to help traders identify potential market trends by combining two popular technical indicators: a Moving Average (MA) and the Relative Strength Index (RSI). Its primary purpose is to simplify the decision-making process by automatically evaluating price data and providing visual cues and notifications.

Core Logic and Functionality

The tool works by scanning historical and real-time price data to determine market momentum. It follows a specific logical flow:

1. Data Processing The script continuously calculates two distinct values for the currency pair or asset you are viewing:

  • Moving Average (MA): This tracks the average price over a specific period, helping to smooth out short-term "noise" and reveal the underlying trend.
  • Relative Strength Index (RSI): This measures the speed and change of price movements. It is used here as a filter to determine if the market is showing strength or weakness.

2. Signal Generation The script evaluates these two values against a pre-defined threshold (the RSI Level). The logic splits into two primary categories:

  • Buy Signals: When the RSI value meets or exceeds the specified level, the script identifies this as a potential upward trend. It then maps the Moving Average to a specific visual line on your chart.
  • Sell Signals: When the RSI falls below that same level, the script identifies this as a potential downward trend and maps the Moving Average to a different visual line.

3. Visual Feedback Rather than just showing raw numbers, the script draws lines directly onto your trading chart. This allows you to see the "trend line" of the moving average change dynamically based on whether the RSI is telling the market to lean toward a "Buy" or "Sell" state.

4. Automated Notifications To ensure traders don't have to watch the screen constantly, the script includes an intelligent notification system. It is designed to recognize when the market sentiment flips (e.g., moving from a Buy state to a Sell state). When this shift occurs, it can perform two actions:

  • Email Alerts: Send an immediate message to your registered email address detailing the signal and the asset name.
  • Sound Alerts: Trigger a pop-up notification and sound on your trading platform.

The script includes "memory" logic to ensure that you are only notified once per trend change, preventing your notifications from being flooded with repeated messages during a single sustained move.

Indicators Used
Moving average indicatorRelative strength index
Miscellaneous
Implements a curve of type %1It sends emailsIt issuies visual alerts to the screen
11 Views
0 Downloads
0 Favorites
MA RSI Alert
//+------------------------------------------------------------------+
//|                                                       MA rsi.mq4 |
//|                                      Copyright © 2006, Eli hayun |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli hayun"

#property link      "email alert by omelette"
#property link      "Sound alert by Sadly - 30/10/2007"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red
//---- input parameters
extern bool      eMailAlerts_On = false;
extern bool      SoundAlert_On = false;
extern int       maPeriod=1;
extern int       maMethod=MODE_SMMA;
extern int       maPrice=PRICE_CLOSE;
extern int       rsiPeriod=50;
extern int       rsiLevel=50;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
int LastTradeType,LastTradeTime;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int limit,TradeType;
   int counted_bars=IndicatorCounted();
   string AlertMsg;
//---- 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;
//---- main loop
   for(int i=0; i<limit; i++)
     {
         double ma = iMA(NULL,0,maPeriod, 0, maMethod, maPrice, i);
         double rsi= iRSI(NULL, 0, rsiPeriod, maPrice, i);
         if (rsi >= rsiLevel) {
            ExtMapBuffer1[i] = ma;
            AlertMsg = "BUY Signal";
            TradeType = 1; }
         else { ExtMapBuffer2[i] = ma;
            AlertMsg = "SELL Signal";
            TradeType = -1; }
            
         if (eMailAlerts_On && LastTradeType != TradeType && LastTradeTime != Time[0]) {
           LastTradeType = TradeType;
           LastTradeTime = Time[0];
           SendMail("Expert-Advisor Generated Alert (MA-RSI) - ",Symbol()+" - "+AlertMsg); }
           
         if(SoundAlert_On && LastTradeType != TradeType && LastTradeTime != Time[0]) {
           LastTradeType = TradeType;
           LastTradeTime = Time[0];
           Alert("Alert (MA-RSI) - ",Symbol()+" - "+AlertMsg); }
           
                          
     }
     
   return(0);
  }
//+------------------------------------------------------------------+

Comments