Kaufman Adaptive Moving Average - KAMA

//+------------------------------------------------------------------+
//|                                                         KAMA.mq4 |
//|                                    Copyright? 2009, Walter Choy. |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright? 2009, Walter Choy."
#property link      ""


#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
//---- input parameters
extern int       kama_period = 10;
extern double    fast_ma_period = 2.0;
extern double    slow_ma_period = 30.0;
//---- buffers
double KAMA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,KAMA);
   SetIndexLabel(0, "KAMA");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   int i = Bars - counted_bars;
   
   double fastest = 2 / (fast_ma_period + 1);
   double slowest = 2 / (slow_ma_period + 1);
   
   while(i>0){
      double er = 1;
      double signal = MathAbs(Close[i] - Close[i+kama_period]);
      double noise = 0;
      for (int j=0; j<kama_period; j++)
         noise += MathAbs(Close[i+j] - Close[i+j+1]);
      if (noise > 0)
         er = signal / noise;
      double sc = MathPow((er * (fastest - slowest) + slowest), 2);
      KAMA[i] = KAMA[i+1] + sc * (Close[i] - KAMA[i+1]);
      i--;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+




Hi could you pls show us how to code and implement this type of indicator?

Attachments
No attachments
  • Votes +1
  • Project Extending SQ
  • Type Bug
  • Status Fixed
  • Priority Normal

History

IH
#1

clonex / Ivan Hudec

13.01.2019 20:15

Task created

g
#2

geektrader

13.01.2019 21:14
This really is a bug tracker and you should post that stuff rather in the Forum so that others can help. The developers should focus on the bugs first instead of adding new indicators. Apart from this, there also is a pretty good PDF explaining that in your SQX root directory. The file is called "Extending_SQX.pdf" and shows exactly how do to that.
IH
#3

clonex / Ivan Hudec

14.01.2019 08:16
Voted for this task.
IH
#4

clonex / Ivan Hudec

14.01.2019 08:34
1. Read properly several times strategyquant site here or here or Extending_SQX.pdf page 23 and page 40 and you will find what this SQ PROGRAMMING is dedicated for.

2. Geektrader. Are u developer, a manager from SQ? Yes? NO.  Then please Geektrader keep this ( diplomatically saying  ) paternalistic "wannabe" guidance ( " The developers should focus on the bugs first instead of adding new indicators." ) for somebody other. 


IH
#5

clonex / Ivan Hudec

14.01.2019 08:58
Btw i think that i already finish this in the end. So ill post this indicator to the forum and to the https://strategyquant.com/codebase ;) .


TB
#6

Tomas Brynda

26.03.2020 10:31

Status changed from New to Fixed

Hi Clonex,

thank you for sharing your indicator.


If you need any assistance in the future, please let me know.


Best regards,

Tomas


Votes: +1

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please