WPR_RSI_cross_alert
Download scriptThis script is a specialized technical analysis tool designed to monitor and notify traders of specific interactions between two popular market indicators: the Williams Percent Range (WPR) and the Relative Strength Index (RSI). Instead of looking at these tools in isolation, this script tracks their relative positions to identify potential momentum shifts in real-time.
How the Logic Works
1. Data Processing & Visualization The script continuously calculates two distinct data streams on your chart:
- RSI: Measures the speed and change of price movements to identify overbought or oversold conditions.
- WPR: Measures where the current price is relative to its high-low range over a specific period. For the purpose of this script, the WPR values are adjusted to be displayed on a compatible scale with the RSI for easier visual comparison.
2. The "Crossover" Strategy The core intelligence of this script lies in detecting a "crossover" event. It treats the two indicators as lines on a graph and looks for the exact moment one line moves from below to above (or vice versa) the other.
- Bullish Signal (Upward Cross): The logic monitors for a moment where the WPR line was previously below the RSI line but has moved to cross above it. This is interpreted as an upward shift in momentum.
- Bearish Signal (Downward Cross): Conversely, the script identifies when the WPR line moves from above the RSI line to cross below it, signaling a potential downward shift in momentum.
3. Automated Notifications To ensure you don't have to constantly watch the screen for these microscopic movements, the script includes an automated alert system. When a crossover is detected:
- The script triggers an instant pop-up alert on your platform.
- The notification provides specific details, including the current asset (Symbol), the timeframe of the chart, the current market price, and the specific direction of the cross (Up or Down).
4. Smart Filtering To prevent your workspace from being flooded with repetitive messages, the logic includes a "time-stamp" filter. This ensures that once an alert is triggered for a specific moment in time, it will not repeat the same notification until a new price candle is formed.
//+------------------------------------------------------------------+
//| WPR_RSI_cross_alert_sw |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//2008 fxtsd ki
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 1
#property indicator_level1 80
#property indicator_level2 50
#property indicator_level3 20
#property indicator_levelstyle 2
#property indicator_levelcolor DarkOliveGreen
extern int WPR_period= 14;
extern int RSI_period = 9;
extern int RSI_price = 0;
extern bool alert = true;
string short_name;
double WPR_Buffer[];
double RSI_Buffer[];
//---
int init()
{
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(0,WPR_Buffer);
SetIndexBuffer(1,RSI_Buffer);
short_name= "WPR ("+WPR_period+") x RSI ("+RSI_period+") ";
IndicatorShortName(short_name);
SetIndexLabel(0,"WPR");
SetIndexLabel(1,"RSI");
return(0);
}
//+---
int start()
{
int counted_bars=IndicatorCounted();
if(counted_bars<0) counted_bars=0;
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
for(int i=0; i<limit;i++)
{
RSI_Buffer[i] = iRSI(NULL,0,RSI_period,RSI_price,i);
WPR_Buffer[i] = iWPR(NULL,0,WPR_period,i)+100;
}
static datetime lastalertUp=0,lastalertDn=0;
string alertmessage = "WPRxRSI: " +Symbol()+" chart M"+Period()+" Bid price "+DoubleToStr(Bid,4)+"; " ;
if (WPR_Buffer[1]<RSI_Buffer[1] && WPR_Buffer[0]>RSI_Buffer[0] && alert && lastalertUp!=Time[0])
{ Alert(alertmessage +short_name+": WPR crossed RSI Up");
lastalertUp=Time[0];
}
if (WPR_Buffer[1]>RSI_Buffer[1] && WPR_Buffer[0]<RSI_Buffer[0] && alert && lastalertDn!=Time[0])
{ Alert(alertmessage +short_name+": WPR crossed RSI Down");
lastalertDn=Time[0];
}
return(0);
}
Comments