Vasily_Pip_Sniper_v3.1Ratio2xx
Download scriptThe Vasily Pip Sniper is a technical analysis tool designed to help traders identify momentum and trend direction by analyzing price action through multiple layers of moving averages. Instead of simply showing you where the price is, it calculates the relationship between different mathematical trends to provide a clearer picture of market movement.
Core Logic and Functionality
The indicator operates using several distinct layers of logic to interpret market data:
1. Dynamic Period Adjustment The script is intelligent enough to recognize the timeframe you are viewing (e.g., 1-minute, hourly, or daily charts). It contains a built-in "smart" system that automatically adjusts its calculation periods to suit that specific timeframe. However, it also gives users the manual override to set custom periods if they prefer a personalized feel.
2. Multi-Layered Moving Averages The tool calculates four primary data streams using different moving average methods (such as Simple, Exponential, Smoothed, or Linear Weighted). By calculating these across different periods (a "Fast" period and a "Slow" period), the script can distinguish between short-term price fluctuations and long-term market trends.
3. The "Difference" Calculation (The Sniper Logic) This is where the unique logic resides. Rather than just plotting lines, the script performs a secondary calculation on its primary data:
- It identifies the difference between the Fast and Slow trend components.
- It then calculates the percentage variance of these differences.
- By converting this into a percentage-based value, it creates a "momentum" indicator that shows how strongly the price is pulling away from its historical average.
4. Visual Representation The final output is displayed in a separate window at the bottom of your trading platform.
- Upward Momentum: Shown as a positive value (Blue line), indicating the strength of the current trend.
- Downward Momentum: Shown as a negative value (Red line), indicating the strength of the bearish movement.
- Secondary Reference: A third line (Green) provides an additional layer of confirmation based on slightly offset calculations, helping to filter out "noise" and confirm the reliability of the primary signals.
Summary for the Trader
Essentially, this script acts as a momentum filter. By analyzing the gap between fast and slow moving averages and expressing that gap as a percentage, it highlights when a trend is accelerating or losing steam. It helps traders see not just where the price is going, but how aggressively it is moving in that direction.
//+------------------------------------------------------------------+
//| Vasily Pip Sniper.mq4 |
//| By: E |
//| |
//+------------------------------------------------------------------+
//mod2008fxtsd
#property copyright "By: E"
//----
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 1
#property indicator_level1 1
#property indicator_level2 0.25
#property indicator_level3 -0.25
#property indicator_level4 -1
#property indicator_levelcolor DarkSlateGray
extern int Price = 6;
extern int Method = 3;
extern int Methodx = 1;
extern bool UseUserVariables = True;
extern int FastPeriod = 11;//21
extern int SlowPeriod = 21;//144
extern int deltax = 1;
extern string notes = "If UseUserVariables set to false, Fast&SlowPeriods are preset for each TF";
extern string price_ = "0C 1O 2H 3L 4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string Method_ = "SMA0 EMA1 SMMA2 LWMA3";
//---- parameters
int per1, per2;
//---- buffers
double up[];
double dn[];
double upx[];
double WorkBuffer[];
double WorkBuffer2[];
double WorkBufferx[];
double WorkBuffer2x[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
if (!UseUserVariables)
{
// for monthly
int mn_per = 12;
int mn_fast = 3;
// for weekly
int w_per = 9;
int w_fast = 3;
// for daily
int d_per = 5;
int d_fast = 3;
// for H4
int h4_per = 12;
int h4_fast = 2;
// for H1
int h1_per = 24;
int h1_fast = 8;
// for M30
int m30_per = 16;
int m30_fast = 2;
// for M15
int m15_per = 16;
int m15_fast = 4;
// for M5
int m5_per = 12;
int m5_fast = 3;
// for M1
int m1_per = 30;
int m1_fast = 10;
//----
}
//----
if (UseUserVariables)
{
per1=FastPeriod;
per2=SlowPeriod;
}
else
{
switch(Period())
{
case 1: per2 = m1_per; per1 = m1_fast; break;
case 5: per2 = m5_per; per1 = m5_fast; break;
case 15: per2 = m15_per; per1 = m15_fast; break;
case 30: per2 = m30_per; per1 = m30_fast; break;
case 60: per2 = h1_per; per1 = h1_fast; break;
case 240: per2 = h4_per; per1 = h4_fast; break;
case 1440: per2 = d_per; per1 = d_fast; break;
case 10080: per2 = w_per; per1 = w_fast; break;
case 43200: per2 = mn_per; per1 = mn_fast; break;
}
}
string Indicator_Name = "Vasily Pip Sniper ZL ("+per1+","+ per2+") ";
//-----
IndicatorBuffers(7);
SetIndexStyle (0, DRAW_LINE);
SetIndexBuffer(0, up);
SetIndexStyle (1, DRAW_LINE);
SetIndexBuffer(1, dn);
SetIndexStyle (2, DRAW_LINE);
SetIndexBuffer(2, upx);
SetIndexBuffer(3, WorkBuffer);
SetIndexBuffer(4, WorkBuffer2);
SetIndexBuffer(5, WorkBufferx);
SetIndexBuffer(6, WorkBuffer2x);
SetIndexDrawBegin(0, per1 + per2);
SetIndexDrawBegin(1, per1 + per2);
SetIndexDrawBegin(2, per1 + per2);
IndicatorShortName(Indicator_Name);
SetIndexLabel(0, "up "+Method );
SetIndexLabel(1, "dn "+Method );
SetIndexLabel(2, "upx "+Methodx );
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars = IndicatorCounted();
//----
if(counted_bars < 0)
return(-1);
//----
if(counted_bars > 0)
counted_bars --;
limit = Bars - counted_bars;
//----
for(int i = 0; i < limit; i++)
{
WorkBuffer[i] = iMA(NULL, 0, per1, 0, Method, Price, i);
WorkBuffer2[i]= iMA(NULL, 0, per2, 0, Method, Price, i);
WorkBufferx[i] = iMA(NULL, 0, per1+deltax, 0, Methodx, Price, i);
WorkBuffer2x[i]= iMA(NULL, 0, per2+deltax, 0, Methodx, Price, i);
}
for(i = 0; i < limit; i++)
{
double wMA, wMA2, lMA, sMA;
double wMAx, wMA2x, lMAx, sMAx;
wMA = iMAOnArray(WorkBuffer, 0, per1, 0, Method, i);
lMA = 2*WorkBuffer[i]-wMA ;
wMA2 = iMAOnArray(WorkBuffer2, 0, per2, 0, Method, i);
sMA = 2*WorkBuffer2[i]-wMA2;
wMAx = iMAOnArray(WorkBufferx, 0, per1, 0, Methodx, i);
lMAx = 2*WorkBufferx[i]-wMAx ;
wMA2x = iMAOnArray(WorkBuffer2x, 0, per2, 0, Methodx, i);
sMAx = 2*WorkBuffer2x[i]-wMA2x;
up [i]=100*(lMA-sMA)/sMA;
upx[i]=100*(lMAx-sMAx)/sMAx;
dn [i]=-1*up[i];
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
Comments