Hello Amibroker Community,
Has anyone coded Ehlers DMH indicator that was recently discussed in the December 2021 Issue of Stocks & Commodities Magazine?
If so, would you please share it with the Community.
Thanks and I'd like to wish our Community a Happy Thanksgiving!
Bernard Rosario
1 Like
Try
_SECTION_BEGIN("DMH");
len = Param("length", 10, 2, 100, 2);
width = Param("width", 2, 1, 10);
function Hann(Deriv, len) {
local Filt, coef, count, f;
Filt = 0;
coef = 0;
P = 2*3.14159216;
for(count = 1; count <= len; ++count) {
f = 1-cos(P*count/(len+1));
Filt = Filt + f*Ref(Deriv, -(count-1));
coef = coef + f;
}
if (coef != 0) Filt = Filt/coef; else Filt = 0;
return Filt;
}
function DMH(n) {
return Hann(EMA(PDI()-MDI(), n), n);
}
sig = DMH(len);
//
plotcolor = IIf(sig > 0, ColorRGB(255, 221, 0), ColorRGB(0, 85, 255));
areacolor = IIf(sig > 0, ColorRGB(128, 110, 0), ColorRGB(0, 42, 128));
Plot(sig, "DMH", plotcolor, styleLine, Null, Null, 0, 0, width);
Plot(sig, "", areacolor, styleArea);
PlotGrid(0, colorGrey50);
_SECTION_END();
5 Likes
fxshrat
#3
There isn't looping required.
_SECTION_BEGIN("DMH");
/// version1 https://forum.amibroker.com/t/ehlers-dmh-indicator/28639/2
/// version2 https://forum.amibroker.com/t/ehlers-dmh-indicator/28639/3
len = Param("length", 10, 2, 100, 2);
width = Param("width", 2, 1, 10);
function Hann(Deriv, len) {
local f,P;
P = 2*3.14159216;
f = cos(P*(BarIndex()+1)/(len+1));
return FIR(Deriv, 1-f, len);
}
function DMH(n) {
return Hann(EMA(PDI()-MDI(), n), n);
}
sig = DMH(len);
//
plotcolor = IIf(sig > 0, ColorRGB(255, 221, 0), ColorRGB(0, 85, 255));
areacolor = IIf(sig > 0, ColorRGB(128, 110, 0), ColorRGB(0, 42, 128));
Plot(sig, "DMH", plotcolor, styleLine, Null, Null, 0, 0, width);
Plot(sig, "", areacolor, styleArea);
PlotGrid(0, colorGrey50);
_SECTION_END();
12 Likes
system
Closed
#4
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.