PineCodersTASC

TASC 2021.11 MADH Moving Average Difference, Hann

█ OVERVIEW

Presented here is code for the "Moving Average Difference, Hann" indicator originally conceived by John ​Ehlers. The code is also published in the November 2021 issue of Trader's Tips by Technical Analysis of Stocks & ​Commodities (TASC) magazine.


█ CONCEPTS

By employing a Hann windowed finite impulse response filter (FIR), John ​Ehlers has enhanced the Moving Average Difference (MAD) to provide an oscillator with exceptional smoothness.

​Of notable mention, the wave form of MADH resembles ​Ehlers' "Reverse EMA" Indicator, formerly revealed in the September 2017 issue of TASC. Many variations of the "Reverse EMA" were published in TradingView's Public Library.


█ FEATURES

Three values in the script's "Settings/Inputs" provide control over the oscillators behavior:
 • The price source
 • A "Short Length" with a default of 8, to manage the lower band edge of the oscillator
 • The "Dominant Cycle", originally set at 27, which appears to be a placeholder for an adaptive control mechanism

Two coloring options are provided for the line's fill:
 • "ZeroCross", the default, uses the line's position above/below the zero level. This is the mode used in the top version of MADH on this chart.
 • "Momentum" uses the line's up/down state, as shown in the bottom version of the indicator on the chart.


█ NOTES

Calculations
The source price is used in two independent Hann windowed FIR filters having two different periods (lengths) of historical observation for calculation, one being a "Short Length" and the other termed "Dominant Cycle". These are then passed to a "rate of change" calculation and then returned by the reusable function. The secret ​sauce is that a "windowed Hann FIR filter" is superior tp a generic SMA filter, and that ultimately reveals Ehlers' clever enhancement. We'll have to wait and see what ingenuities ​Ehlers has next to unleash. Stay tuned...

The `madh()` function code was optimized for computational efficiency in Pine, differing visibly from ​Ehlers' original formula, but yielding the same results as ​Ehlers' version.

Background
This indicator has a sibling indicator discussed in the "The MAD Indicator, Enhanced" article by ​Ehlers. MADH is an evolutionary update from the prior MAD indicator code published in the October 2021 issue of TASC.

Sibling Indicators
 • Moving Average Difference (MAD)
 • Cycle/Trend Analytics

Related Information
 • Cycle/Trend Analytics And The MAD Indicator
 • The Reverse ​EMA Indicator
 • Hann Window
 • ROC

Join TradingView!

Tools and ideas for all Pine coders: www.tradingview.com/u/PineCoders/
Pine news broadcasts: t.me/PineCodersSquawkBox or twitter.com/PineCoders
TASC: traders.com/
Skrypt open-source

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz użyć tego skryptu na wykresie?