Pharos
TAKline

早晨之星 (Morning Star)

函数签名

python
TA.CDLMORNINGSTAR(opens, highs, lows, closes, penetration=0.3) -> array

功能说明

早晨之星是一个强烈的看涨反转形态,由三根K线组成,通常出现在下跌趋势的底部,是最可靠的反转信号之一。

形态特征

三根K线组成

第一根: 长阴线

  • 实体较大的阴线
  • 确认下跌趋势

第二根: 星线(小实体)

  • 实体很小(可以是阳线或阴线)
  • 向下跳空
  • 表示市场犹豫

第三根: 长阳线

  • 实体较大的阳线
  • 收盘价深入第一根阴线实体内部
  • 确认反转

市场含义

  1. 第一根阴线:卖方占主导
  2. 第二根星线:多空平衡,市场犹豫
  3. 第三根阳线:买方发力,确认反转

参数说明

参数类型默认值说明
opensarray-开盘价数组
highsarray-最高价数组
lowsarray-最低价数组
closesarray-收盘价数组
penetrationfloat0.3渗透比例(0-1)

penetration 参数详解

控制第三根阳线必须深入第一根阴线实体的程度:

  • 0.3: 深入30%(默认,平衡)
  • 0.5: 深入50%(更严格,信号更可靠)
  • 0.7: 深入70%(非常严格,信号较少)
python
# 宽松模式 - 更多信号
loose = TA.CDLMORNINGSTAR(opens, highs, lows, closes, penetration=0.2)

# 严格模式 - 更可靠
strict = TA.CDLMORNINGSTAR(opens, highs, lows, closes, penetration=0.6)

返回值

返回整数数组:

  • 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]
        
        morning_star = TA.CDLMORNINGSTAR(opens, highs, lows, closes, penetration=0.3)
        
        if morning_star[-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]
        volumes = [r['Volume'] for r in records]
        
        # 检测早晨之星
        morning_star = TA.CDLMORNINGSTAR(opens, highs, lows, closes, penetration=0.3)
        
        # 趋势判断
        sma50 = TA.SMA(closes, 50)
        sma200 = TA.SMA(closes, 200)
        downtrend = closes[-1] < sma50[-1] < sma200[-1]
        
        # 成交量分析
        vol_sma = TA.SMA(volumes, 20)
        vol_surge = volumes[-1] > vol_sma[-1] * 1.5  # 第三根K线成交量放大
        
        # RSI超卖
        rsi = TA.RSI(closes, 14)
        oversold = rsi[-1] < 35
        
        if morning_star[-1] == 100:
            score = 0
            if downtrend: score += 2
            if vol_surge: score += 2
            if oversold: score += 1
            
            Log(f"早晨之星 (评分: {score}/5)")
            if score >= 3:
                Log("⭐ 强烈买入信号!")
                Log(f"建议止损: {min(lows[-3:])*0.98}")
        
        Sleep(60000)

参数优化

python
def find_best_penetration():
    """测试不同penetration参数的效果"""
    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]
    
    penetrations = [0.2, 0.3, 0.4, 0.5, 0.6]
    
    for p in penetrations:
        pattern = TA.CDLMORNINGSTAR(opens, highs, lows, closes, penetration=p)
        signals = sum([1 for x in pattern if x == 100])
        Log(f"penetration={p}: 检测到 {signals} 个信号")

完整交易系统

python
def main():
    position = None
    
    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]
        volumes = [r['Volume'] for r in records]
        
        # 检测早晨之星
        morning_star = TA.CDLMORNINGSTAR(opens, highs, lows, closes, penetration=0.3)
        
        # 检测黄昏之星(退出信号)
        evening_star = TA.CDLEVENINGSTAR(opens, highs, lows, closes, penetration=0.3)
        
        # 计算ATR止损
        atr = TA.ATR(highs, lows, closes, 14)
        
        # 买入逻辑
        if position is None and morning_star[-1] == 100:
            price = closes[-1]
            stop_loss = price - atr[-1] * 2
            take_profit = price + atr[-1] * 3
            
            Log(f"早晨之星买入 @ {price}")
            Log(f"止损: {stop_loss}")
            Log(f"目标: {take_profit}")
            
            # exchange.Buy(price)
            position = {
                'entry': price,
                'stop': stop_loss,
                'target': take_profit
            }
        
        # 卖出逻辑
        elif position is not None:
            current_price = closes[-1]
            
            # 止损
            if current_price < position['stop']:
                Log(f"止损卖出 @ {current_price}")
                # exchange.Sell(current_price)
                position = None
            
            # 止盈
            elif current_price > position['target']:
                Log(f"止盈卖出 @ {current_price}")
                # exchange.Sell(current_price)
                position = None
            
            # 黄昏之星退出
            elif evening_star[-1] == -100:
                Log(f"黄昏之星退出 @ {current_price}")
                # exchange.Sell(current_price)
                position = None
        
        Sleep(60000)

识别要点

完美的早晨之星

✅ 第一根是长阴线
✅ 第二根跳空向下
✅ 第二根实体很小
✅ 第三根长阳线
✅ 第三根深入第一根实体≥30%
✅ 第三根成交量放大
✅ 出现在下跌趋势底部

质量较差的早晨之星

⚠️ 第二根没有跳空
⚠️ 第三根渗透不足
⚠️ 出现在横盘震荡中
⚠️ 成交量萎缩

实战技巧

1. 确认三要素

  • 位置: 必须在下跌趋势底部
  • 形态: 三根K线符合标准
  • 成交量: 第三根K线成交量放大

2. 入场时机

两种入场方式:

python
# 方式1: 激进 - 第三根K线收盘时买入
if morning_star[-1] == 100:
    buy()

# 方式2: 稳健 - 等待下一根K线确认
if morning_star[-2] == 100 and closes[-1] > closes[-2]:
    buy()  # 确认后买入

3. 止损设置

python
# 方法1: 设在早晨之星最低点
stop_loss = min(lows[-3:]) * 0.98

# 方法2: 使用ATR
atr = TA.ATR(highs, lows, closes, 14)
stop_loss = closes[-1] - atr[-1] * 2

4. 目标位

python
# 初步目标: 最近阻力位
# 或使用ATR计算
atr = TA.ATR(highs, lows, closes, 14)
target1 = closes[-1] + atr[-1] * 2  # 保守
target2 = closes[-1] + atr[-1] * 3  # 激进

变种形态

早晨十字星

第二根是十字星,信号更强:

python
morning_doji = TA.CDLMORNINGDOJISTAR(opens, highs, lows, closes, penetration=0.3)

不完美的早晨之星

  • 第二根没有跳空,但其他特征符合
  • 仍然有效,但可靠性略低

可靠性分析

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

统计数据

  • 胜率: 约70-75%(单独使用)
  • 胜率: 约80-85%(结合确认)
  • 最佳时间周期: 日线、周线
  • 适用市场: 所有市场

常见错误

错误1: 在横盘震荡中使用

python
# 错误示例
if morning_star[-1] == 100:
    buy()  # 没有判断趋势

正确做法:

python
# 正确示例
sma50 = TA.SMA(closes, 50)
downtrend = closes[-1] < sma50[-1]
if morning_star[-1] == 100 and downtrend:
    buy()  # 在下跌趋势中使用

错误2: 不设止损

python
# 危险!
if morning_star[-1] == 100:
    buy()  # 没有止损

正确做法:

python
if morning_star[-1] == 100:
    entry = closes[-1]
    stop = min(lows[-3:]) * 0.98
    buy(entry, stop_loss=stop)

注意事项

⚠️ 重要提示:

  1. 需要TA-Lib库: 此函数依赖TA-Lib
  2. 趋势确认: 在下跌趋势中使用效果最佳
  3. 成交量: 第三根K线成交量应放大
  4. 等待形态完成: 三根K线全部收盘后才确认
  5. 假信号: 在震荡市中可能出现假信号

对比形态

早晨之星 vs 黄昏之星

特征早晨之星黄昏之星
位置底部顶部
第一根长阴线长阳线
第二根向下跳空小K线向上跳空小K线
第三根长阳线长阴线
信号看涨看跌

相关形态

返回

返回K线形态目录