Zerolagstochs_v4

Author: Copyright � 2004, MetaQuotes Software Corp.
Zerolagstochs_v4

This tool is designed as a custom technical indicator for trading platforms, specifically engineered to provide a clearer view of market momentum by combining multiple data points into a single, smoothed visual output.

Core Logic and Methodology

The primary goal of this script is to eliminate the "lag" often associated with standard momentum indicators while filtering out unnecessary market noise. It achieves this through a multi-layered calculation process:

1. Multi-Timeframe Analysis (Weighted Aggregation) Instead of relying on a single Stochastic oscillator, the script calculates five different variations simultaneously. Each variation uses unique settings (different periods and price sensitivities) to capture various market behaviors—ranging from very short-term "fast" movements to longer-term "slow" trends.

2. Proportional Weighting Not all data points are treated equally. The script assigns a specific weight (percentage) to each of the five variations. By multiplying each oscillator by a specific coefficient and then summing them together, the tool creates a composite momentum value. This ensures that the resulting line represents a balanced "consensus" of the market's direction, rather than being swayed too heavily by a single outlier.

3. Advanced Smoothing Technique To ensure the final output is easy to read and visually stable, the script applies a sophisticated smoothing mechanism. It uses a moving average approach where the current calculated value is blended with the previous data point based on a "smoothing" factor. This prevents the line from flickering or jumping erratically, providing the user with a fluid trend line that highlights sustained price movement.

Visual Output

The script generates two distinct visual components:

  • The Momentum Trend: A primary line representing the weighted sum of all oscillators, showing the immediate strength of the current move.
  • The Smoothed Buffer: A secondary calculation that acts as a stabilized baseline, helping traders distinguish between temporary price fluctuations and actual trend changes.

Summary for the User

In simple terms, this indicator looks at five different "speeds" of market movement at once, weighs them based on their reliability, and blends them into one smooth, easy-to-follow line. It is designed to help you see where the market is headed by filtering out the "jitter" of price action while keeping the trend as updated as possible.

Indicators Used
Stochastic oscillator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
Zerolagstochs_v4
//+------------------------------------------------------------------+
//|                                                Zerolagstochs.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#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
//---- input parameters
double stok1 = 0, stok2 = 0, stok3 = 0, stok4 = 0, stok5 = 0, mov = 0,
       stoksmoothed = 0, smoothing = 15;
int shift = 0, MAType = 1, cnt = 0,  prevbars = 0, loopbegin = 0;
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("ZeroLagStocs");
//----
    return(0);
  }
//+------------------------------------------------------------------+
//|  Zero Lag Stocs                                                  |
//+------------------------------------------------------------------+
int start()
  {
   // initial checkings
   // check for additional bars loading or total reloading
    if(Bars < prevbars )  
        first = true;
    if(Bars - prevbars > 1) 
        first = true;
    prevbars = Bars;
    if(first) 
      {
	       // loopbegin prevent couning of counted bars exclude current
	       loopbegin = Bars - 1;
	       if(loopbegin < 0) 
	           return(0);      // not enough bars for counting
	       first = False;
      }
    loopbegin = loopbegin+1; 
// current bar is to be recounted too
    for(shift = loopbegin; 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;
	       loopbegin = loopbegin - 1;     
	     }
	   return(0);
	 }

	    

Comments