WilliamsPR_alert

WilliamsPR_alert

This tool is designed as a visual monitoring system for your trading platform, specifically built to track market momentum and identify potential entry points based on price extremes. It operates by calculating a specific technical metric (the Williams Percent Range) over a customizable period to help traders distinguish between "overextended" market conditions.

How the Logic Works

The script functions by scanning historical and real-time price data to plot a line in a dedicated window below your main chart. It focuses on identifying two specific zones: extreme lows and extreme highs.

1. Trend Tracking and Visualization The tool continuously calculates the current market position based on the user-defined period (defaulting to 90). It then plots this movement as a line, allowing you to see how quickly price is moving toward its limits. To assist with clarity, it features pre-set horizontal levels that act as "thresholds" for high and low market activity.

2. Signal Identification The core logic monitors the current value of this indicator against two specific thresholds:

  • The "Buy" Zone: When the indicator drops below a very deep negative level (specifically -95), the script recognizes that the asset may be oversold. It identifies this as a potential opportunity for a "Long" position.
  • The "Sell" Zone: When the indicator rises above a specific upper limit (specifically -5), it recognizes that the asset may be overbought, signaling a potential opportunity for a "Short" position.

3. Smart Notifications To ensure you don't miss these movements while away from your screen, the script includes an intelligent alert system. It is programmed to recognize when the indicator crosses into these extreme zones for the first time. When a threshold is breached, the tool can:

  • Trigger an immediate pop-up alert on your trading platform.
  • Send an automated email notification (if enabled in the settings).

4. Dynamic Labeling The script provides real-time feedback directly on your screen by updating its status label. It communicates the current "signal" state—telling you clearly whether the market is currently showing a "Long" or "Short" bias based on the most recent data points. This helps traders quickly identify the sentiment of the market at a glance.

Indicators Used
Larry William percent range indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
17 Views
0 Downloads
0 Favorites
WilliamsPR_alert

#property indicator_separate_window
#property indicator_buffers 1 
#property indicator_color1 Magenta 
#property indicator_maximum 0
#property indicator_minimum -100
#property indicator_level1 -5
#property indicator_level2 -95
#property indicator_level3 -50
#property indicator_levelwidth 1
#property indicator_levelstyle STYLE_SOLID
#property indicator_levelcolor Aqua

extern int WPRPeriod = 90;
extern bool Alerts = true;
extern bool UseSendMail = false;

double ExtMapBuffer1[]; 
int shortA;
int longA;
datetime lasttime = 0;

int init() 
  { 
   SetIndexStyle(0,DRAW_LINE); 
   SetIndexBuffer(0,ExtMapBuffer1);
   IndicatorShortName("%R(WPRPeriod)");
   
   return(0); 
  } 

int deinit() 
  { 
//----  
    
//---- 
   return(0); 
  } 


int start() 
  { 
    int    counted_bars=IndicatorCounted(); 
   if (counted_bars<0) return(-1); 
   if (counted_bars>0) counted_bars--; 
    
   int pos=Bars-counted_bars; 
 //  Alert(TimeCurrent());
   while(pos>=0) 
     { 
         ExtMapBuffer1[pos] = iWPR(NULL, 0, WPRPeriod, pos);          
         pos--; 
     } 
     
    

      if ( iWPR(NULL, 0, WPRPeriod, 0) > -95) {
         longA = 0;
         IndicatorShortName("%R("+WPRPeriod+")");
      }
      if ( iWPR(NULL, 0, WPRPeriod, 0) < -5) {
         shortA = 0;
          IndicatorShortName("%R("+WPRPeriod+")");
      }
      
          
      if ( iWPR(NULL, 0, WPRPeriod, 0) < -95 && longA != 1) {
         if (lasttime != Time[0]) {
          if (Alerts == true)Alert(Symbol()+" %R("+WPRPeriod+") is below -95. Buy if in blue zone.");
          if (UseSendMail == true)  SendMail(Symbol()+" %R("+WPRPeriod+") is below -95. Buy if in blue zone"," ");
          lasttime = Time[0];
         }
           IndicatorShortName("%R("+WPRPeriod+") Current signal: LONG  ");
          longA=1;        
      }
      if ( iWPR(NULL, 0, WPRPeriod, 0) > -5 && shortA != 1) {
      if (lasttime != Time[0]) {
          if (Alerts == true)Alert(Symbol()+" %R("+WPRPeriod+") is above -5. Sell if in red zone.");    
          if (UseSendMail == true) SendMail(Symbol()+" %R("+WPRPeriod+") is above -5. Sell if in red zone"," ");
          lasttime = Time[0];
        }
          IndicatorShortName("%R("+WPRPeriod+") Current signal: SHORT  ");
          shortA = 1;   
      }      
   return(0); 
  } 

Comments