4.5 KiB
Accumulation/Distribution Line (ADL)
1. Summary (Introduction)
The Accumulation/Distribution Line (A/D Line or ADL) is a volume-based indicator developed by Marc Chaikin. It was designed to measure the cumulative flow of money into and out of a security. The ADL attempts to identify whether traders are primarily "accumulating" (buying) or "distributing" (selling) an asset by analyzing the relationship between the closing price and its trading range, weighted by volume.
It is a cumulative, running total. A rising ADL suggests that buying pressure is dominant, while a falling ADL suggests that selling pressure is dominant. It is primarily used to confirm the strength of a trend or to spot divergences that may signal a potential reversal.
2. Mathematical Foundations and Calculation Logic
The ADL is calculated by first determining the "Money Flow Multiplier" for each period and then using it to weight the volume.
Required Components
- Price Data: The
High,Low, andCloseof each bar. - Volume Data: The volume for each bar.
Calculation Steps (Algorithm)
-
Calculate the Money Flow Multiplier (MFM): This value determines the proportion of the volume that was bullish or bearish. It ranges from +1 (if Close = High) to -1 (if Close = Low).
\text{MFM} = \frac{(\text{Close} - \text{Low}) - (\text{High} - \text{Close})}{\text{High} - \text{Low}}(Note: If High equals Low, the MFM is 0). -
Calculate the Money Flow Volume (MFV): Multiply the MFM by the volume for the period.
\text{MFV}_i = \text{MFM}_i \times \text{Volume}_i -
Calculate the Accumulation/Distribution Line (ADL): The ADL is the cumulative sum of the Money Flow Volume.
\text{ADL}_i = \text{ADL}_{i-1} + \text{MFV}_i
3. MQL5 Implementation Details
Our MQL5 implementation is a self-contained, robust, and accurate representation of the classic A/D Line.
-
Stability via Full Recalculation: We employ a "brute-force" full recalculation within the
OnCalculatefunction. For a cumulative, recursive indicator like the ADL, this is the most reliable method to ensure stability and prevent calculation errors. -
Self-Contained Logic: The indicator is completely self-contained. It does not use any external indicator handles. All calculations are performed manually within a single, efficient
forloop in theOnCalculatefunction. -
Correct Algorithm: The implementation strictly follows the correct, textbook definition of the ADL, ensuring its results are consistent with other professional charting platforms. The logic correctly handles the selection of Tick or Real volume based on user input.
-
Heikin Ashi Variant (
AD_HeikinAshi.mq5):- Our toolkit also includes a "pure" Heikin Ashi version of this indicator. The calculation logic is identical, but it uses the smoothed Heikin Ashi
ha_high,ha_low, andha_closevalues to calculate the Money Flow Multiplier. The volume component remains the standard volume from the underlying chart. - This results in a smoother ADL that reflects the buying and selling pressure of the underlying Heikin Ashi trend, effectively filtering out some of the noise from standard price action.
- Our toolkit also includes a "pure" Heikin Ashi version of this indicator. The calculation logic is identical, but it uses the smoothed Heikin Ashi
4. Parameters
- Volume Type (
InpVolumeType): Allows the user to select between Tick Volume (VOLUME_TICK) and Real Volume (VOLUME_REAL) for the calculation.
5. Usage and Interpretation
The absolute value of the ADL is not important; its slope and direction are what matter.
- Trend Confirmation:
- If both the price and the ADL are making higher highs and higher lows, the uptrend is considered strong and likely to continue.
- If both the price and the ADL are making lower highs and lower lows, the downtrend is considered strong.
- Divergence: This is the most powerful signal from the ADL.
- Bullish Divergence: The price continues to fall and makes a new low, but the ADL fails to make a new low and starts to rise. This suggests that accumulation (buying) is taking place despite the lower prices, which can foreshadow a bullish reversal.
- Bearish Divergence: The price continues to rise and makes a new high, but the ADL fails to make a new high and starts to fall. This suggests that distribution (selling) is occurring on the rally, which can be an early warning of a bearish reversal.
- Caution: The ADL does not account for price gaps between periods. A significant gap down will not be reflected in the ADL's calculation, which can sometimes lead to a discrepancy between price and the indicator. It is best used for confirmation alongside other price-based indicators.