Author: Copyright (c) 2005, Sergey Iljukhin, Novosibirsk
MIR_2L

This script functions as a sophisticated technical analysis tool designed to refine and smooth price action data in real-time. Its primary objective is to eliminate "market noise"—the small, erratic price fluctuations that can often lead to false signals—while ensuring the resulting trend line remains highly responsive to actual price movements.

Core Logic and Methodology

The script utilizes a Digital Filter approach, which moves beyond simple moving averages by using a mathematically precise weighted calculation. Here is how the logic unfolds step-by-step:

1. Multi-Layered Smoothing Instead of calculating the trend once, the script processes the data through two distinct stages of filtering. This "double filtering" technique acts like a high-quality lens: the first pass cleans up the initial jaggedness of the price, and the second pass applies that same mathematical logic to the already smoothed data. This results in a much cleaner, more stable output than a single filter could provide.

2. Weighted Price Attribution The tool does not treat all historical prices equally. It uses a specific set of coefficients (weights) for 30 different price points.

  • Recent prices are given higher priority to ensure the indicator stays "tight" to the current market activity.
  • Older prices are factored in with smaller weights to provide context and stability.
  • Specific negative and positive weights are balanced mathematically to suppress erratic spikes while allowing the underlying trend to flow smoothly.

3. Elimination of Lag A common problem with standard smoothing indicators is "lag," where the line trails too far behind the actual price. By utilizing this specific digital filter configuration, the script aims to strike a professional balance: it removes the "jitter" of the market without sacrificing the speed at which the indicator reacts to new information.

Visual Representation

The tool generates two distinct lines on your chart:

  • Primary Filter: The first level of smoothed data.
  • Secondary Filter: The highly refined, final output designed for trend analysis and decision-making.

In summary, this script serves as a professional-grade stabilizer. It transforms chaotic market data into a clear, readable trend, helping traders identify the true direction of price movement by filtering out the distractions of minor volatility.

Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
MIR_2L
//+------------------------------------------------------------------+
//|                     This filter created by Digital filter Method |
//|             Software(Copyright (c) Sergey Iljukhin, Novosibirsk. |
//|                     email sergey[at]tibet.ru http://fx.qrz.ru/). |
//|                Designing and special parameters are designed and |
//|                tested to remove more noise  and follow the price |
//|                instantly and reliably. This source code is free. |
//|                Designer: Saeid Mohammadi Jazi, saeid169@yahoo.com|    
//+------------------------------------------------------------------+
#property copyright "Copyright (c) 2005, Sergey Iljukhin, Novosibirsk"
#property link      "http://fx.qrz.ru/"

// --- Parameters: P1=20, D1=12, A1=40
// --- P2=36, D2=12, A2=40, Ripple=0.08, Delay=0
// --- Order [Auto]=30, Calculate method=2

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
#define FilterOrder 30

//---- buffers
double FilterBuffer[];
double FilterBuffer2[];

//+------------------------------------------------------------------+
//| Digital filter indicator initialization function                 |
//+------------------------------------------------------------------+
int init()
{
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,FilterBuffer);
SetIndexDrawBegin(0,61);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,FilterBuffer2);
SetIndexDrawBegin(1,62);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Digital filter main function                                     |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double response;
//----
if(Bars<=30) return(0);
//----
i=Bars-30-1;
if(counted_bars>=30) i=Bars-counted_bars-1;
while(i>=0)
{
response=
 0.2674159617898*Close[i]
 +0.2513802565774*Close[i+1]
 +0.2211333753570*Close[i+2]
 +0.1800616410930*Close[i+3]
 +0.1326480423408*Close[i+4]
 +0.0838587718677*Close[i+5]
 +0.0384533194950*Close[i+6]
 +0.000361380408010*Close[i+7]
 -0.02763961135328*Close[i+8]
 -0.0443785558740*Close[i+9]
 -0.0501417866008*Close[i+10]
 -0.0465638452107*Close[i+11]
 -0.0362043470551*Close[i+12]
 -0.02209069455035*Close[i+13]
 -0.00720956629679*Close[i+14]
 +0.00589037910713*Close[i+15]
 +0.01544079199829*Close[i+16]
 +0.02055957526714*Close[i+17]
 +0.02126036163880*Close[i+18]
 +0.01828930006698*Close[i+19]
 +0.01286478623414*Close[i+20]
 +0.00638761812864*Close[i+21]
 +0.0001646100607892*Close[i+22]
 -0.00480278407473*Close[i+23]
 -0.00796418634567*Close[i+24]
 -0.00925425730208*Close[i+25]
 -0.00909425465110*Close[i+26]
 -0.00839501788430*Close[i+27]
 -0.00872393363958*Close[i+28]
 +0.00629266940806*Close[i+29];
FilterBuffer[i]=response;

i--;
}
i=Bars-30-1;
if(counted_bars>=30) i=Bars-counted_bars-1;
while(i>=0)
{
double response2=
 0.2674159617898*FilterBuffer[i]
 +0.2513802565774*FilterBuffer[i+1]
 +0.2211333753570*FilterBuffer[i+2]
 +0.1800616410930*FilterBuffer[i+3]
 +0.1326480423408*FilterBuffer[i+4]
 +0.0838587718677*FilterBuffer[i+5]
 +0.0384533194950*FilterBuffer[i+6]
 +0.000361380408010*FilterBuffer[i+7]
 -0.02763961135328*FilterBuffer[i+8]
 -0.0443785558740*FilterBuffer[i+9]
 -0.0501417866008*FilterBuffer[i+10]
 -0.0465638452107*FilterBuffer[i+11]
 -0.0362043470551*FilterBuffer[i+12]
 -0.02209069455035*FilterBuffer[i+13]
 -0.00720956629679*FilterBuffer[i+14]
 +0.00589037910713*FilterBuffer[i+15]
 +0.01544079199829*FilterBuffer[i+16]
 +0.02055957526714*FilterBuffer[i+17]
 +0.02126036163880*FilterBuffer[i+18]
 +0.01828930006698*FilterBuffer[i+19]
 +0.01286478623414*FilterBuffer[i+20]
 +0.00638761812864*FilterBuffer[i+21]
 +0.0001646100607892*FilterBuffer[i+22]
 -0.00480278407473*FilterBuffer[i+23]
 -0.00796418634567*FilterBuffer[i+24]
 -0.00925425730208*FilterBuffer[i+25]
 -0.00909425465110*FilterBuffer[i+26]
 -0.00839501788430*FilterBuffer[i+27]
 -0.00872393363958*FilterBuffer[i+28]
 +0.00629266940806*FilterBuffer[i+29];
FilterBuffer2[i]=response2;

i--;
}


return(0);
}

Comments