TAKline
TA.CDLHARAMI() - 孕线
Harami Pattern 孕线,第二根K线实体完全在第一根实体内,双向反转信号。
语法
python
TA.CDLHARAMI(opens, highs, lows, closes)返回值
- 100:看涨孕线(底部反转)
- -100:看跌孕线(顶部反转)
- 0:未识别到
形态特征
- 第一根:长实体K线
- 第二根:小实体,完全在第一根实体内
- 颜色相反:两根K线颜色通常相反
信号解读
市场动能减弱,可能反转。需结合趋势判断方向。
使用示例
python
def harami_pattern():
records = exchange.GetRecords()
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]
pattern = TA.CDLHARAMI(opens, highs, lows, closes)
sma50 = TA.SMA(closes, 50)
if pattern[-1] == 100 and closes[-2] < sma50[-2]:
# 下跌趋势中的看涨孕线
exchange.Buy(-1, 0.5)
Log("看涨孕线,做多")
elif pattern[-1] == -100 and closes[-2] > sma50[-2]:
# 上升趋势中的看跌孕线
exchange.Sell(-1, 0.5)
Log("看跌孕线,做空")