ZerolagstochsM
Download scriptThis tool is designed to provide traders with a more responsive and fluid view of market momentum compared to standard oscillators. Its primary objective is to reduce the "lag" often found in traditional technical indicators, allowing for a clearer visualization of price trends.
Core Logic and Methodology
The script operates by synthesizing multiple layers of data into a single, cohesive visual output. Here is a breakdown of how it processes market information:
Multi-Layered Data Synthesis Instead of relying on a single Stochastic calculation—which can often be noisy or slow to react—this indicator pulls data from five different Stochastic settings simultaneously. Each of these settings uses different "lookback" periods and weighting factors. By analyzing five distinct timeframes at once, the tool captures a broader spectrum of market behavior, from very short-term fluctuations to longer-term trends.
Weighted Averaging The script doesn't treat all five data sources equally. It applies specific percentage weights to each one (ranging from 5% to 43%). This ensures that the most significant trend drivers have a larger influence on the final result, while smaller, faster movements provide necessary "fine-tuning" to the data. These are combined to create a composite movement value.
Smoothing and Stability To ensure the final visual output is readable and not erratic, the script employs a custom smoothing technique. It takes the combined weighted average and blends it with its own previous values based on a user-defined "smoothing" parameter. This creates a "Zero Lag" effect; it aims to keep the line as close to the actual price action as possible while filtering out the "jitter" that typically makes indicators difficult to read in real-time trading.
Visual Output
The indicator produces two primary lines on your chart:
- Trend Buffer: Represents the raw combined weighted movement of the five Stochastic sources.
- Smoothed Buffer: Provides a refined, fluid version of that movement, designed to highlight the underlying trend with minimal delay.
By balancing high-frequency data with smoothed averages, this logic helps traders identify the strength and direction of a move more reliably than using standard tools alone.
//+------------------------------------------------------------------+
//| ZerolagstochsM.mq4 |
//| Copyright © 1.09.2006, MetaQuotes Software Corp. |
//| perky_z@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "perky_z@yahoo.com"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
extern int smoothing = 15;
extern int prevbars = 100;
//---- input parameters
double stok1, stok2, stok3, stok4, stok5, mov, stoksmoothed;
int shift, loopbegin;
bool first = true;
//---- buffers
double TrendBuffer[];
double LoBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffers
SetIndexBuffer(0, TrendBuffer);
SetIndexBuffer(1, LoBuffer);
//----
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("ZeroLagStocsM" + "(" + smoothing + ")");
SetIndexLabel( 0, "TrZLStocsM");
SetIndexLabel( 1, "LoZLStocsM");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Zero Lag Stocs |
//+------------------------------------------------------------------+
int start()
{
// initial checkings
// check for additional bars loading or total reloading
if(Bars < prevbars)
return(0); // not enough bars for counting
int counted_bars = IndicatorCounted();
if(counted_bars > 0)
counted_bars--;
int limit = Bars - counted_bars;
// current bar is to be recounted too
for(shift = limit; shift >= 0 ; shift--)
{
stok1 = iStochastic(NULL, 0, 8, 3, 3, MODE_SMA, NULL, MODE_MAIN, shift)*0.05;
stok2 = iStochastic(NULL, 0, 89, 21, 3, MODE_SMA, NULL, MODE_MAIN, shift)*0.43;
stok3 = iStochastic(NULL, 0, 55, 13, 3, MODE_SMA, NULL, MODE_MAIN, shift)*0.26;
stok4 = iStochastic(NULL, 0, 34, 8, 3, MODE_SMA, NULL, MODE_MAIN, shift)*0.16;
stok5 = iStochastic(NULL, 0, 21, 5, 3, MODE_SMA, NULL, MODE_MAIN, shift)*0.10;
mov = stok1 + stok2 + stok3 + stok4 + stok5;
stoksmoothed = mov / smoothing + LoBuffer[shift+1]*(smoothing - 1) / smoothing;
TrendBuffer[shift] = mov;
LoBuffer[shift] = stoksmoothed;
}
return(0);
}
//+------------------------------------------------------------------+
Comments