Kaufman_v1
Download scriptThis tool is designed to help traders identify the underlying direction of the market by filtering out "market noise"—those small, erratic price fluctuations that can often mislead short-term analysis. It functions by creating a smoothed trend line and identifying specific moments where the price momentum shifts significantly enough to be considered a meaningful move.
Core Logic & Methodology
The script operates based on a sophisticated smoothing process that adapts to the current market conditions. Here is how it processes data:
1. Noise vs. Signal Analysis Instead of simply averaging prices (like a standard moving average), this logic compares the "signal" (the overall distance the price has moved over a specific period) against the "noise" (the sum of all tiny individual price changes within that same period). By dividing the signal by the noise, the tool calculates an Efficiency Ratio. This allows it to determine if a move is a steady, purposeful trend or just random volatility.
2. Dynamic Smoothing The tool uses this Efficiency Ratio to adjust how quickly it reacts to new price data.
- In a trending market, where the efficiency is high, the smoothed line stays closer to the actual price to capture the move quickly.
- In a choppy or sideways market, where the noise is high relative to the movement, the logic automatically slows down its reaction, preventing the indicator from reacting to "fake-out" movements.
3. Visual Outputs The script provides three distinct visual elements on your chart:
- The Trend Line: A primary smoothed line that represents the "true" direction of the price action, stripped of minor fluctuations.
- Upward Signals: The tool monitors the gap between the current trend value and the previous value. If the price moves upward by a specific user-defined threshold (the sensitivity level), it marks a potential buying signal with an arrow.
- Downward Signals: Conversely, if the trend value drops by that same threshold, it marks a potential selling signal with an arrow.
Summary for the User
Essentially, this script acts as a "smart filter." It ignores the "jitter" of the market to show you the real flow of price. By using the Efficiency Ratio, it tries to stay on top of fast-moving trends while remaining stable during quiet periods, highlighting clear entries when the momentum surpasses your chosen sensitivity limits.
//+------------------------------------------------------------------+
//| Kaufman.mq4 |
//| Copyright © -2005, by konKop & wellx |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, by konKop,wellx"
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Sienna
#property indicator_color2 DeepSkyBlue
#property indicator_color3 Gold
//---- input parameters
extern int periodAMA=9;
extern int nfast=2;
extern int nslow=30;
extern double G=2.0;
extern double dK=2.0;
//---- buffers
double kAMAbuffer[];
double kAMAupsig[];
double kAMAdownsig[];
//+------------------------------------------------------------------+
int k=0, cbars=0, prevbars=0, prevtime=0;
double slowSC,fastSC;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,159);
SetIndexStyle(2,DRAW_ARROW);
SetIndexArrow(2,159);
//SetIndexDrawBegin(0,nslow+nfast);
SetIndexBuffer(0,kAMAbuffer);
SetIndexBuffer(1,kAMAupsig);
SetIndexBuffer(2,kAMAdownsig);
IndicatorDigits(4);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i,pos=0;
double noise=0.000000001,AMA,AMA0,signal,ER;
double dSC,ERSC,SSC,ddK;
if (prevbars==Bars) return(0);
//---- TODO: add your code here
slowSC=(2.0 /(nslow+1));
fastSC=(2.0 /(nfast+1));
cbars=IndicatorCounted();
if (Bars<=(periodAMA+2)) return(0);
//---- check for possible errors
if (cbars<0) return(-1);
//---- last counted bar will be recounted
if (cbars>0) cbars--;
pos=Bars-periodAMA-2;
AMA0=Close[pos+1];
while (pos>=0)
{
kAMAupsig[pos] =NULL;
kAMAdownsig[pos]=NULL;
if(pos==Bars-periodAMA-2) AMA0=Close[pos+1];
signal=MathAbs(Close[pos]-Close[pos+periodAMA]);
noise=0.000000001;
for(i=0;i<periodAMA;i++)
{
noise=noise+MathAbs(Close[pos+i]-Close[pos+i+1]);
}
ER =signal/noise;
dSC=(fastSC-slowSC);
ERSC=ER*dSC;
SSC=ERSC+slowSC;
AMA=AMA0+(MathPow(SSC,G)*(Close[pos]-AMA0));
kAMAbuffer[pos]=AMA;
ddK=(AMA-AMA0);
if ((MathAbs(ddK) > (dK*Point)) && (ddK > 0)) kAMAupsig[pos] =AMA;
if ((MathAbs(ddK)) > (dK*Point) && (ddK < 0)) kAMAdownsig[pos]=AMA;
AMA0=AMA;
pos--;
}
//----
prevbars=Bars;
return(0);
}
Comments