Author: Copyright � 2005, Nick Bilak
slow-stoch

This custom technical indicator is designed to provide a smoother, more stable visualization of market momentum by refining standard Stochastic oscillator data. While a typical Stochastic indicator can sometimes produce "noisy" or erratic price fluctuations that lead to false signals, this specific script applies a mathematical smoothing technique to filter out those inconsistencies.

Core Logic and Functionality

The indicator operates by taking the standard output of a Stochastic oscillator—a tool used to identify whether an asset is overbought or oversold—and calculating a moving average over the most recent three data points.

Specifically, it performs the following actions:

  • Data Averaging: Instead of displaying the immediate, raw value of the current market movement, the script looks back at the current point and the two preceding points. It then calculates the mathematical mean of these three values for both the "Main" line and the "Signal" line.
  • Noise Reduction: By averaging these three consecutive points, the indicator creates a "slow-stitch" effect. This suppresses sudden, momentary spikes in price action that do not represent a true trend change, resulting in a cleaner visual representation on your chart.
  • Visual Output: The result is displayed in a separate window below your main price chart. It provides two distinct lines:
    • The primary line represents the smoothed momentum of the market.
    • The secondary signal line helps identify potential turning points where the smoothed momentum begins to shift direction.

Practical Application

For a trader, this logic means that the indicator is less likely to react impulsively to minor price "jitters." By smoothing the data over a three-period window, the script aims to provide a more reliable perspective on market trends, helping users identify significant shifts in momentum with greater clarity than a standard, non-smoothed oscillator.

Indicators Used
Stochastic oscillator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
slow-stoch
//+------------------------------------------------------------------+
//|                                                   slow-stich.mq4 |
//|                                     Copyright © 2005, Nick Bilak |
//|                                              beluck[at]gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Nick Bilak"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 Aqua
//---- input parameters
extern int PK=14;
extern int PD=5;
extern int PS=5;
//---- buffers
double k[];
double d[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,k);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,d);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   int shift,limit;
   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
   limit=Bars-PK-1;
   if(counted_bars>=PK) limit=Bars-counted_bars-1;

   for (shift=limit;shift>=0;shift--)   {
		d[shift]=(iStochastic(NULL,0,PK,PD,PS,MODE_SMA,1,MODE_SIGNAL,shift)+iStochastic(NULL,0,PK,PD,PS,MODE_SMA,1,MODE_SIGNAL,shift+1)+iStochastic(NULL,0,PK,PD,PS,MODE_SMA,1,MODE_SIGNAL,shift+2))/3.0;
		k[shift]=(iStochastic(NULL,0,PK,PD,PS,MODE_SMA,1,MODE_MAIN,shift)+iStochastic(NULL,0,PK,PD,PS,MODE_SMA,1,MODE_MAIN,shift+1)+iStochastic(NULL,0,PK,PD,PS,MODE_SMA,1,MODE_MAIN,shift+2))/3.0;
   }
   return(0);
  }
//+------------------------------------------------------------------+

Comments