
Strategi ini adalah sistem perdagangan kuantitatif yang didasarkan pada beberapa indikator teknis, yang didorong oleh indikator SuperTrend, yang digabungkan dengan mekanisme stop loss dinamis ATR, untuk pengakuan tren multi-dimensi dan pengendalian risiko melalui indikator seperti MACD, ADX, RSI. Strategi ini menggunakan mekanisme penyaringan enam untuk mengidentifikasi peluang perdagangan probabilitas tinggi, sekaligus memperkenalkan deteksi tiga kali lipat untuk memperingatkan risiko pasar lebih awal.
Strategi ini berpusat pada indikator SuperTrend, yang secara dinamis menghitung arah tren melalui faktor dan parameter ATR. Sinyal masuk harus memenuhi persyaratan berikut:
Sistem mengendalikan risiko melalui stop loss dinamis ATR, dan melakukan manajemen posisi dengan sinyal pembalikan tren.
Strategi ini membangun sistem perdagangan kuantitatif yang kuat dengan penggabungan indikator multi-dimensi dan kontrol risiko yang ketat. Desain modular sistem ini memudahkan optimalisasi dan perluasan, tetapi dalam aplikasi praktis perlu memperhatikan penyesuaian parameter dan adaptasi pasar. Desain inovatif seperti peringatan tiga kali lipat dan penyaringan biaya gas meningkatkan kepraktisan strategi.
/*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