OPEN-SOURCE SCRIPT
Hull DMI - Mattes

Hull DMI - Mattes
A Directional Movement Index enhanced with Hull Moving Average smoothing for refined trend detection.
Key Features:
How It Differs from Standard DMI/ADX:
Unlike the traditional DMI, which uses raw price changes and true range, this version employs Hull Moving Averages on highs and lows for smoother, more responsive directional calculations. This minimizes whipsaws in choppy markets while preserving sensitivity to genuine trends. The ADX is integrated to filter signals, ensuring color changes and alerts only occur during strengthening trends, setting it apart from basic oscillator-based indicators.Why It's Useful:
This Hull DMI variant offers several practical advantages that can directly improve trading decisions and performance:
Signals & Interpretation
Pine Script®
Great Inventions Require great care
Disclaimer: This indicator is provided for educational and informational purposes only and should not be considered as financial advice. Past performance is not indicative of future results. Always backtest thoroughly on your specific assets and timeframes, and consult a qualified financial advisor before making trading decisions. The author assumes no responsibility for any losses incurred from its use.
A Directional Movement Index enhanced with Hull Moving Average smoothing for refined trend detection.
This indicator reimagines the classic Directional Movement Index (DMI) by incorporating Hull Moving Average (HMA) smoothing on high and low prices. It calculates the +DI and -DI components based on changes in these hulled values, then derives the ADX for trend strength. The core plot displays the difference between +DI and -DI, colored to indicate bullish (blue) or bearish (purple) dominance when ADX is rising. Additionally, it overlays colored candles on the price chart to visually represent the prevailing trend direction.
Key Features:
- Hull-Smoothed Inputs: Applies HMA to highs and lows before computing directional changes, reducing noise and lag compared to standard DMI.
- Customizable Lengths: Adjustable periods for HMA, DI, and ADX smoothing to suit various timeframes and assets.
- Trend Visualization: Plots DI difference with dynamic coloring and overlays trend-colored candles for at-a-glance analysis.
- Alert Conditions: Built-in alerts for long (bullish) and short (bearish) signals when conditions shift.
How It Differs from Standard DMI/ADX:
Unlike the traditional DMI, which uses raw price changes and true range, this version employs Hull Moving Averages on highs and lows for smoother, more responsive directional calculations. This minimizes whipsaws in choppy markets while preserving sensitivity to genuine trends. The ADX is integrated to filter signals, ensuring color changes and alerts only occur during strengthening trends, setting it apart from basic oscillator-based indicators.Why It's Useful:
- Enhanced Trend Identification: The HMA smoothing provides clearer signals in volatile environments, helping traders spot emerging trends earlier.
- Visual Clarity: Colored DI plot and candle overlays make it easy to interpret market bias without cluttering the chart.
- Versatility: Suitable for stocks, forex, crypto, and more; excels in trend-following strategies or as a filter for other systems.
- Risk Management Aid: By focusing on ADX-confirmed moves, it reduces false signals, potentially improving win rates in systematic trading.
This Hull DMI variant offers several practical advantages that can directly improve trading decisions and performance:
- Reduced Lag with Smoother Signals: By applying Hull Moving Average smoothing to highs and lows, the indicator responds faster to genuine trend changes than the standard DMI while filtering out much of the noise that causes false signals in ranging or choppy markets. Traders get earlier entries into trending moves without excessive whipsaws.
- Built-in Trend Strength Filter: The optional ADX confirmation (enabled by default) ensures bullish signals and blue coloring only activate when trend strength is increasing (ADX rising). This helps traders avoid entering long positions during weakening or sideways trends, focusing capital on higher-probability setups.
- Clear Visual Bias at a Glance: The single oscillator line (+DI – -DI) centered on zero, combined with dynamic blue/purple coloring and full candle overlay on the price chart, instantly shows the dominant trend direction. No need to interpret multiple lines—traders can quickly assess market bias across multiple charts or timeframes.
- Versatile Across Markets and Styles: Works effectively on stocks, forex, futures, and cryptocurrencies. Trend-following traders can use it standalone for entries/exits, swing traders can use it for bias confirmation, and scalpers/day traders benefit on lower timeframes due to the reduced lag.
- Improved Risk Management: By prioritizing ADX-confirmed directional moves, the indicator naturally filters low-conviction setups. This can lead to higher win rates and better risk-reward ratios when used systematically, especially when combined with proper stop-loss placement below/above recent swings.
- Easy Integration: Built-in alert conditions and simple long/short logic make it straightforward to incorporate into automated strategies, watchlists, or as a confirming filter alongside other indicators (e.g., moving averages, RSI, volume profile).
- Customizable Sensitivity: Separate inputs for Hull length, DI period, and ADX smoothing allow traders to optimize the indicator for specific assets, volatility regimes, or personal trading horizons—making it adaptable rather than one-size-fits-all.
Signals & Interpretation
- The oscillator plots the difference between +DI and -DI (positive = bullish dominance, negative = bearish).
- Bullish Signal (Long): +DI crosses above -DI, and (if ADX confirmation enabled) ADX is rising — triggers blue coloring, candle overlay, and long alert.
- Bearish Signal (Short): -DI crosses above +DI — triggers purple coloring, candle overlay, and short alert.
- Zero line acts as neutrality; crossings indicate potential trend shifts.
- Best used in trending markets; ADX rising filter helps avoid whipsaws.
// Example Usage in Strategy
strategy("Hull DMI Strategy Example", overlay=true)
if L
strategy.entry("Long", strategy.long)
if S
strategy.entry("Short", strategy.short)
Great Inventions Require great care
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.