
이 전략은 다중 기술 지표에 기반한 정량 거래 시스템이며, 핵심은 슈퍼 트렌드 (SuperTrend) 지표에 의해 구동되며, ATR 동적 중지 메커니즘과 결합되어 MACD, ADX, RSI 등의 지표를 통해 다차원 트렌드 확인 및 위험 통제를 수행합니다. 이 전략은 높은 확률의 거래 기회를 식별하기 위해 6 개의 필터링 메커니즘을 사용하며, 시장의 위험을 미리 경고하기 위해 3 개의 역방향 검출을 도입합니다.
이 전략은 SuperTrend 지표를 중심으로, factor과 ATR 파라미터를 통해 동적으로 추세 방향을 계산한다. 입시 신호는 다음과 같은 조건을 동시에 충족해야 한다:
시스템은 ATR 동적 손실을 통해 위험을 제어하고, 트렌드 반전 신호와 결합하여 포지션 관리를 한다.
이 전략은 다차원 지표 통합과 엄격한 위험 통제를 통해 안정적인 수치 거래 시스템을 구축한다. 시스템의 모듈화된 디자인은 후속 최적화 및 확장이 용이하지만 실제 응용에서는 파라미터 조정 및 시장 적응성에 주의를 기울여야 한다. 삼중 역전 경고 및 가스 요금 필터와 같은 혁신적인 디자인은 전략의 실용성을 더욱 향상시킨다.
/*backtest
start: 2024-02-22 00:00:00
end: 2025-02-19 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("ETH 超级趋势增强策略-精简版", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// —————————— 参数配置区 ——————————
// 超级趋势参数
atrPeriod = input.int(8, "ATR周期(8-10)", minval=8, maxval=10)
factor = input.float(3.5, "乘数(3.5-4)", minval=3.5, maxval=4, step=0.1)
// MACD参数
fastLength = input.int(10, "MACD快线周期")
slowLength = input.int(21, "MACD慢线周期")
signalLength = input.int(7, "信号线周期")
// ADX参数
adxLength = input.int(18, "ADX周期")
adxThreshold = input.int(28, "ADX趋势阈值")
// 成交量验证
volFilterRatio = input.float(1.8, "成交量放大倍数", step=0.1)
// ATR止损
atrStopMulti = input.float(2.2, "ATR止损乘数", step=0.1)
// —————————— 核心指标计算 ——————————
// 1. 超级趋势(修复索引使用)
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
plot(supertrend, color=direction < 0 ? color.new(color.green, 0) : color.new(color.red, 0), linewidth=2)
// 2. MACD指标
[macdLine, signalLine, histLine] = ta.macd(close, fastLength, slowLength, signalLength)
macdCol = histLine > histLine[1] ? color.green : color.red
// 3. ADX趋势强度
[DIMinus, DIPlus, ADX] = ta.dmi(adxLength, adxLength)
// 4. 成交量验证
volMA = ta.sma(volume, 20)
volValid = volume > volMA * volFilterRatio
// 5. ATR动态止损
atrVal = ta.atr(14)
var float stopPrice = na
// —————————— 三重背离检测 ——————————
// RSI背离检测
rsiVal = ta.rsi(close, 14)
priceHigh = ta.highest(high, 5)
rsiHigh = ta.highest(rsiVal, 5)
divergenceRSI = high >= priceHigh[1] and rsiVal < rsiHigh[1]
// MACD柱状图背离
macdHigh = ta.highest(histLine, 5)
divergenceMACD = high >= priceHigh[1] and histLine < macdHigh[1]
// 成交量背离
volHigh = ta.highest(volume, 5)
divergenceVol = high >= priceHigh[1] and volume < volHigh[1]
tripleDivergence = divergenceRSI and divergenceMACD and divergenceVol
// —————————— 信号生成逻辑 ——————————
// 多头条件(6层过滤)
longCondition =
direction < 0 and // 超级趋势看涨
histLine > 0 and // MACD柱在零轴上方
ADX > adxThreshold and // 趋势强度达标
close > open and // 阳线确认
volValid and // 成交量验证
not tripleDivergence // 无三重顶背离
// 空头条件(精简条件)
shortCondition =
direction > 0 and // 超级趋势看跌
histLine < 0 and // MACD柱在零轴下方
ADX > adxThreshold and // 趋势强度达标
close < open and // 阴线确认
volValid and // 成交量验证
tripleDivergence // 出现三重顶背离
// —————————— 交易执行模块 ——————————
if (longCondition)
strategy.entry("Long", strategy.long)
stopPrice := close - atrVal * atrStopMulti
if (shortCondition)
strategy.entry("Short", strategy.short)
stopPrice := close + atrVal * atrStopMulti
// 动态止损触发
strategy.exit("Exit Long", "Long", stop=stopPrice)
strategy.exit("Exit Short", "Short", stop=stopPrice)
// 趋势反转离场
if (direction > 0 and strategy.position_size > 0)
strategy.close("Long")
if (direction < 0 and strategy.position_size < 0)
strategy.close("Short")
// —————————— 可视化提示 ——————————
plotshape(longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="买入信号")
plotshape(shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="卖出信号")
plot(strategy.position_size != 0 ? stopPrice : na, color=color.orange, style=plot.style_linebr, linewidth=2, title="动态止损线")
// —————————— 预警系统 ——————————
alertcondition(tripleDivergence, title="三重顶背离预警", message="ETH出现三重顶背离!")
longCondition := longCondition