Author: MetaQuotes
SmWPR

This tool is a custom technical analysis indicator designed to help traders visualize market momentum and identify specific entry or exit signals based on price action trends. It works by processing raw market data through several mathematical layers to smooth out "noise" and highlight significant shifts in sentiment.

Core Logic Overview

The script operates using three distinct stages of data processing:

1. Momentum Foundation (WPR) At its base, the tool utilizes the Williams Percent Range (WPR). This is a standard technical indicator that measures where the current price sits relative to its high and low range over a specific period. Essentially, it tells the script whether the market is currently "overbought" (near the top) or "oversold" (near the bottom).

2. Multi-Layer Smoothing (The Moving Average Chain) To prevent the data from being too jumpy or erratic, the script passes the WPR value through a series of six consecutive smoothing calculations. Think of this like a series of filters: each layer takes the result of the previous one and blends it with new data. By the time the data reaches the final stage, it has been refined multiple times to create a much smoother, more stable curve that represents the underlying trend of the market momentum.

3. Signal Calculation and Triggering Once the data is smoothed, the script applies a specific mathematical formula (a weighted calculation) to determine a final value. This value is plotted on your chart as a primary line.

The logic then looks for two specific threshold "breakout" points:

  • Sell Signal: If the calculated momentum drops below a certain negative level, the script identifies a potential downward trend.
  • Buy Signal: If the momentum rises above a different negative threshold, it identifies an upward shift.

Visual Output

The tool provides two visual elements in its own window:

  • The Main Line (Gold): This represents the smoothed momentum value. It allows you to see the "flow" of the market—whether it is gaining strength, losing steam, or moving sideways.
  • The Trigger Dots (Blue): These act as visual markers. When the momentum crosses the predefined thresholds determined by the script's logic, these dots appear to highlight specific moments where the trend might be changing direction.

Summary for the User

In simple terms, this script takes volatile market price movements, cleans them up through several layers of mathematical "polishing," and then flags specific points where the momentum moves from one extreme to another. It is designed to help you see the "big picture" of market movement while providing clear markers for potential trend shifts.

Indicators Used
Larry William percent range indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
SmWPR
//+------------------------------------------------------------------+
//|                                                   SmWPR-Rosh.mq4 |
//|                                                       MetaQuotes |
//|                 http://forum.alpari-idc.ru/viewtopic.php?t=48186 |
//+------------------------------------------------------------------+
#property copyright "MetaQuotes"
#property link      "http://forum.alpari-idc.ru/viewtopic.php?t=48186"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gold
#property indicator_color2 Blue

//---- input parameters
extern int       per=21;
extern int       psel=-15;
extern int       pbuy=-85;
extern double    t3_period=8.0;
extern double    b=0.7;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];

double e1Buffer[];
double e2Buffer[];
double e3Buffer[];
double e4Buffer[];
double e5Buffer[];
double e6Buffer[];

double c1,c2,c3,c4,n,w1,w2,b2,b3;
double t3,wpr,trig;

//+------------------------------------------------------------------+
//| User functions                                                   |
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(8);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE, STYLE_DOT);
   SetIndexBuffer(1,ExtMapBuffer2);

   SetIndexBuffer(2,e1Buffer);
   SetIndexBuffer(3,e2Buffer);
   SetIndexBuffer(4,e3Buffer);
   SetIndexBuffer(5,e4Buffer);
   SetIndexBuffer(6,e5Buffer);
   SetIndexBuffer(7,e6Buffer);
   
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);
   SetIndexEmptyValue(3,0.0);
   SetIndexEmptyValue(4,0.0);
   SetIndexEmptyValue(5,0.0);
   SetIndexEmptyValue(6,0.0);
   SetIndexEmptyValue(7,0.0);
   
   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;

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int shift,limit;
   if (counted_bars==0) limit=Bars-per;
   if (counted_bars>=0) limit=Bars-counted_bars;
   limit--;

   for (shift=limit;shift>=0;shift--)
      {

      wpr=iWPR(NULL,0,per,shift);

      e1Buffer[shift] = w1*wpr + w2*e1Buffer[shift+1];
      e2Buffer[shift] = w1*e1Buffer[shift] + w2*e2Buffer[shift+1];
      e3Buffer[shift] = w1*e2Buffer[shift] + w2*e3Buffer[shift+1];
      e4Buffer[shift] = w1*e3Buffer[shift] + w2*e4Buffer[shift+1];
      e5Buffer[shift] = w1*e4Buffer[shift] + w2*e5Buffer[shift+1];
      e6Buffer[shift] = w1*e5Buffer[shift] + w2*e6Buffer[shift+1];

      t3 = c1*e6Buffer[shift] + c2*e5Buffer[shift] + c3*e4Buffer[shift] + c4*e3Buffer[shift];

      if (t3>=-50) trig=psel; 
      if (t3<-50) trig=pbuy;

      ExtMapBuffer1[shift]=t3;  
      ExtMapBuffer2[shift]=trig;  

   }
 
   return(0);
  }
//+------------------------------------------------------------------+


Comments