MACD_HULL







#property indicator_separate_window 
#property indicator_buffers 3
#property indicator_color2 Red
#property indicator_color1 Blue
#property indicator_color3 Green

//---- input parameters 
extern int       period=100; 
extern int       method=3;                         // MODE_SMA 
extern int       price=0;                          // PRICE_CLOSE 


extern int       period2=300; 
extern int       method2=3;                         // MODE_SMA 
extern int       price2=0;                          // PRICE_CLOSE 


extern int       period3=50; 
extern int       method3=1;                         // MODE_SMA 
extern int       price3=0;                          // PRICE_CLOSE 

//---- buffers 
double FL[];
double FS[];
double OSMA[];
double ExtMapBuffer[]; 
double ExtMapBuffer2[]; 


//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
{ 
    IndicatorBuffers(5);  
    
   
    SetIndexBuffer(0, FL);
    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
    
    SetIndexBuffer(1, FS);
    SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
    
    SetIndexBuffer(2, OSMA);
    SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1);
     
    SetIndexBuffer(3, ExtMapBuffer); 
    SetIndexBuffer(4, ExtMapBuffer2); 
    
    
    
    
    IndicatorShortName("Hull Moving Average("+period+","+period2+","+period3+")"); 
    return(0); 
} 


double WMA(int x, int p) 
{ 
    return(iMA(NULL, 0, p, 0, method, price, x));    
} 

double WMAd(int xd, int pd) 
{ 
    return(iMA(NULL, 0, pd, 0, method2, price2, xd));    
} 


//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int start() 
{ 
    int counted_bars = IndicatorCounted(); 
    
    if(counted_bars < 0) 
        return(-1); 
                  
    int x = 0; 
    int p = MathSqrt(period);              
    int e = Bars - counted_bars + period + 1; 
    
    double vect[]; 
    
    if(e > Bars) 
        e = Bars;    

    ArrayResize(vect, e); 
    ArraySetAsSeries(vect, true);
    
    
    for(x = 0; x < e; x++) 
    { 
        vect[x] = 2*WMA(x, period/2) - WMA(x, period);        
    } 

    for(x = 0; x < e-period; x++)
     {
        ExtMapBuffer[x] = iMAOnArray(vect, 0, p, 0, method, x);        
    }
    
    
    
        
        
    int xd = 0; 
    int pd = MathSqrt(period2);              
    int ed = Bars - counted_bars + period2 + 1; 
    
    double vectd[]; 
    
    if(ed > Bars) 
        ed = Bars;    

    ArrayResize(vectd, ed); 
    ArraySetAsSeries(vectd, true);
    
    
    for(xd = 0; xd < ed; xd++) 
    { 
        vectd[xd] = 2*WMAd(xd, period2/2) - WMAd(xd, period2);        
    } 

    for(xd = 0; xd < ed-period2; xd++)
     {
        ExtMapBuffer2[xd] = iMAOnArray(vectd, 0, pd, 0, method2, xd);  
    }
    
    
    
    int limit;
   
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   for(int i=0; i<limit; i++)
      {
        FL[i] = ExtMapBuffer[i]-ExtMapBuffer2[i]; 
        
                
    }
    
   for(int b=0; b<limit; b++)
      {
          FS[b] = iMAOnArray(FL, 0, period3, 0, method3, b);  
           
    }
   for(int c=0; c<limit; c++)
      {
          OSMA[c] =FL[c]-FS[c];  
           
    } 
    return(0); 
} 
//+------------------------------------------------------------------+ 



Sample





Analysis



Market Information Used:



Indicator Curves created:


Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_HISTOGRAM

Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: