EMA_RSI_Signal

Author: Copyright � 2006, MetaQuotes Software Corp.
EMA_RSI_Signal

This tool is designed to assist traders by identifying specific momentum shifts in the market using a combination of trend-following indicators and price volatility measurements. Instead of relying on a single piece of data, it looks for a "confluence"—a moment where three different technical conditions align simultaneously to suggest a potential move in price.

How the Logic Works

The script monitors the market using three primary components:

1. Moving Average Crossovers (The Trend) The tool tracks two different Exponential Moving Averages (EMAs): a "Fast" average and a "Slow" average. These represent the short-term and long-term price trends, respectively.

  • Buy Signal: The logic looks for the moment the Fast average crosses above the Slow average. This suggests that upward momentum is accelerating compared to the recent past.
  • Sell Signal: The logic looks for the moment the Fast average crosses below the Slow average, suggesting a shift toward downward momentum.

2. Relative Strength Index (The Momentum Filter) To ensure the signals aren't just "noise," the script uses the RSI (Relative Strength Index). This acts as a filter to confirm the strength of the move:

  • For an Upward signal, the RSI must be above 50, confirming that bullish momentum is active.
  • For a Downward signal, the RSI must be below 50, confirming that bearish momentum is active.

3. Dynamic Visual Positioning (The Accuracy) Unlike standard indicators that might overlap with price candles and become hard to see, this script calculates the "Range" of the current market (the difference between high and low prices). It uses this calculation to place visual markers (arrows) at a consistent distance away from the actual price. This ensures that the signals are clearly visible on your chart without cluttering the active trading price.

User Notifications

When all conditions are met—the averages cross in the correct direction and the RSI confirms the momentum—the script performs three actions:

  • Visual Markers: It places a green arrow (for Up) or a red arrow (for Down) on the chart.
  • Pop-up Alerts: It generates an on-screen notification identifying the specific currency pair and timeframe where the signal occurred.
  • Audio Alerts: It plays a sound file to grab your attention immediately, ensuring you don't miss a potential entry point.

Summary of Behavior

Essentially, this script acts as an automated scout. It watches the background data 24/7 and only "flags" the chart when the price trend shifts significantly enough to meet all three mathematical criteria, filtering out minor fluctuations to highlight clearer opportunities.

Indicators Used
Relative strength indexMoving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screenIt plays sound alerts
10 Views
0 Downloads
0 Favorites
EMA_RSI_Signal
//+------------------------------------------------------------------+
//|                                               EMA_RSI_Signal.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property link      "Code adapted by cja" 

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2

extern bool Alert_ON = true;
extern bool POP_UP_ON = true;

extern int EMA_Fast = 10;
extern int EMA_Slow = 40; 
extern int RSI = 9;
extern int ARROW_Distance = 15;

double CrossUp[];
double CrossDown[]; 

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {

   static datetime dt = 0;
   int limit, i, counter;
   double RRSI,EMA_FFast,EMA_SSlow,EMA_FFast_Prev,EMA_SSlow_Prev;
   double Range, AvgRange;
   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;
   
   static datetime cDT = 0;
   for(i = 0; i <= limit; i++) {
   
      counter=i;
      Range=0;
      AvgRange=0;
      CrossUp[i] = 0; CrossDown[i] = 0;
      for (counter=i ;counter<=i+ARROW_Distance ;counter++)// distance star above/below price 
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/10;
       
      RRSI = iRSI(NULL,0, RSI, PRICE_CLOSE,i);
            
      EMA_FFast = iMA(NULL,0,EMA_Fast,0,MODE_EMA,PRICE_CLOSE,i);
      EMA_FFast_Prev = iMA(NULL,0,EMA_Fast,0,MODE_EMA,PRICE_CLOSE,i+1);
      
      EMA_SSlow = iMA(NULL,0,EMA_Slow,0,MODE_EMA,PRICE_CLOSE,i);
      EMA_SSlow_Prev = iMA(NULL,0,EMA_Slow,0,MODE_EMA,PRICE_CLOSE,i+1);
      
  
      if ((EMA_FFast > EMA_SSlow) && (EMA_FFast_Prev < EMA_SSlow_Prev)&& (RRSI > 50)){
         CrossUp[i] = Low[i] - Range*0.5; // range # also affects star price difference
         if ((i < 2) && (dt != iTime(NULL,0,0)))
            {
                if (Alert_ON ==true) 
   {
                if (POP_UP_ON ==true) 
   {
               Alert(Symbol(),"M",Period()," : EMA["+EMA_Fast+"]  EMA["+EMA_Slow+"]  RSI["+RSI+"] Cross UP " );
   }            
               PlaySound("alert.wav");
               dt = iTime(NULL,0,0);
            }}
      }
      else  if ((EMA_FFast < EMA_SSlow) && (EMA_FFast_Prev > EMA_SSlow_Prev)&& (RRSI < 50)){
         CrossDown[i] = High[i] + Range*0.5; // range # also affects star price difference
         if ((i < 2) && (dt != iTime(NULL,0,0)))
            {
                if (Alert_ON ==true) 
   {
                if (POP_UP_ON ==true) 
   {
               Alert(Symbol()," M",Period(), " : EMA["+EMA_Fast+"]  EMA["+EMA_Slow+"]  RSI["+RSI+"] Cross DOWN ");
   }            
               PlaySound("alert.wav");
               dt = iTime(NULL,0,0);
            }}
      }
      
   }
   return(0);
}

Comments