Pharos
TAVolume

TA.AD() - 累积/派发线

累积/派发线 (Accumulation/Distribution Line)

基于价格位置和成交量的累积指标,判断资金流向。

返回成交量指标目录


语法

python
TA.AD(high, low, close, volume)

参数

参数名类型必选默认值说明
highany-最高价数组
lowany-最低价数组
closeany-收盘价数组
volumeany-成交量数组

返回值

返回 A/D 线值数组,与输入数组长度相同。

计算方法

累积/派发线通过以下步骤计算:

plaintext
1. 资金流量乘数 = ((Close - Low) - (High - Close)) / (High - Low)
2. 资金流量 = 资金流量乘数 × Volume
3. A/D = 累积(资金流量)

资金流量乘数范围

  • +1:收盘价 = 最高价(最强买盘)
  • 0:收盘价在中间位置
  • -1:收盘价 = 最低价(最强卖盘)

乘数反映了收盘价在当日价格区间的位置,位置越高表明买盘越强。

信号解读

基本信号

  1. A/D 上升:资金流入,买盘强劲
  2. A/D 下降:资金流出,卖盘强劲
  3. 价格新高 + A/D 未新高:顶背离,可能反转
  4. 价格新低 + A/D 未新低:底背离,可能反转

趋势确认

  • A/D 创新高确认上升趋势
  • A/D 创新低确认下降趋势
  • A/D 与价格同步创新高/低 = 强势确认

基础示例

资金流向判断

python
def main():
    while True:
        records = exchange.GetRecords()
        if len(records) < 30:
            Sleep(1000)
            continue
        
        highs = [r['High'] for r in records]
        lows = [r['Low'] for r in records]
        closes = [r['Close'] for r in records]
        volumes = [r['Volume'] for r in records]
        
        ad = TA.AD(highs, lows, closes, volumes)
        
        # 资金流向判断
        if ad[-1] > ad[-10]:
            Log("过去 10 周期资金流入")
            
        elif ad[-1] < ad[-10]:
            Log("过去 10 周期资金流出")
        
        # A/D 短期趋势
        ad_diff = ad[-1] - ad[-2]
        if ad_diff > 0:
            Log("资金持续流入")
        else:
            Log("资金持续流出")
        
        Sleep(60000)

高级应用

A/D 背离检测

python
def main():
    while True:
        records = exchange.GetRecords()
        if len(records) < 50:
            Sleep(1000)
            continue
        
        highs = [r['High'] for r in records]
        lows = [r['Low'] for r in records]
        closes = [r['Close'] for r in records]
        volumes = [r['Volume'] for r in records]
        
        ad = TA.AD(highs, lows, closes, volumes)
        
        # 检测顶背离
        # 价格创 20 周期新高
        if closes[-1] == max(closes[-20:]):
            # 但 A/D 未创新高
            if ad[-1] < max(ad[-20:]):
                Log("⚠️ 顶背离:价格创新高,但 A/D 未创新高,警惕回调")
        
        # 检测底背离
        # 价格创 20 周期新低
        if closes[-1] == min(closes[-20:]):
            # 但 A/D 未创新低
            if ad[-1] > min(ad[-20:]):
                Log("✅ 底背离:价格创新低,但 A/D 未创新低,可能反弹")
        
        Sleep(60000)

A/D 趋势强度分析

python
def main():
    while True:
        records = exchange.GetRecords()
        if len(records) < 100:
            Sleep(1000)
            continue
        
        highs = [r['High'] for r in records]
        lows = [r['Low'] for r in records]
        closes = [r['Close'] for r in records]
        volumes = [r['Volume'] for r in records]
        
        ad = TA.AD(highs, lows, closes, volumes)
        
        # 计算 A/D 的变化率
        ad_change_5 = (ad[-1] - ad[-5]) / abs(ad[-5]) if ad[-5] != 0 else 0
        ad_change_20 = (ad[-1] - ad[-20]) / abs(ad[-20]) if ad[-20] != 0 else 0
        
        # 判断资金流入强度
        if ad_change_5 > 0.05 and ad_change_20 > 0.10:
            Log("强势资金流入,A/D 快速上升")
        elif ad_change_5 < -0.05 and ad_change_20 < -0.10:
            Log("强势资金流出,A/D 快速下降")
        elif abs(ad_change_5) < 0.02:
            Log("资金流向不明确,观望")
        
        Sleep(60000)

A/D 与价格趋势配合

python
def main():
    while True:
        records = exchange.GetRecords()
        if len(records) < 100:
            Sleep(1000)
            continue
        
        highs = [r['High'] for r in records]
        lows = [r['Low'] for r in records]
        closes = [r['Close'] for r in records]
        volumes = [r['Volume'] for r in records]
        
        # 价格趋势
        sma20 = TA.SMA(closes, 20)
        sma50 = TA.SMA(closes, 50)
        
        # A/D 指标
        ad = TA.AD(highs, lows, closes, volumes)
        
        # 判断趋势
        price_trend_up = sma20[-1] > sma50[-1]
        ad_trend_up = ad[-1] > ad[-5]
        
        # 综合判断
        if price_trend_up and ad_trend_up:
            Log("✅ 上升趋势 + 资金流入,强势信号")
        elif price_trend_up and not ad_trend_up:
            Log("⚠️ 上升趋势但资金流出,趋势可能减弱")
        elif not price_trend_up and ad_trend_up:
            Log("💡 下降趋势但资金流入,可能即将反转")
        else:
            Log("❌ 下降趋势 + 资金流出,弱势信号")
        
        Sleep(60000)

参数优化建议

A/D 本身无参数,但可以配合其他分析:

配合方法参数建议说明
回溯周期20-50检测背离的时间窗口
变化率周期5, 10, 20分析资金流入/流出速度
趋势均线20, 50价格趋势判断

与其他指标配合

A/D + OBV 双重确认

python
ad = TA.AD(highs, lows, closes, volumes)
obv = TA.OBV(closes, volumes)

obv_trend = obv[-1] - obv[-5]
ad_trend = ad[-1] - ad[-5]

# 双重确认买入
if obv_trend > 0 and ad_trend > 0:
    Log("OBV + AD 双重确认资金流入")
    if closes[-1] > closes[-2]:
        Log("价格上涨 + 成交量支持,买入信号")

A/D + RSI 超买超卖

python
ad = TA.AD(highs, lows, closes, volumes)
rsi = TA.RSI(closes, 14)

# RSI 超卖 + A/D 上升
if rsi[-1] < 30 and ad[-1] > ad[-5]:
    Log("RSI 超卖且资金流入,可能反弹")

# RSI 超买 + A/D 下降
if rsi[-1] > 70 and ad[-1] < ad[-5]:
    Log("RSI 超买且资金流出,可能回调")

A/D + MACD 趋势确认

python
ad = TA.AD(highs, lows, closes, volumes)
macd = TA.MACD(closes, 12, 26, 9)

# MACD 金叉 + A/D 上升
if macd[0][-1] > macd[1][-1] and ad[-1] > ad[-5]:
    Log("MACD 金叉 + 资金流入,强势买入信号")

注意事项

  1. 相对值重要:A/D 的绝对数值无意义,关注趋势方向
  2. 背离优先:价格与 A/D 的背离是最重要的信号
  3. 收盘价位置:A/D 更关注收盘价在日内区间的位置
  4. 比 OBV 敏感:A/D 通过资金流量乘数更精细地衡量买卖压力
  5. 单边市场:在趋势市场中,A/D 与价格应同步运行
  6. 震荡市场:震荡市场中 A/D 可能横盘,信号不明显
  7. 成交量要求:A/D 需要足够的成交量才能产生有效信号

相关指标

A/D vs OBV 对比

特性A/DOBV
计算方式考虑收盘价位置仅看涨跌方向
敏感度更敏感相对迟钝
适用场景细微的资金流向变化趋势确认
信号质量更早但可能误判更稳定但滞后

实战要点

买入信号

✅ A/D 快速上升 + 价格上涨 ✅ 底背离出现(价跌 A/D 涨) ✅ A/D 创新高确认趋势

卖出信号

❌ A/D 快速下降 + 价格下跌 ❌ 顶背离出现(价涨 A/D 跌) ❌ A/D 创新低确认趋势

风险控制

  • 背离信号需要多周期确认
  • 结合价格趋势和其他动量指标
  • 注意假背离(短期震荡造成)
  • 在重要价格节点关注 A/D 表现

返回成交量指标目录 | 返回 TA 指标总目录