TAKline
TA.CDL3WHITESOLDIERS() - 三白兵
3 White Soldiers 三白兵,三根连续上涨的阳线,是强烈的底部反转或持续上涨信号。
语法
python
TA.CDL3WHITESOLDIERS(opens, highs, lows, closes)参数
| 参数 | 类型 | 说明 |
|---|---|---|
| opens | array | 开盘价序列 |
| highs | array | 最高价序列 |
| lows | array | 最低价序列 |
| closes | array | 收盘价序列 |
返回值
返回整数数组:
- 100:识别到三白兵(看涨)
- 0:未识别到
形态特征
- 三根阳线:连续三根实体较长的阳线
- 逐步上涨:每根收盘价高于前一根
- 开盘在实体内:每根开盘价在前一根实体中上部
- 影线较短:上下影线都很短
- 出现位置:下降趋势末期或低位
识别标准
plaintext
1. 连续3根阳线:Close[i] > Open[i]
2. 递增收盘:Close[-1] > Close[-2] > Close[-3]
3. 开盘在实体内:Open[-2] > Open[-3] 且 Open[-2] < Close[-3]
4. 实体较长:每根阳线实体 > 平均实体
5. 收盘接近最高:Close ≈ High(影线短)信号强度
| 特征 | 强度 | 说明 |
|---|---|---|
| 标准形态 | ⭐⭐⭐⭐ | 低位出现,强烈看涨 |
| 影线极短 | ⭐⭐⭐⭐⭐ | 买方完全控盘 |
| 配合放量 | ⭐⭐⭐⭐⭐ | 确认性极强 |
| 连续跳空 | ⭐⭐⭐⭐⭐ | 强势上涨 |
基础示例
python
def three_white_soldiers():
records = exchange.GetRecords()
if len(records) < 50:
return
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.CDL3WHITESOLDIERS(opens, highs, lows, closes)
if pattern[-1] == 100:
Log("✅ 出现三白兵,强烈看涨信号")
# 检查位置
sma50 = TA.SMA(closes, 50)
rsi = TA.RSI(closes, 14)
if closes[-3] < sma50[-3] and rsi[-4] < 40:
Log("低位三白兵 → 底部反转信号")
exchange.Buy(-1, 1)
Log("做多入场")
elif closes[-3] > sma50[-3]:
Log("高位三白兵 → 趋势持续信号")
exchange.Buy(-1, 0.5)
Log("轻仓跟随")高级应用
三白兵突破策略
python
def soldiers_breakout_strategy():
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]
volumes = [r['Volume'] for r in records]
pattern = TA.CDL3WHITESOLDIERS(opens, highs, lows, closes)
if pattern[-1] == 100:
# 检查是否突破阻力位
resistance = TA.MAX(highs[-50:-3], 47)[-1]
if closes[-1] > resistance:
Log("三白兵突破阻力位")
# 检查成交量
avg_vol = sum(volumes[-20:-3]) / 17
recent_vol = sum(volumes[-3:]) / 3
if recent_vol > avg_vol * 1.3:
Log("放量突破,信号强烈")
# 做多入场
atr = TA.ATR(records, 14)
entry = closes[-1]
stop_loss = lows[-3] - atr[-1] # 第一根白兵下方
exchange.Buy(-1, 1)
Log(f"入场: {entry:.2f}")
Log(f"止损: {stop_loss:.2f}")三白兵 + MACD金叉
python
def soldiers_macd_combo():
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.CDL3WHITESOLDIERS(opens, highs, lows, closes)
macd_result = TA.MACD(closes, 12, 26, 9)
dif = macd_result[0]
dea = macd_result[1]
if pattern[-1] == 100:
# MACD金叉
if dif[-1] > dea[-1] and dif[-2] <= dea[-2]:
Log("三白兵 + MACD金叉 → 极强看涨")
# 检查底背离
price_lower = closes[-4] < closes[-10]
macd_higher = dif[-4] > dif[-10]
if price_lower and macd_higher:
Log("底背离确认,趋势反转")
# 激进做多
exchange.Buy(-1, 1.5)
atr = TA.ATR(records, 14)
stop = min(lows[-3], lows[-2], lows[-1]) - atr[-1]
Log(f"止损: {stop:.2f}")信号解读
出现位置分析
-
下降趋势底部(最佳)
- 趋势反转信号
- 可靠性极高
- 建议做多或平空
-
横盘震荡低位
- 可能向上突破
- 积极做多
- 突破确认后加仓
-
上升趋势中途
- 趋势加速信号
- 持有多仓
- 可适量加仓
确认条件
必要条件
- ✅ 出现在下降趋势末期或低位
- ✅ 前期RSI < 40
- ✅ 三根阳线实体均较长
- ✅ 影线短(收盘近最高价)
增强条件
- 🔥 成交量逐步放大
- 🔥 MACD底背离或金叉
- 🔥 突破关键阻力位
- 🔥 第四根K线继续上涨
止损止盈
python
def soldiers_risk_management():
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.CDL3WHITESOLDIERS(opens, highs, lows, closes)
if pattern[-1] == 100:
atr = TA.ATR(records, 14)
entry = closes[-1]
# 止损:第一根白兵最低点下方
stop_loss = min(lows[-3], lows[-2], lows[-1]) - atr[-1]
# 止盈:风险回报比1:3
risk = entry - stop_loss
target_1 = entry + risk * 1.5 # 目标1: 1.5R
target_2 = entry + risk * 3 # 目标2: 3R
Log(f"入场: {entry:.2f}")
Log(f"止损: {stop_loss:.2f} (风险: {risk:.2f})")
Log(f"目标1: {target_1:.2f} (50%仓位)")
Log(f"目标2: {target_2:.2f} (剩余仓位)")参数优化
时间周期
| 周期 | 可靠性 | 持续时间 | 建议 |
|---|---|---|---|
| 日线 | ⭐⭐⭐⭐⭐ | 数周 | 最佳 |
| 4小时 | ⭐⭐⭐⭐ | 数日 | 较好 |
| 1小时 | ⭐⭐⭐ | 数小时 | 需确认 |
| 15分钟 | ⭐⭐ | 短暂 | 不推荐 |
市场环境
| 环境 | 适用性 | 建议 |
|---|---|---|
| 强势牛市 | ⭐⭐⭐⭐⭐ | 积极做多 |
| 弱势反弹 | ⭐⭐⭐ | 轻仓试探 |
| 横盘震荡 | ⭐⭐⭐⭐ | 突破后做多 |
| 熊市 | ⭐⭐ | 谨慎观望 |
注意事项
- 位置重要:低位三白兵最可靠
- 成交量:放量上涨更可靠
- 影线长度:影线过长可靠性降低
- 后续确认:第四根K线继续上涨最好
- 避免追高:高位出现谨慎对待
失败案例
三白兵也可能失败:
python
# 失败信号
1. 第四根K线收大阴线
2. 快速回落跌破第一根白兵开盘价
3. 成交量萎缩
4. 出现在上升趋势顶部(可能是诱多)实战技巧
- 分批建仓:第一根白兵试探,第三根确认
- 移动止损:每日将止损上移至前日低点
- 部分止盈:达到第一目标平50%
- 趋势跟踪:用EMA跟踪趋势持有
- 避免贪婪:达到目标及时获利
对比形态
| 形态 | 方向 | 可靠性 | K线数 |
|---|---|---|---|
| 三白兵 | 看涨 | ⭐⭐⭐⭐⭐ | 3 |
| 三只乌鸦 | 看跌 | ⭐⭐⭐⭐⭐ | 3 |
| 早晨之星 | 看涨 | ⭐⭐⭐⭐ | 3 |
| 刺透形态 | 看涨 | ⭐⭐⭐ | 2 |
相关形态
- 三只乌鸦 - CDL3BLACKCROWS(看跌对应)
- 早晨之星 - CDLMORNINGSTAR(三K线看涨)
- 刺透形态 - CDLPIERCING(两K线看涨)
- 前进阻挡 - CDLADVANCEBLOCK(弱化版看跌)