This script manually calculates the Directional Movement Index (DMI) and the Average Directional Index (ADX) using Wilder’s smoothing technique. The DMI indicators are used to assess the strength and direction of a market trend. It includes three main lines: ADX (yellow), DI+ (green), and DI− (red). Traders use these indicators to determine whether a trend is strong and in which direction it is moving.
The process begins by defining the length parameter, which determines how many periods are considered in the calculation. It then calculates the True Range (TR), which is the greatest of three values: the difference between the current high and low, the difference between the current high and the previous close, and the difference between the current low and the previous close. This TR is used to compute the Average True Range (ATR), which smooths out price fluctuations to get a clearer picture of the market’s volatility. Next, the script calculates the +DM (positive directional movement) and -DM (negative directional movement) based on the changes in the highs and lows from one period to the next.
Finally, the script computes the DI+ and DI− values by dividing the smoothed +DM and -DM by the ATR and multiplying by 100 to express them as percentages. The DX value is calculated as the absolute difference between DI+ and DI−, normalized by the sum of both values. The ADX is then derived by smoothing the DX value over the specified length. The three indicators — ADX, DI+, and DI− — are plotted in the lower chart panel, providing traders with visual cues about the trend’s direction (DI+ and DI−) and strength (ADX).
Important Notice: The use of technical indicators like this one does not guarantee profitable results. This indicator should not be used as a standalone analysis tool. It is essential to combine it with other forms of analysis, such as fundamental analysis, risk management strategies, and awareness of current market conditions. Always conduct thorough research.
Note: The effectiveness of any technical indicator can vary based on market conditions and individual trading styles. It's crucial to test indicators thoroughly using historical data before applying them in live trading scenarios.
Disclaimer: Trading financial instruments involves substantial risk and may not be suitable for all investors. Past performance is not indicative of future results. This indicator is provided for informational and educational purposes only and should not be considered investment advice. Always conduct your own research before making any trading decisions.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
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.