The Digital PCCI Filter is a specialized technical analysis tool designed to smooth out market noise and provide a clearer picture of price movement. Instead of simply looking at the current price, this script employs a mathematical approach to "filter" out erratic fluctuations, helping traders identify more stable trends.
How it Works
The logic behind this filter operates by calculating a weighted average of recent historical data. Here is a breakdown of the process:
- Data Sampling: The script looks back at a specific window of 20 previous price points. It specifically focuses on the "midpoint" of each price bar (the average between the highest and lowest prices reached during that period).
- Weighting System: Not all past prices are treated equally. The logic applies a specific mathematical weight to each of these 20 points. The weights are distributed in a way that allows the filter to react dynamically to the price action, balancing the influence of older data against more recent movements.
- The "Response" Calculation: By multiplying each midpoint by its assigned weight and adding them together, the script generates a "response" value. This represents what the price should look like if all the temporary noise and spikes were removed.
- Final Output: To determine the final line you see on your chart, the script takes the current midpoint and subtracts this calculated "response."
Purpose for the Trader
The goal of this logic is to create a visual representation of price momentum that is less distracted by "市場雜訊" (market noise). By subtracting the weighted response from the current price, the tool highlights the underlying trend. This helps in identifying whether the current price movement is a significant shift in direction or simply a temporary fluctuation, allowing for potentially cleaner entry and exit signals.
//+------------------------------------------------------------------+
//| Digital PCCI Filter |
//| Copyright (c) Sergey Iljukhin, Novosibirsk. |
//| email sergey[at]tibet.ru http://fx.qrz.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright (c) 2005, Sergey Iljukhin, Novosibirsk"
#property link "http://fx.qrz.ru/"
// --- Parameters: P1=50, D1=14, A1=3
// --- P2=54, D2=51, A2=50, Ripple=0.08, Delay=11
// --- Order [Auto]=20, Calculate method=2
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- buffers
double FilterBuffer[];
//+------------------------------------------------------------------+
//| Digital filter indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,FilterBuffer);
SetIndexDrawBegin(0,20);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Digital filter main function |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
double response;
//----
if(Bars<=20) return(0);
//---- initial zero
if(counted_bars<20)
for(i=1;i<=0;i++) FilterBuffer[Bars-i]=0.0;
//----
i=Bars-20-1;
if(counted_bars>=20) i=Bars-counted_bars-1;
while(i>=0)
{
response=
// 0*((High[i+0]+Low[i+0])/2)
// 0*((High[i+1]+Low[i+1])/2)
+0.0328596706665*((High[i+2]+Low[i+2])/2)
+0.02766391536906*((High[i+3]+Low[i+3])/2)
+0.0372462661561*((High[i+4]+Low[i+4])/2)
+0.0471931369620*((High[i+5]+Low[i+5])/2)
+0.0569044599702*((High[i+6]+Low[i+6])/2)
+0.0657924462253*((High[i+7]+Low[i+7])/2)
+0.0730704081225*((High[i+8]+Low[i+8])/2)
+0.0782920581838*((High[i+9]+Low[i+9])/2)
+0.0809776383446*((High[i+10]+Low[i+10])/2)
+0.0809776383446*((High[i+11]+Low[i+11])/2)
+0.0782920581838*((High[i+12]+Low[i+12])/2)
+0.0730704081225*((High[i+13]+Low[i+13])/2)
+0.0657924462253*((High[i+14]+Low[i+14])/2)
+0.0569044599702*((High[i+15]+Low[i+15])/2)
+0.0471931369620*((High[i+16]+Low[i+16])/2)
+0.0372462661561*((High[i+17]+Low[i+17])/2)
+0.02766391536906*((High[i+18]+Low[i+18])/2)
+0.0328596706665*((High[i+19]+Low[i+19])/2);
FilterBuffer[i]=(High[i]+Low[i])/2-response;
i--;
}
return(0);
}
Comments