MIR_osc2L
Download scriptThis script is a sophisticated technical analysis tool designed to provide a cleaner, more reliable view of market price movements by filtering out "market noise." In trading, noise refers to the small, erratic price fluctuations that can often mislead traders and trigger false signals.
Here is a breakdown of how the logic works in plain English:
Core Objective
The primary goal of this tool is to smooth out price action so that you can see the underlying trend more clearly. It achieves this by using a "Digital Filter" method, which mathematically processes historical price data to produce a refined output that follows the actual price path more closely than standard moving averages might.
How the Logic Works
The script operates through a multi-stage calculation process:
-
Primary Smoothing (The Foundation): The tool takes the most recent closing prices and applies a complex weighted formula to them. Each of the last 30 price points is multiplied by a specific coefficient. Some weights are positive, while others are negative. This "balancing" act allows the indicator to react quickly to significant changes while ignoring minor vibrations in the data.
-
Secondary Smoothing (The Refinement): Instead of just showing the result of the first calculation, the script takes that smoothed data and runs it through the exact same weighted formula a second time. By "filtering the filter," the tool significantly reduces lag—one of the biggest problems with traditional indicators—while maintaining a high level of stability.
-
Trend and Slope Analysis: Finally, the script performs subtraction calculations to derive two specific visual outputs:
- The Difference: It subtracts the second filtered value from the first to highlight immediate shifts in price momentum.
- The Slope: It calculates the change between consecutive results to determine the "steepness" or velocity of the trend.
Key Benefits for the User
- Reduced Noise: By neutralizing minor market fluctuations, the tool helps traders focus on the real direction of the market.
- Responsiveness: The specific mathematical coefficients used are designed to ensure the indicator follows the price instantly, rather than trailing far behind the current candle.
- Visual Clarity: The script provides distinct visual lines (colored in Dodger Blue and Red) that represent the filtered price and its slope, allowing for a quicker assessment of whether a trend is accelerating, slowing down, or reversing.
//+------------------------------------------------------------------+
//| 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_separate_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
#define FilterOrder 30
//---- buffers
double FilterBuffer[];
double FilterBuffer2[];
double FilterBuffer3[];
double FilterBuffer4[];
//+------------------------------------------------------------------+
//| Digital filter indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator line
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,FilterBuffer3);
SetIndexDrawBegin(0,61);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,FilterBuffer4);
SetIndexDrawBegin(1,61);
SetIndexBuffer(2,FilterBuffer);
SetIndexBuffer(3,FilterBuffer2);
SetIndexLabel(0,"mirCD");
SetIndexLabel(1,"CDslope");
//----
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;
FilterBuffer3[i]=FilterBuffer[i]-FilterBuffer2[i];
FilterBuffer4[i]=FilterBuffer3[i]-FilterBuffer3[i+1];
i--;
}
return(0);
}
Comments