ADX and DI mt5
- Indicatori
- Ulises Calderon Bautista
- Versione: 1.0
### ADX and DI v1.00
Faithful MQL4/MQL5 port of BeikabuOyaji's "ADX and DI" indicator from TradingView, one of the most widely used ADX implementations on the platform with over 43,000 users. It displays +DI, −DI, and ADX in a single subwindow, using a hybrid smoothing approach — Wilder's method for the Directional Indexes and a simple moving average for the ADX line.
#### How it works
The indicator implements Welles Wilder's Directional Movement System with one notable variation in the final ADX calculation:
- **True Range, +DM, −DM** are calculated per Wilder's original definitions with mutual exclusivity between directional movements
- **Smoothing of TR, +DM, −DM** uses Wilder's running sum method: S(i) = S(i−1) − S(i−1)/N + value
- **+DI and −DI** are derived as the ratio of smoothed directional movement to smoothed True Range, expressed as percentages
- **DX** measures the normalized difference between +DI and −DI
- **ADX** is computed as a **simple moving average (SMA)** of DX over the selected period — not Wilder's SMMA as in the classical formulation
This SMA-based ADX responds faster to trend changes than the traditional Wilder/SMMA version, crossing threshold levels earlier in both directions.
#### Visual features
- **Green line**: +DI (bullish directional strength)
- **Red line**: −DI (bearish directional strength)
- **Navy line** (thicker): ADX (trend strength regardless of direction)
- **Horizontal level**: configurable threshold reference line (default 20)
#### Parameters
| Parameter | Default | Description |
|-----------|---------|-------------|
| Period | 14 | Smoothing period for Wilder's calculation and SMA window for ADX |
| Threshold | 20 | Horizontal reference level drawn on the indicator panel |
#### Key characteristics
- Produces values that differ from MetaTrader's built-in iADX (EMA-based) and iADXWilder (SMMA-based) due to the hybrid SMA approach
- Does not repaint: all values are fixed once the bar closes
- Available for both MetaTrader 4 and MetaTrader 5
- Works on all symbols and timeframes; best suited for H1, H4, and Daily charts
- Initialization starts from zero (replicating Pine Script's nz() behavior); values converge fully after approximately 100–150 bars
#### Original source
[ADX and DI]() by BeikabuOyaji — published February 16, 2015, updated to Pine Script v4 on January 28, 2021. Licensed under Mozilla Public License 2.0.
