OPEN-SOURCE SCRIPT
ZenAlgo - ADX

This open-source indicator builds upon the official Average Directional Index (ADX) implementation by TradingView. It preserves the core logic of the original ADX while introducing additional visualization features, configurability, and analytical overlays to assist with directional strength analysis.
Core Calculation
The script computes the ADX, +DI, and -DI based on smoothed directional movement and true range over a user-defined length. The smoothing is performed using Wilder’s method, as in the original implementation.
The indicator includes a selectable signal line (SMA or EMA) applied to the ADX for crossover-based visualization.
Visualization Enhancements
Several plots and conditions have been added to improve interpretability:
The script also provides small circles and diamonds to highlight:
Divergence Detection
The indicator includes optional detection of fractal-based divergences on the DI curve:
Fractal points are defined using 5-bar patterns to ensure consistency and reduce false positives.
ADX/DI Table
When enabled, a floating table displays live values and summaries:
The background colors of the table reflect current trend strength and direction.
Interpretation Guidelines
The threshold line (default 25) provides a basic filter for ignoring low-strength conditions. This can be adjusted depending on the market or timeframe.
Added Value over Existing Indicators
These additions aim to improve situational awareness without altering the fundamental meaning of ADX/DI values.
Limitations and Disclaimers
Core Calculation
The script computes the ADX, +DI, and -DI based on smoothed directional movement and true range over a user-defined length. The smoothing is performed using Wilder’s method, as in the original implementation.
- True Range is calculated from the current high, low, and previous close.
- Directional Movement components (+DM, -DM) are derived by comparing the change in highs and lows between consecutive bars.
- These values are then smoothed, and the +DI and -DI are expressed as percentages of the smoothed True Range.
- The difference between +DI and -DI is normalized to derive DX, which is further smoothed to yield the ADX value.
The indicator includes a selectable signal line (SMA or EMA) applied to the ADX for crossover-based visualization.
Visualization Enhancements
Several plots and conditions have been added to improve interpretability:
- Color-coded histograms and lines visualize DI relative to a configurable threshold (default: 25). Colors follow the ZenAlgo color scheme.
- Dynamic opacity and gradient coloring are used for both ADX and DI components, allowing users to distinguish weak/moderate/strong directional trends visually.
- Mirrored ADX is internally calculated for certain overlays but not directly plotted.
The script also provides small circles and diamonds to highlight:
- Crossovers between ADX and its signal line.
- DI crossing above or below the 25 threshold.
- Rising ADX confirmed by rising DI values, with point size reflecting ADX strength.
Divergence Detection
The indicator includes optional detection of fractal-based divergences on the DI curve:
- Regular and hidden bullish and bearish divergences are identified based on relative fractal highs/lows in both price and DI.
- Detected divergences are optionally labeled with 'R' (Regular) or 'H' (Hidden), and color-coded accordingly.
Fractal points are defined using 5-bar patterns to ensure consistency and reduce false positives.
ADX/DI Table
When enabled, a floating table displays live values and summaries:
- ADX value, trend direction (rising/falling), and qualitative strength.
- DI composite, trend direction, and relative strength.
- Contextual power dynamics, describing whether bulls or bears are gaining or losing strength.
The background colors of the table reflect current trend strength and direction.
Interpretation Guidelines
- ADX indicates the strength of a trend, regardless of its direction. Values below 20 are often considered weak, while those above 40 suggest strong trending conditions.
- +DI and -DI represent bullish and bearish directional movements, respectively. Crossovers between them are used to infer trend direction.
- When ADX is rising and either +DI or -DI is dominant and increasing, the trend is likely strengthening.
- Divergences between DI and price may suggest potential reversals but should be interpreted cautiously and not in isolation.
The threshold line (default 25) provides a basic filter for ignoring low-strength conditions. This can be adjusted depending on the market or timeframe.
Added Value over Existing Indicators
- Fully color-graded ADX and DI display for better visual clarity.
- Optional signal MA over ADX with crossover markers.
- Rich contextual labeling for both divergence and threshold events.
- Power dynamics commentary and live table help users contextualize current momentum.
- Customizable options for smoothing type, divergence display, table position, and visual offsets.
These additions aim to improve situational awareness without altering the fundamental meaning of ADX/DI values.
Limitations and Disclaimers
- As with any ADX-based tool, this indicator does not indicate market direction alone—it measures strength, not trend bias.
- Divergence detection relies on fractal patterns and may lag or produce false positives in sideways markets.
- Signal MA crossovers and DI threshold breaks are not entry signals, but contextual markers that may assist with timing or filtering other systems.
- The table text and labels are for visual assistance and do not replace proper technical analysis or market context.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
The ZenAlgo team
zenalgo.io
discord.zenalgo.io
zenalgo.io
discord.zenalgo.io
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
The ZenAlgo team
zenalgo.io
discord.zenalgo.io
zenalgo.io
discord.zenalgo.io
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.