RSI_Signals
Download scriptThis script is a technical trading indicator designed for the MetaTrader platform. Its primary purpose is to identify potential entry points in the market by analyzing price momentum through a mathematical formula known as the Relative Strength Index (RSI).
Core Functionality
The tool monitors the "strength" of price movements to determine if an asset is being overbought (where prices might be due for a pullback) or oversold (where prices might be due for a rebound). It simplifies this complex data into clear visual cues on your trading chart.
Key Logic and Features
1. Signal Identification The script looks for specific "crosses" in the RSI values. Instead of just looking at where the price is currently, it compares the current value to the previous one to detect a shift in momentum:
- Buy Signals: Triggered when the RSI moves from a low "oversold" area back upward. This suggests that the downward pressure is weakening and a move up may be starting.
- Sell Signals: Triggered when the RSI moves from a high "overbought" area back downward. This suggests that upward momentum is fading and a price drop may be imminent.
2. Customizable Thresholds The logic allows for user-defined boundaries to determine what constitutes "overbought" or "oversold." By default, these are set to standard levels (70 for high, 30 for low), but they can be adjusted to suit different trading styles or specific currency pairs.
3. Visual and Audible Alerts To ensure the trader doesn't have to watch the screen constantly, the script provides immediate feedback:
- On-Chart Arrows: It places visual markers (arrows) directly on the price candles. The position of these arrows is dynamically calculated based on the recent price range to ensure they remain visible and do not overlap with the candles.
- Real-Time Notifications: When a new signal is detected, the script can trigger an audible alert and a pop-up notification. These alerts include critical information such as the current Ask/Bid prices, the exact time of the signal, the currency symbol, and the timeframe being viewed.
4. Filtering Logic The script includes internal "flags" to ensure that signals are processed cleanly. This prevents the indicator from repeating the same alert multiple times on a single price movement, ensuring that you only receive a notification when a fresh trend shift occurs. It also includes an optional toggle to include signals from the "mid-point" (50) of the RSI range for traders who prefer more frequent, albeit less extreme, trading opportunities.
//+------------------------------------------------------------------+
//| RSI Signals.mq4 |
//| Copyright © 2010, Èâàí Òðåòüÿêîâ |
//| tretyak-off@inbox.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Èâàí Òðåòüÿêîâ"
#property link "tretyak-off@inbox.ru"
#property indicator_chart_window
#property indicator_buffers 4
//---- äëÿ RSI
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int RSIPeriod=14;
extern double _Up=70.0; //OverBoughtLevel - óðîâåíü ïåðåêóïëåííîñòè
extern double _Mid=50.0;
extern double _Down=30.0;//OverSoldLevel - óðîâåíü ïåðåïðîäàííîñòè
extern bool ShowMidSignals=false;
extern bool SoundON=true;
//---- çíà÷êè
extern int DownArrow=234;
extern int UpArrow=233;
//---- buffers
double UpBuffer[];
double DownBuffer[];
//---- ïåðåêëþ÷àòåëè
int flagval1=0;
int flagval2=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,DownArrow);//Âíèç
SetIndexBuffer(0,UpBuffer);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,UpArrow);//Ââåðõ
SetIndexBuffer(1,DownBuffer);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit,i,counter;
double Range,AvgRange;
double RSIPrev,RSIAnow;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if(counted_bars==0) limit-=1+9;
for(i=1; i<=limit; i++)
{
counter=i;Range=0;AvgRange=0;
for(counter=i;counter<=i+9;counter++)
{AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);}
Range=AvgRange/10;
RSIPrev=iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,i+1);
RSIAnow=iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,i);
UpBuffer[i]=EMPTY_VALUE;
DownBuffer[i]=EMPTY_VALUE;
if((RSIPrev<_Down) && (RSIAnow>_Down))
{
if(i==1 && flagval1==0)
{
flagval1=1;
flagval2=0;
if(SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
}
DownBuffer[i]=Low[i]-Range*0.5;
UpBuffer[i]=EMPTY_VALUE;
flagval1=0;
}
if((ShowMidSignals) && ((RSIPrev<_Mid) && (RSIAnow>_Mid)))
{
if(i==1 && flagval1==0)
{
flagval1=1;
flagval2=0;
if(SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
}
DownBuffer[i]=Low[i]-Range*0.5;
UpBuffer[i]=EMPTY_VALUE;
flagval1=0;
}
if((RSIPrev>_Up) && (RSIAnow<_Up))
{
if(i==1 && flagval2==0)
{
flagval2=1;
flagval1=0;
if(SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
}
UpBuffer[i]=High[i]+Range*0.5;
DownBuffer[i]=EMPTY_VALUE;
flagval2=0;
}
if((ShowMidSignals) && ((RSIPrev>_Mid) && (RSIAnow<_Mid)))
{
if(i==1 && flagval2==0)
{
flagval2=1;
flagval2=0;
if(SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
}
UpBuffer[i]=High[i]+Range*0.5;
DownBuffer[i]=EMPTY_VALUE;
flagval2=0;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments