Pharos
TAKline

锤子线 (Hammer)

函数签名

python
TA.CDLHAMMER(opens, highs, lows, closes) -> array

功能说明

锤子线是一个看涨反转形态,通常出现在下跌趋势的底部,表示卖方力量减弱,买方开始进场。

形态特征

外观特点

  • 长下影线: 下影线长度至少是实体的2倍
  • 小实体: 实体很小(可以是阳线或阴线)
  • 无或短上影线: 几乎没有上影线
  • 位置: 出现在K线区间的上端

市场含义

  1. 开盘后价格大幅下跌
  2. 但收盘时被拉回接近开盘价
  3. 显示买方在低位强力介入
  4. 卖方失去控制权

参数说明

参数类型说明
opensarray开盘价数组
highsarray最高价数组
lowsarray最低价数组
closesarray收盘价数组

返回值

返回整数数组:

  • 100: 检测到锤子线(看涨信号)
  • 0: 未检测到形态

使用示例

基础用法

python
def main():
    while True:
        records = exchange.GetRecords()
        if len(records) < 10:
            Sleep(1000)
            continue
        
        opens = [r['Open'] for r in records]
        highs = [r['High'] for r in records]
        lows = [r['Low'] for r in records]
        closes = [r['Close'] for r in records]
        
        hammer = TA.CDLHAMMER(opens, highs, lows, closes)
        
        if hammer[-1] == 100:
            Log("检测到锤子线,可能反转上涨")
        
        Sleep(60000)

结合趋势确认

python
def main():
    while True:
        records = exchange.GetRecords()
        if len(records) < 100:
            Sleep(1000)
            continue
        
        opens = [r['Open'] for r in records]
        highs = [r['High'] for r in records]
        lows = [r['Low'] for r in records]
        closes = [r['Close'] for r in records]
        
        # 检测锤子线
        hammer = TA.CDLHAMMER(opens, highs, lows, closes)
        
        # 判断趋势
        sma20 = TA.SMA(closes, 20)
        sma50 = TA.SMA(closes, 50)
        
        # 只在下跌趋势中使用锤子线
        if hammer[-1] == 100 and closes[-1] < sma20[-1] < sma50[-1]:
            Log("下跌趋势 + 锤子线 = 买入信号")
            Log(f"建议止损: {lows[-1] * 0.98}")
        
        Sleep(60000)

结合成交量验证

python
def main():
    while True:
        records = exchange.GetRecords()
        if len(records) < 50:
            Sleep(1000)
            continue
        
        opens = [r['Open'] for r in records]
        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]
        
        # 检测锤子线
        hammer = TA.CDLHAMMER(opens, highs, lows, closes)
        
        # 成交量分析
        vol_sma = TA.SMA(volumes, 20)
        vol_increase = volumes[-1] > vol_sma[-1] * 1.3
        
        # OBV确认
        obv = TA.OBV(closes, volumes)
        obv_rising = obv[-1] > obv[-2]
        
        if hammer[-1] == 100 and vol_increase and obv_rising:
            Log("锤子线 + 成交量放大 + OBV上升 = 强烈买入信号")
        
        Sleep(60000)

多形态组合

python
def main():
    while True:
        records = exchange.GetRecords()
        if len(records) < 100:
            Sleep(1000)
            continue
        
        opens = [r['Open'] for r in records]
        highs = [r['High'] for r in records]
        lows = [r['Low'] for r in records]
        closes = [r['Close'] for r in records]
        
        # 检测多个看涨形态
        hammer = TA.CDLHAMMER(opens, highs, lows, closes)
        engulfing = TA.CDLENGULFING(opens, highs, lows, closes)
        dragonfly = TA.CDLDRAGONFLYDOJI(opens, highs, lows, closes)
        
        # 计算RSI超卖
        rsi = TA.RSI(closes, 14)
        oversold = rsi[-1] < 30
        
        bullish_count = 0
        if hammer[-1] == 100: bullish_count += 1
        if engulfing[-1] == 100: bullish_count += 1
        if dragonfly[-1] == 100: bullish_count += 1
        
        if bullish_count >= 2 and oversold:
            Log(f"检测到 {bullish_count} 个看涨形态 + RSI超卖")
            Log("强烈买入信号")
        
        Sleep(60000)

识别要点

有效的锤子线

✅ 下影线长度 ≥ 实体的2倍
✅ 实体很小
✅ 上影线很短或没有
✅ 出现在下跌趋势底部
✅ 伴随成交量放大

无效的锤子线

❌ 出现在上涨趋势中
❌ 下影线不够长
❌ 实体太大
❌ 成交量萎缩
❌ 后续无确认K线

实战技巧

1. 位置很重要

锤子线必须出现在下跌趋势的底部才有效。如果出现在上涨趋势中,则不可靠。

2. 等待确认

发现锤子线后,等待下一根K线确认:

  • 下一根K线收阳线
  • 收盘价高于锤子线的收盘价
  • 成交量放大

3. 设置止损

止损位设在锤子线最低点下方1-2%:

python
stop_loss = lows[-1] * 0.98

4. 目标位

初步目标可设在最近的阻力位,或使用ATR计算:

python
atr = TA.ATR(highs, lows, closes, 14)
target = closes[-1] + atr[-1] * 2

常见变种

倒锤子线

如果锤子线出现长上影线、短下影线,则称为倒锤子线,也是看涨信号:

python
inverted = TA.CDLINVERTEDHAMMER(opens, highs, lows, closes)

彩色锤子

  • 绿锤子(阴线锤子):开盘高于收盘,通常更可靠
  • 红锤子(阳线锤子):开盘低于收盘

两者都有效,但绿锤子略强。

可靠性分析

评估项评分
整体可靠性⭐⭐⭐ (中等)
单独使用⭐⭐ (不推荐)
结合趋势⭐⭐⭐⭐ (推荐)
结合成交量⭐⭐⭐⭐⭐ (强烈推荐)

统计数据

  • 胜率: 约55-60%(单独使用)
  • 胜率: 约70-75%(结合确认)
  • 最佳时间周期: 日线、4小时
  • 适用市场: 股票、期货、数字货币

注意事项

⚠️ 重要提示:

  1. 需要TA-Lib库: 此函数依赖TA-Lib
  2. 趋势判断: 必须在下跌趋势中使用
  3. 等待确认: 不要立即行动,等待下一根K线确认
  4. 设置止损: 锤子线也可能失效,必须设置止损
  5. 假信号: 震荡市中容易出现假锤子线

相关形态

返回

返回K线形态目录