Description of the indicator.
The Average Directional Index (ADX) is a technical analysis indicator developed by J. Welles Wilder in 1978. Its main function is to measure the strength of a trend, regardless of its direction. It is also mentioned by John Murphy in The Visual Investor (2005) as an indicator that helps to determine whether a market is consolidating or about to start a new trend.
Regarding Exponential Moving Averages (EMAs), some authors believe that their introduction to the study of time series first occurred as a data smoothing technique for statistical models.
The indicator "ADX EMAs Distance" is a custom indicator based on the idea that popular assets with sufficient liquidity cannot remain stationary for long periods. Therefore, the more stationary the prices become for a given timeframe, the more likely it is that they will experience a sharp movement afterward.
The distances between 4 EMAs of different periods have been normalized, resulting in three curves that express the distance between 2, 3, and 4 EMAs. When the curves touch the horizontal line at level 0, the distance between them is zero, which is the case of a simultaneous multiple crossover. Since the crossover is usually lagging, a special level line has been added to warn of the proximity of the averages before their crossover.
Indeed, since the EMAs are insufficient to determine the direction of the subsequent movement, the two complementary curves of the ADX: +DI and -DI have been visually added, which are the ones that really indicate the direction for entering before the movement.
Explanation of the code.
Block 6-11: Definition of the input variables of the script, that is, the periodicity of the four EMAs, the ADX, and the level line assignment.
Block 13-28: Calculation of the 4 EMAs, their relative distance of separation, and their normalization so that they only cover the interval between 0 and 100 and not real numbers that tend to infinity.
Block 30-42: The ADX period is calculated, which includes the +DI and the -DI, and their subsequent normalization to also cover the range between 0 and 100.
Block 44-50: We plotted the 4 EMAs on the main chart and the ADX periods integrated with the normalized separation distance.
Block 52-59: Declaration of alerts with the conditions configured by the user.
This indicator is available for free use in the TradingView® community library of indicators and strategies.