Navigation:Home > Content >

T3_DeMarker_v1.mq4

Time: 2012-06-04 | Download file:T3_DeMarker_v1.mq4

//+------------------------------------------------------------------+
//|                                                       DeM T3.mq4 |
//|                                       Original Code by FX Sniper |
//|                                  Copyright © 2008, Forex-TSD.com |
//|                                              Written by Linuxser |
//|For more information read TASC January 1998                       |
//|Thanks to mladen to notify me about the error in orig algorithm   |
//|http://www.linuxser.com.ar/                                       |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 1
#property indicator_color1 Blue
#property indicator_level1 0.3
#property indicator_level2 0.7

//----
extern int DeM_Period = 14;
extern int Applied_Price  =  0; // 0: Close // 1: Open // 2: High // 3: Low // 4: Median (H+L/2) // 5: Typical (H+L+C/3) // 6: Weighted (H+L+C+C/4)
extern int T3_Period = 5;
extern double b = 0.618;
//----
double e1, e2, e3, e4, e5, e6;
double c1, c2, c3, c4;
double n, w1, w2, b2, b3;
double DeM[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators setting
    SetIndexBuffer(0, DeM);

//----
    SetIndexStyle(0, DRAW_LINE);

//----        
    IndicatorShortName("DeM T3(" + DeM_Period + ", " + T3_Period + ")");
    SetIndexLabel(0, "DeM T3");     
  
//---- variable reset
    b2 = b*b;
    b3 = b2*b;
    c1 = -b3;
    c2 = (3*(b2 + b3));
    c3 = -3*(2*b2 + b + b3);
    c4 = (1 + 3*b + b3 + 3*b2);
    n = T3_Period;
//----
    if(n < 1) 
        n = 1;    
    w1 = 2 / (n + 1);
    w2 = 1 - w1;    
//----
    return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars = IndicatorCounted();
//---- check for possible errors
   if(counted_bars < 0) 
       return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;
   limit = Bars - counted_bars;  
//---- indicator calculation
   for(int i = Bars - 1; i >= 0; i--)
     {   
       DeM[i] = iDeMarker(NULL, 0, DeM_Period,i);
       e1 = w1*DeM[i] + w2*e1;
       e2 = w1*e1 + w2*e2;
       e3 = w1*e2 + w2*e3;
       e4 = w1*e3 + w2*e4;
       e5 = w1*e4 + w2*e5;
       e6 = w1*e5 + w2*e6;    
       DeM[i] = c1*e6 + c2*e5 + c3*e4 + c4*e3; 
       
     }   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend