John Ehlers DMH – AN IMPROVED DIRECTIONAL MOVEMENT INDICATOR

Category: Indicators By: Bruno Carnazzi Created: January 14, 2022, 10:15 AM
January 14, 2022, 10:15 AM
Indicators
0 Comments

Presented here is code for the “Directional Movement w/Hann” indicator originally conceived by John ​Ehlers. The code is also published in the December 2021 issue of Trader’s Tips by Technical Analysis of Stocks & ​Commodities (TASC) magazine.

Ehlers continues here his exploration of the application of Hann windowing to conventional trading indicators.

 

// DMH - Directional Movement using Hann Windowing
// (C) 2021 John F. Ehlers

// Parameters
Length: 14

// Vars
once DMH = 0
once EMA = 0

once SF = 1 / Length

if barindex > Length then
UpperMove = High - High[1]
LowerMove = Low[1] - Low

PlusDM = 0
MinusDM = 0
If UpperMove > LowerMove and UpperMove > 0 Then
PlusDM = UpperMove
ElsIf LowerMove > UpperMove and LowerMove > 0 Then
MinusDM = LowerMove
endif

EMA = SF*(PlusDM - MinusDM) + (1 - SF)* EMA[1]

//Smooth Directional Movements with Hann Windowed FIR filter
DMSum = 0
coef = 0
For count = 1 to Length do
DMSum = DMSum + (1 - cos(360*count / (Length + 1)))*EMA[count - 1]
coef = coef + (1 - cos(360*count / (Length + 1)))
next

If coef <> 0 Then
DMH = DMSum / coef
endif
endif

return DMH as "DMH", 0 as "0"

 

Download
Filename: DMH-DirectionalMovement-Hann.itf
Downloads: 246
Bruno Carnazzi Senior
https://market.prorealcode.com/store/digital-filters-workshop/
Author’s Profile

Comments

Logo Logo
Loading...