SmWPR_test
Download scriptThis tool is designed to function as a visual aid for traders, helping them identify potential momentum shifts and price action trends by processing historical market data. Rather than looking at raw prices alone, it applies a layered mathematical filter to smooth out "noise" and highlight specific signals.
How the Logic Works
1. Data Foundation (The Williams %R) The core of this script begins with a standard momentum oscillator known as the Williams %R. This measures the relative position of the current price compared to its high and low over a set period. By using this as a starting point, the tool establishes a baseline for how "overbought" or "oversold" the market currently feels.
2. Multi-Layer Smoothing (The Triple Exponential Filter) To prevent the erratic jumps common in raw momentum data, the script puts the information through a series of successive smoothing calculations. It takes the initial data and passes it through multiple stages of weighted averages.
- Think of this like a "blur" effect on a photo: each layer reduces the jagged edges of the data.
- By applying three layers of this filtering, the script creates a much more stable and fluid line that reveals the underlying trend without getting distracted by minor, temporary price fluctuations.
3. Trend Identification and Signal Generation Once the data is smoothed, the tool evaluates the resulting values to generate two distinct visual components on your chart:
- The Main Trend Line: This represents the processed momentum. It allows you to see the "flow" of the market more clearly than a standard oscillator might.
- Dynamic Trigger Levels: The script constantly monitors the smoothed value against specific mathematical thresholds.
- When the value reaches a certain high point, it identifies a potential "sell" zone.
- When the value drops to a specific low point, it identifies a potential "buy" zone.
Summary for the User
Instead of reacting to every small tick in price, this script distills market movement into a stabilized trend line. It effectively filters out the "static" of the market so you can focus on the broader momentum. By identifying specific thresholds where the smoothed momentum becomes extreme, it provides visual cues for potential reversal points or entries, helping you stay aligned with the prevailing market direction.
//+------------------------------------------------------------------+
//| SmWPR.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gold
#property indicator_color2 Red
//---- input parameters
extern int x_prd=0;
extern int t3_period=8;
extern double b=0.8;
extern int per=14;
extern int psel=-25;
extern int pbuy=-75;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double e1, e2, e3, e4, e5, e6, c1, c2, c3, c4, n, w1, w2, b2, b3;
double dpo, t3, shift, wpr, trig;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
b2=b*b;
b3=b2*b;
c1=-b3;
c2=(3*(b2+b3));
c3=-3*(2*b2+b+b3);
c4=(1+3*b+b3+3*b2);
n=t3_period;
if (n<1) n=1;
n = 1 + 0.5*(n-1);
w1 = 2 / (n + 1);
w2 = 1 - w1;
for(int i=Bars-1; i>=0; i--)
{
wpr=iWPR(NULL,0,per,i);
dpo=wpr;
e1 = w1*dpo + w2*e1;
e2 = w1*e1 + w2*e2;
e3 = w1*e2 + w2*e3;
e4 = w1*e3 + w2*e4;
e5 = w1*e4 + w2*e5;
e6 = w1*e5 + w2*e6;
t3 = c1*e6 + c2*e5 + c3*e4 + c4*e3;
if (t3>=-50) trig=psel;
if (t3<-50) trig=pbuy;
ExtMapBuffer1[i]=t3;
ExtMapBuffer2[i]=trig;
}
return(0);
}
//+------------------------------------------------------------------+
Comments