mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-23 13:08:04 +00:00
volume category touchup
This commit is contained in:
+6
-12
@@ -7,20 +7,14 @@ namespace QuanTAlib;
|
||||
/// ADL: Accumulation/Distribution Line
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The Accumulation/Distribution Line is a cumulative indicator that uses volume and price
|
||||
/// to assess whether a stock is being accumulated or distributed.
|
||||
/// Cumulative indicator using volume and price to assess accumulation or distribution.
|
||||
/// Rising ADL confirms accumulation; falling confirms distribution.
|
||||
///
|
||||
/// Calculation:
|
||||
/// 1. Money Flow Multiplier = [(Close - Low) - (High - Close)] / (High - Low)
|
||||
/// 2. Money Flow Volume = Money Flow Multiplier * Volume
|
||||
/// 3. ADL = Previous ADL + Money Flow Volume
|
||||
///
|
||||
/// If High equals Low, the Multiplier is 0.
|
||||
///
|
||||
/// Sources:
|
||||
/// https://www.investopedia.com/terms/a/accumulationdistribution.asp
|
||||
/// https://school.stockcharts.com/doku.php?id=technical_indicators:accumulation_distribution_line
|
||||
/// Calculation: <c>MFM = [(Close - Low) - (High - Close)] / (High - Low)</c>,
|
||||
/// <c>MFV = MFM × Volume</c>, <c>ADL = prev_ADL + MFV</c>. If High equals Low, MFM is 0.
|
||||
/// </remarks>
|
||||
/// <seealso href="Adl.md">Detailed documentation</seealso>
|
||||
/// <seealso href="adl.pine">Reference Pine Script implementation</seealso>
|
||||
[SkipLocalsInit]
|
||||
public sealed class Adl : ITValuePublisher
|
||||
{
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// The MIT License (MIT)
|
||||
// © mihakralj
|
||||
//@version=6
|
||||
indicator("Accumulation/Distribution Line (ADL)", "ADL", overlay=false)
|
||||
|
||||
//@function Calculates the Accumulation/Distribution Line (ADL), a volume-based indicator that measures money flow into and out of a security
|
||||
//@doc https://github.com/mihakralj/pinescript/blob/main/indicators/volume/adl.md
|
||||
//@param src_high The high price (default: built-in high)
|
||||
//@param src_low The low price (default: built-in low)
|
||||
//@param src_close The close price (default: built-in close)
|
||||
//@param src_vol The volume (default: built-in volume)
|
||||
//@returns The cumulative ADL value representing buying/selling pressure
|
||||
adl(src_high = high, src_low = low, src_close = close, src_vol = volume) =>
|
||||
float mfm = 0.0
|
||||
if not na(src_high) and not na(src_low) and not na(src_close)
|
||||
mfm := (src_close - src_low) - (src_high - src_close)
|
||||
mfm := src_high != src_low ? mfm / (src_high - src_low) : 0.0
|
||||
float mfv = na(src_vol) ? 0.0 : src_vol * mfm
|
||||
var float cumulativeSum = 0.0
|
||||
cumulativeSum := na(mfv) ? cumulativeSum : cumulativeSum + mfv
|
||||
cumulativeSum
|
||||
|
||||
// ---------- Inputs ----------
|
||||
|
||||
// ---------- Calculations ----------
|
||||
adl_val = adl(high, low, close, volume)
|
||||
|
||||
// ---------- Plotting ----------
|
||||
plot(adl_val, "ADL", color=color.yellow, linewidth=2)
|
||||
Reference in New Issue
Block a user