Calculation Methodology:
MaxCloseHigh and MinCloseLow:
MaxCloseHigh: Computes the higher value between the closing price (close) and the high price (high) of the current candle.
MinCloseLow: Determines the lower value between the closing price (close) and the low price (low) of the current candle.
Price Difference (priceDifference):
If the current closing price is higher than the previous closing price, the difference between the closing price and the low price (minCloseLow) is calculated.
If the current closing price is lower than the previous closing price, the difference between the closing price and the high price (maxCloseHigh) is calculated.
Cumulative Trend Calculation (cumulativeTrend):
The price difference (priceDifference) is aggregated over time to form a cumulative trend value, which represents the accumulated price movement.
Moving Average of the Trend:
SmoothedTrend: A Simple Moving Average (SMA) applied to the cumulative trend over a defined period (maLength) to smooth the trend and reduce noise.
SmoothedMidTrend: Another SMA applied to the cumulative trend over a shorter period (midMaLength) to allow for quicker response to changes in trend dynamics.
Applications and Use Cases:
Identifying Divergences:
The ADMA indicator excels at detecting divergences between price movements and the indicator itself. Divergences can serve as strong signals for potential trend reversals.
Bullish Divergence: When the price forms lower lows while the ADMA forms higher lows, suggesting a potential upward reversal.
Bearish Divergence: When the price makes higher highs while the ADMA forms lower highs, indicating a possible downward reversal.
How to Spot Divergences: Draw lines connecting two significant points on the price chart and compare them with corresponding points on the ADMA. Deviations between these lines indicate a divergence.
Assessing Market Conditions:
The smoothed line of the ADMA makes it easier to evaluate the current market environment.
Bullish Market: When the cumulativeTrend is above the smoothed trend, it signals a bullish market environment.
Bearish Market: When the cumulativeTrend is below the smoothed trend, it likely indicates a bearish market environment.