Hull Moving Average - page 6

 

Hull ribbon with alert

--

 

LOVE IT - the new design

--

 
while waiting ... This is the code of the above indicator. Some light in the afternoon
//------------------------------------------------------------------

#property copyright "www.forex-tsd.com"

#property link "www.forex-tsd.com"

//------------------------------------------------------------------

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 LightGreen

#property indicator_color2 Bisque

#property indicator_color3 DarkGray

#property indicator_color4 DarkGray

#property indicator_width1 4

#property indicator_width2 4

#property indicator_width3 2

#property indicator_width4 2

//

//

//

//

//

extern int HMA1Period=10;

extern int HMA1Price =PRICE_CLOSE;

extern int HMA2Period=50;

extern int HMA2Price =PRICE_CLOSE;

//

//

//

//

//

double buffer1[];

double buffer2[];

double buffer3[];

double buffer4[];

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int init()

{

SetIndexBuffer(0,buffer3); SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexBuffer(1,buffer4); SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexBuffer(2,buffer1);

SetIndexBuffer(3,buffer2);

return(0);

}

int deinit()

{

return(0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int start()

{

int counted_bars=IndicatorCounted();

int limit,i;

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

//

//

//

//

//

for(i=limit; i>=0; i--)

{

buffer1 = iHull(iMA(NULL,0,1,0,MODE_SMA,HMA1Price,i),HMA1Period,i,0);

buffer2 = iHull(iMA(NULL,0,1,0,MODE_SMA,HMA2Price,i),HMA2Period,i,0);

buffer3 = buffer1;

buffer4 = buffer2;

}

return(0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

double workHull[][4];

double iHull(double price, double period, int r, int instanceNo=0)

{

if (ArrayRange(workHull,0)!= Bars) ArrayResize(workHull,Bars); r=Bars-r-1;

//

//

//

//

//

int HmaPeriod = MathMax(period,2);

int HalfPeriod = MathFloor(HmaPeriod/2);

int HullPeriod = MathFloor(MathSqrt(HmaPeriod));

double hma,hmw,weight; instanceNo *= 2;

workHull[r] = price;

//

//

//

//

//

hmw = HalfPeriod; hma = hmw*price;

for(int k=1; k=0; k++)

{

weight = HalfPeriod-k;

hmw += weight;

hma += weight*workHull[r-k];

}

workHull[r] = 2.0*hma/hmw;

hmw = HmaPeriod; hma = hmw*price;

for(k=1; k=0; k++)

{

weight = HmaPeriod-k;

hmw += weight;

hma += weight*workHull[r-k];

}

workHull[r] -= hma/hmw;

//

//

//

//

//

hmw = HullPeriod; hma = hmw*workHull[r];

for(k=1; k=0; k++)

{

weight = HullPeriod-k;

hmw += weight;

hma += weight*workHull[r-k][1+instanceNo];

}

return(hma/hmw);

}
 

PS: images in posts are cut as a consequence of a new look and feel and will be corrected along with other changes

 

...

The hull ribbon ...

Files:
hullribbon.gif  73 kb
 

Hull candles ...

Here you go If you wish just bars, set the widths for color 3 and 4 to 1, and then it will draw bars instead of candles

skn:
Beautiful indicator, Mladen.

What about Hull candles?

Regards.
Files:
 

Thanks for Hull Ribbon

Mladen,

Thanks for Hull Ribbon.

Regards

 

...

No alerts yet in it, that will be added later ...

skn:
Mladen,

Thanks for Hull Ribbon.

Regards
 

Thanks

Thanks for the complete indicator with alerts.

 
mladen:
This one is a version for metatrader 5 with a twist in it ...


It can adapt its style depending on the chart style. If the "Style" parameter is set to "automatically adjust style" it will detect the chart style and then it will adjust the display style of the indicator accordingly. That way you can get the following display (all 3 are the same indicator and the only thing that is done is that the chart type was change - none of the parameters in indicator was changed)

Hi mladen,

i have seen a few charts from you where there is a big candle ( i presume the daily) beside the current price

. is that a separate indicator? what is its name? thanks

Reason: