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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
// 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" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials