William36HistogramWallerTest1

William36HistogramWallerTest1

This custom technical indicator is designed to help traders identify potential overbought and oversold conditions by analyzing price momentum. It functions as a visual dashboard that interprets market extremes and provides real-time notifications when specific price movements occur.

Core Logic and Calculation

The script utilizes a modified version of the "Williams %R" oscillator. It calculates where the current closing price sits relative to the highest highs and lowest lows over a 40-period window. By normalizing this data, the indicator creates a scale that helps users see if the market is stretched too far in one direction or is showing signs of exhaustion.

The visual output is split into two primary components:

  • Positive Momentum (Upper Histogram): When the calculated value is above zero, it is displayed in lime green.
  • Negative Momentum (Lower Histogram): When the value falls below zero, it is displayed in red.

Signal Detection and Alerts

Beyond just providing a visual histogram, the script contains internal logic to "track" shifts in momentum. It monitors for "crosses"—moments where the indicator flips from positive to negative or vice versa.

The indicator uses these switches to trigger specific actions:

  • Buy Signals: If the momentum swings into a favorable position and reaches a specific strength threshold (above +15), the script triggers a "BUY" alert.
  • Sell Signals: If the momentum swings into a bearish position and reaches a specific weakness threshold (below -15), the script triggers a "SELL" alert.

User Experience Features

To ensure the trader is always aware of the current status, the script provides real-time feedback directly on the chart:

  • On-Screen Comments: The indicator constantly updates a text comment on the screen. It will explicitly state whether a "BUY SWITCH," a "SELL SWITCH," or "NO SWITCH" is currently active, along with the specific numerical data driving that status.
  • Audio/Popup Alerts: When the predefined price conditions are met, the script generates a system alert to notify the trader immediately without them having to watch the screen constantly.

In summary, this tool transforms raw price data into a clear visual histogram while acting as an automated surveillance system that filters out minor fluctuations to highlight significant momentum shifts.

Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
William36HistogramWallerTest1
/* 
original formula)
WH:=HHV(HIGH,5);
WL:=LLV(LOW,5);

//WRD:=(( HHV( WH,36 )-c ) /( HHV(WH,36 ) - LLV( WL,36) ) ) *- 100,

//WDo:=WRD+50;

//WU:=IF(WDo>0,WDo,0);
//WD:=IF(WDo<0,WDo,0);
//{- this will give you the william's when it is below zero and it is plotted red}
//LN:=0;

*/

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 LimeGreen
#property indicator_color2 Red
#property indicator_color3 Gray
#property indicator_maximum 50
#property indicator_minimum -50
#property indicator_level1 0
#property indicator_level2 15
#property indicator_level3 -15
//---- input parameters


//---- buffers

double WU[],WD[],W[],Zero[];
int Ssw=0,Bsw=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 3 additional buffers are used for counting.
   IndicatorBuffers(4);
   SetIndexBuffer(3,W);
//---- indicator lines
   SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
   SetIndexBuffer(0,WU);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
   SetIndexBuffer(1,WD);
      SetIndexStyle(2,DRAW_LINE,0,2);
   SetIndexBuffer(2,Zero);
//---- name for DataWindow and indicator subwindow label
   short_name="William%R36 With Alert";
   IndicatorShortName(short_name);


//---- indicator lines
  

//----
   SetIndexDrawBegin(0,40);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| BSPVolume                                       
//+------------------------------------------------------------------+
int start()
 {
   int    i,k,counted_bars=IndicatorCounted();
   
   if(Bars<=40) return(0);
//---- initial zero
/* 
  if(counted_bars<1)
     {
      for(i=1;i<=CCIPeriod;i++) CCIBuffer[Bars-i]=0.0;
      for(i=1;i<=CCIPeriod;i++) DevBuffer[Bars-i]=0.0;
      for(i=1;i<=CCIPeriod;i++) MovBuffer[Bars-i]=0.0;
     }
*/
//---- last counted bar will be recounted
   int limit=Bars-counted_bars;
   if (counted_bars>0) limit++; else if (limit>3000) limit=3000;

   
   
   for(i=0; i<limit; i++)
      W[i]=50+(-100)*(High[Highest(NULL,0,MODE_HIGH,40,i)]-Close[i])/(High[Highest(NULL,0,MODE_HIGH,40,i)]-Low[Lowest(NULL,0,MODE_LOW,40,i)]);

   for(i=0; i<limit; i++) Zero[i]=0;
   
   for(i=0; i<limit; i++)
  {
  
  
        
     if (W[i]<0 && W[i+1]>0 && i<2) 
     {
     Ssw=1;
     Bsw=0;
     }
        
     if (W[i]>0 && W[i+1]<0 && i<2) 
     {
     Ssw=0;
     Bsw=1;
     }
     
      
     if (Bsw==1 && i<2 && W[i]>=15 )
         {
     Ssw=0;
     Bsw=0;
       Alert (Symbol()," ",Period()," Willy Says B U Y");
         }
       if (Ssw==1 && i<2 && W[i]<=-15 )
         {
     Ssw=0;
     Bsw=0;
       Alert (Symbol()," ",Period()," Willy Says S E L L");
     }
 if (Ssw==1) Comment ("SELL SWITCH ON","i ",i,"W[i] ",W[i],"W[i+1] ",W[i+1]);
 if (Bsw==1) Comment ("BUY SWITCH ON","i ",i,"W[i] ",W[i],"W[i+1] ",W[i+1]);
 if (Bsw==0 && Ssw==0) Comment ("NO SWITCH ON","i ",i,"W[i] ",W[i],"W[i+1] ",W[i+1]);
 
 
   if (W[i]>0)
      {WU[i]=W[i];WD[i]=0;}
      
      else if (W[i]<0)
          {WU[i]=0;WD[i]=W[i];}
          
            else {WU[i]=0;WD[i]=0;}
        }    
            return(0);
   
}

Comments