Author: Copyright � 2004, by konKop,wellx
Kaufman_v3

This script is designed as a technical analysis tool that helps traders filter out market "noise" to identify smoother, more reliable price trends. It utilizes a sophisticated mathematical approach known as the Kaufman Adaptive Moving Average (KAMA) logic to determine whether the current market movement is a significant trend or just random fluctuation.

Core Logic and Functionality

1. Market Efficiency Calculation The primary intelligence of this script lies in its ability to measure "noise." It compares the actual price change over a specific period against the sum of all individual price movements within that same timeframe.

  • If the price is moving in a straight, consistent direction, the "Efficiency Ratio" is high.
  • If the price is zigzagging and volatile without making much progress, the "Efficiency Ratio" is low.

2. Adaptive Smoothing Unlike standard moving averages that treat all price data equally, this script adjusts its sensitivity based on the market conditions identified above:

  • In Trending Markets: When the market shows high efficiency (clear direction), the script reacts more quickly to price changes so you can follow the trend closely.
  • In Choppy Markets: When the market is highly volatile or "noisy," the script automatically slows down and smooths out the data to prevent false signals caused by minor price fluctuations.

3. Visual Indicators and Signals The script provides three distinct visual components on your chart:

  • The Main Trend Line: A primary line that represents the smoothed average of the price, helping you see the "true" direction of the market.
  • Buy Signals (Upward Arrows): The script identifies specific moments where the trend moves upward with enough momentum to cross a pre-defined threshold. These appear as visual markers indicating potential bullish strength.
  • Sell Signals (Downward Arrows): Conversely, when the trend moves downward with significant momentum, the script marks these points with visual indicators to highlight potential bearish strength.

How It Works for the User

By combining these elements, the tool aims to provide a clearer picture of market dynamics. Instead of getting distracted by every minor tick in price, the script filters the data to show you where the "heavy" movement is happening, highlighting clear entries while ignoring the distractions of a sideways or erratic market.

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
Kaufman_v3
//+------------------------------------------------------------------+
//|                                                      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