WPRslow_v2
Download scriptOverview of the WPRslow Indicator
This trading tool is designed to analyze market momentum and provide visual cues regarding price trends. It utilizes a modified version of the Williams Percent Range (WPR), a popular technical indicator, but adds specific mathematical filters to refine the signal and reduce market "noise."
Instead of showing every fluctuation in price movement, this script identifies significant shifts by isolating extreme values. It provides a cleaner, more focused view of the market's strength by applying unique thresholds to the data.
Key Components of the Logic
1. Data Input and Range Selection The tool looks back at a specific historical period (defined by the "P" parameter) to calculate how far the price has moved relative to its high and low points during that timeframe. This helps establish the baseline for current market volatility.
2. Momentum Squaring and Normalization The core logic takes the standard Williams Percent Range value and squares it. By squaring the result, the script gives more weight to larger price movements while smoothing out minor fluctuations. The value is then normalized to ensure it remains within a manageable scale for the user to read.
3. Dynamic Threshold Filtering This is the primary feature that distinguishes this script from a standard WPR:
- The Upper Bound: If the calculated momentum stays below a specific low threshold (n1), the indicator marks it as an "Up" movement.
- The Lower Bound: If the calculated momentum exceeds a high threshold (n2), the indicator marks it as a "Down" movement.
4. Visual Representation The script translates these mathematical results into a visual histogram:
- Blue Histograms: Represent instances where the momentum meets the criteria for upward pressure.
- Red Histograms: Represent instances where the momentum meets the criteria for downward pressure.
How it Works in Practice
Rather than showing a continuous line that moves up and down with every tick of the market, this tool acts as a "filter." It remains neutral unless the price action becomes significant enough to cross the pre-defined boundaries (n1 and n2). When the price breaks these levels, the histogram provides a clear visual signal of which direction the momentum is favoring, helping traders identify potential trend shifts more clearly.
//+------------------------------------------------------------------+
//| WPRslow.mq4 |
//| Ramdass - Conversion only |
//+------------------------------------------------------------------+
#property copyright "Author - OlegVS"
//----
#property indicator_separate_window
#property indicator_minimum -1.0
#property indicator_maximum 1.0
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int P = 54;
extern int n1 = 9;
extern int n2 = 49;
extern int CountBars = 300;
//---- buffers
double Up[];
double Down[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2);
SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
SetIndexBuffer(0, Up);
SetIndexBuffer(1, Down);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("WPRslow(" + P + ", " + n1 + ", " + n2 + ")");
SetIndexLabel(0, "WPRslowUp(" + P + ", " + n1 + ", " + n2 + ")");
SetIndexLabel(1, "WPRslowDown(" + P + ", " + n1 + ", " + n2 + ")");
//----
if(CountBars > Bars)
CountBars = Bars;
SetIndexDrawBegin(0, Bars - CountBars + P);
SetIndexDrawBegin(1, Bars - CountBars + P);
//----
return(0);
}
//+------------------------------------------------------------------+
//| WPRslow |
//+------------------------------------------------------------------+
int start()
{
int i, counted_bars = IndicatorCounted();
double V1, V2;
//----
if(CountBars <= P)
return(0);
//---- initial zero
if(counted_bars < 1)
{
for(i = 1; i <= P; i++)
Up[CountBars-i] = 0.0;
for(i = 1; i <= P; i++)
Down[CountBars-i] = 0.0;
}
//----
i = CountBars - P - 1;
while(i >= 0)
{
Down[i] = 0.0;
Up[i] = 0.0;
V1 = iWPR(NULL, 0, P, i)*iWPR(NULL, 0, P, i) / 100;
V2 = MathCeil(V1);
if(V2 < n1)
{
Up[i] = V2;
}
if(V2 > n2)
{
Down[i] = -(V2);
}
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments