SmWPRExp
Download scriptThis script is a technical analysis tool designed for the MetaTrader 4 platform. Its primary purpose is to smooth out market price fluctuations and identify specific trend reversals or momentum shifts by analyzing historical price data over a set period.
Core Functionality
The indicator functions by processing "Wrapped Price Ratio" (WPR) data—a common metric used to determine whether an asset is overbought or oversold. Rather than looking at these raw numbers directly, the script subjects them to a multi-stage smoothing process. This helps filter out "market noise" (minor, insignificant price jumps) so that only significant movements are highlighted.
How the Logic Works
- Data Smoothing: The tool uses a series of weighted calculations to create a moving average of the market's momentum. By layering these calculations on top of each other, it creates a much smoother curve than a standard moving average would provide. This allows for a clearer view of the underlying trend.
- Trend Calculation: The script calculates a specific value (represented as a "t3" value) based on the weighted averages. This value represents the current momentum state of the asset.
- Signal Generation: The logic then looks for specific thresholds in this smoothed momentum:
- It monitors whether the calculated momentum value stays above or falls below a specific limit (in this case, -50).
- When the momentum crosses these pre-defined boundaries, the script identifies a "trigger."
- Visual Output: The tool provides two visual elements on your chart:
- A continuous line that shows the smoothed momentum path.
- Specific trigger points (signals) that appear when the momentum reaches extreme levels, helping traders identify potential areas of interest where the price might be overextended.
Summary for Users
In simple terms, this script acts as a "filter" for market volatility. It takes raw price data, smooths it out to see the bigger picture, and then highlights specific moments where the momentum becomes significantly strong or weak enough to potentially signal a change in direction.
//+------------------------------------------------------------------+
//| SmWPRExp.mq4 |
//| 30.08.2006 Translated on MT4 by Oleg Golozubov aka Maloma |
//+------------------------------------------------------------------+
#property copyright " Copyright © 2006, HomeSoft Corp."
#property link " spiky@sinet.spb.ru"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gold
#property indicator_color2 Red
#include <stdlib.mqh>
extern double t3_period = 8;
extern double b = 0.7;
extern double per = 14;
extern double psel = -25;
extern double pbuy = -75;
extern double mBar = 300;
double Buffer1[];
double Buffer2[];
int init()
{
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
SetIndexBuffer(0, Buffer1);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
SetIndexBuffer(1, Buffer2);
return(0);
}
int start()
{
double e1 = 0;
double e2 = 0;
double e3 = 0;
double e4 = 0;
double e5 = 0;
double e6 = 0;
double c1 = 0;
double c2 = 0;
double c3 = 0;
double c4 = 0;
double n = 0;
double w1 = 0;
double w2 = 0;
double b2 = 0;
double b3 = 0;
double dpo = 0;
double t3 = 0;
int shift = 0;
double wpr = 0;
double trig = 0;
bool ft = true;
if(ft)
{
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;
ft=false;
}
for(shift=Bars-1;shift>=0;shift--)
{
Buffer1[shift]=0;
Buffer2[shift]=0;
}
for(shift=mBar;shift>=0;shift--)
{
wpr=iWPR(NULL, 0, per,shift);
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;
Buffer2[shift]=trig;
Buffer1[shift]=t3;
}
return(0);
}
Comments