SmWPRExp_nR
Download scriptThis tool is designed as a visual momentum indicator for trading platforms, specifically intended to help traders identify trend shifts and potential reversal points by smoothing out market volatility.
Core Functionality
The script works by taking raw price data and passing it through a multi-stage mathematical filter. Instead of simply reacting to every small price flicker, the logic aims to isolate the underlying "momentum" of the market. It achieves this by analyzing the relationship between current prices and historical data over a set period.
How the Logic Works
The internal process can be broken down into three main stages:
1. Data Input and Smoothing The tool begins by looking at a standard momentum oscillator (the WPR). To make this information more readable and less "noisy," the script applies a specialized smoothing technique. It takes the raw values and blends them with previous data points using a weighted calculation, ensuring that the resulting line flows smoothly across your chart rather than jumping erratically.
2. Advanced Trend Calculation Once the data is smoothed, the script performs a complex series of calculations (a polynomial expansion). This step is designed to calculate the "acceleration" or the true strength of the current trend. It looks at the interaction between multiple layers of these smoothed values to generate a specific trend value (represented by the gold line on your chart).
3. Signal Identification The final layer of logic determines when the market might be reaching an extreme state. The script constantly monitors the calculated trend value against two specific thresholds:
- Upper Threshold: If the trend value reaches a certain level, it identifies a potential area of overextension.
- Lower Threshold: If the trend value drops below a certain level, it identifies a corresponding opposite area of overextension.
The result is a dual-line display where one line shows you the continuous flow of momentum, and the second line (the red indicator) acts as a trigger, highlighting specific zones where the price movement may be reaching a turning point based on the predefined parameters.
//+------------------------------------------------------------------+
//| 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.8;
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);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
SetIndexBuffer(1, Buffer2);
SetIndexEmptyValue(1,0.0);
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;
}
int loop=Bars-IndicatorCounted();
Comment (loop);
for(shift=loop;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