OPEN-SOURCE SCRIPT
DMI & ADX Enhanced Trend Dashboard (with Long/Short Status)

概述
本脚本在经典的 Wilder DMI(趋向指标)与 ADX(平均趋向指数)基础上,进行了实用性增强。它不仅在副图区清晰绘制了 +DI、-DI 与 ADX 三条曲线,还在图表右上角集成了一个智能状态看板(Dashboard),将枯燥的数值转化为 “做多 / 做空 / 不交易” 的直观文字信号,极大提升了复盘效率和实时盯盘的便捷性。
核心计算逻辑
严格遵循 Wilder 标准算法,使用 RMA(Wilder 移动平均)对真实波幅(TR)和方向运动(DM)进行平滑处理,确保指标反应的稳定性和经典性。+DI 与 -DI 分别代表多头与空头的力量方向,ADX 则量化了当前趋势的绝对强度(数值越高,趋势越强)。
智能看板(Dashboard)信号规则
1. 趋势过滤:当 ADX > 设定阈值(默认 20)时,认定市场存在明显趋势,进入交易逻辑判断。
2. 多空判定:若 +DI > -DI 且 ADX 大于阈值,看板显示“做多”(绿色背景)。若 -DI > +DI 且 ADX 大于阈值,看板显示“做空”(红色背景)。
3. 观望警示:当 ADX 低于阈值时,视为市场处于震荡或无趋势状态,看板显示“不交易(趋势偏弱)”(灰色背景),建议投资者空仓观望,规避频繁止损。
参数自定义建议
ADX 平滑长度(默认 14):控制 ADX 线的平滑度,数值越大曲线越平缓。
DI 周期长度(默认 14):影响 +/-DI 对价格变化的敏感度。
趋势阈值(默认 20):核心风控参数。对于波动较大的品种(如加密货币),建议调高至 25;对于股票或外汇,保持 20 即可。
适用场景
本指标非常适合中长线趋势跟踪策略,能有效帮助交易者过滤掉震荡行情的噪音,只在趋势明确时提供方向性参考。请注意,本工具为分析型指标,不包含未来函数,信号稳定。
Overview
This script enhances the classic Wilder DMI (Directional Movement Indicator) and ADX (Average Directional Index) with practical improvements. It not only clearly plots the +DI, -DI, and ADX curves in the indicator pane, but also integrates a smart dashboard in the top-right corner of the chart. This dashboard translates the raw numerical values into intuitive textual signals — "Long", "Short", or "No Trade" — greatly improving the efficiency of both backtesting analysis and real-time monitoring.
Core Calculation Logic
The script strictly follows Wilder's standard algorithm, using RMA (Wilder's Moving Average) to smooth True Range (TR) and Directional Movement (DM), ensuring stable and classic indicator responses. +DI and -DI represent the directional strength of bulls and bears respectively, while ADX quantifies the absolute strength of the current trend — the higher the value, the stronger the trend.
Smart Dashboard Signal Rules
1. Trend Filter: When ADX > the set threshold (default 20), the market is considered to have a clear trend, and the trading logic is activated.
2. Long/Short Determination: If +DI > -DI and ADX is above the threshold, the dashboard displays "Long" (with a green background). If -DI > +DI and ADX is above the threshold, the dashboard displays "Short" (with a red background).
3. Caution/Wait Signal: When ADX is below the threshold, the market is considered range-bound or trendless. The dashboard displays "No Trade (Weak Trend)" (with a gray background), suggesting that traders should stay on the sidelines to avoid frequent stop-losses.
Parameter Customization Suggestions
ADX Smoothing Length (default 14): Controls the smoothness of the ADX line. Higher values result in a smoother, less reactive curve.
DI Period Length (default 14): Affects the sensitivity of +DI and -DI to price changes.
Trend Threshold (default 20): A critical risk management parameter. For more volatile instruments (e.g., cryptocurrencies), consider raising it to 25. For stocks or forex, keeping it at 20 is generally suitable.
Application Scenarios
This indicator is ideally suited for medium-to-long-term trend-following strategies. It effectively helps traders filter out noise during choppy, sideways markets, providing directional references only when a clear trend is present. Please note that this is an analytical tool with no built-in future functions, ensuring stable and reliable signals.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.