
이 전략은 슈퍼트렌드 지표와 카우프만 적응형 이동 평균(KAMA)을 결합한 추세 추종 거래 시스템입니다. 이 전략은 시장 추세의 변화를 역동적으로 파악하고, 상승 추세에서 장기적 기회를 찾으며, 유연한 손절매 메커니즘을 사용하여 위험을 통제합니다. 이 전략의 핵심 아이디어는 Supertrend 지표의 추세 방향 판단 능력과 KAMA 지표의 시장 변동에 대한 적응 특성을 결합하여 시장 상승 추세에서 롱 포지션을 확립하는 것입니다.
이 전략은 이중 기술 지표 확인 시스템을 사용합니다. 첫째, Supertrend 지표는 ATR과 사용자 정의 계수를 통해 추세 방향을 계산합니다. 지표 선이 가격 아래에 있으면 상승 추세를 나타냅니다. 두 번째로, KAMA 지표는 적응적 메커니즘을 통해 이동평균선의 민감도를 조절하는데, 이는 다양한 시장 환경에 더 잘 적응할 수 있습니다. 진입 신호는 동시에 두 가지 조건을 충족해야 합니다. 슈퍼트렌드는 상승 추세를 나타내고, 가격은 KAMA 선 위에 있습니다. 마찬가지로, 종료 신호에도 두 번의 확인이 필요합니다. 즉, 슈퍼트렌드가 하락세로 바뀌고 가격이 KAMA 선 아래로 떨어지는 것입니다. 이러한 이중 확인 메커니즘은 잘못된 신호의 영향을 효과적으로 줄여줍니다.
이 전략은 두 가지 기술 지표인 Supertrend와 KAMA를 결합하여 강력한 추세 추종 거래 시스템을 구축합니다. 이 전략의 주요 장점은 적응성과 위험 관리 능력이며, 이중 확인 메커니즘을 통해 거래 신호의 신뢰성이 향상됩니다. 변동성이 큰 시장에서는 몇 가지 어려움이 있을 수 있지만, 적절한 매개변수 설정과 최적화 방향의 구현을 통해 전략의 전반적인 성과를 더욱 개선할 수 있습니다. 이 전략은 특히 중기 및 장기 추세 거래에 적합하며 추세가 명확한 시장 환경에서 더 좋은 성과를 거두고 있습니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-25 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("Supertrend + KAMA Long Strategy", overlay=true, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3)
// User-defined inputs for date range
startDate = input(timestamp("2018-01-01 00:00:00"), title="Start Date")
endDate = input(timestamp("2069-12-31 23:59:59"), title="End Date")
inDateRange = true
// Inputs for KAMA and Supertrend
kamaLength = input.int(21, title="KAMA Length", minval=1)
atrPeriod = input.int(10, title="Supertrend ATR Length", minval=1)
factor = input.float(3.0, title="Supertrend Factor", minval=0.01, step=0.01)
//------------------------- Kaufman Moving Average Adaptive (KAMA) -------------------------
xPrice = close
xvnoise = math.abs(xPrice - xPrice[1])
Length = kamaLength
nfastend = 0.666
nslowend = 0.0645
nsignal = math.abs(xPrice - xPrice[Length])
float nnoise = 0.0
for i = 0 to Length - 1
nnoise := nnoise + xvnoise[i]
nefratio = nnoise != 0.0 ? nsignal / nnoise : 0.0
nsmooth = math.pow(nefratio * (nfastend - nslowend) + nslowend, 2)
var float nAMA = na
nAMA := nz(nAMA[1]) + nsmooth * (xPrice - nz(nAMA[1]))
plot(nAMA, color=color.blue, linewidth=2, title="Kaufman KAMA")
//------------------------- Supertrend Calculation -------------------------
[stValue, dirValue] = ta.supertrend(factor, atrPeriod)
upTrend = dirValue < 0
downTrend = dirValue >= 0
plot(dirValue < 0 ? stValue : na, "Up Trend", color=color.green, style=plot.style_linebr)
plot(dirValue >= 0 ? stValue : na, "Down Trend", color=color.red, style=plot.style_linebr)
//------------------------- Strategy Logic -------------------------
// Entry condition: Supertrend is in uptrend AND price is above KAMA
canLong = inDateRange and upTrend and close > nAMA
// Exit condition (Take Profit): Supertrend switches to downtrend AND price is below KAMA
stopLoss = inDateRange and downTrend and close < nAMA
if canLong
strategy.entry("Long", strategy.long)
label.new(bar_index, low, "BUY", color=color.green, textcolor=color.white, style=label.style_label_down, size=size.normal)
if stopLoss
strategy.close("Long", comment="Stop Loss")
label.new(bar_index, high, "STOP LOSS", color=color.red, textcolor=color.white, style=label.style_label_up, size=size.normal)
//------------------------- Alerts -------------------------
alertcondition(canLong, title="Long Entry", message="Supertrend + KAMA Long Signal")
alertcondition(stopLoss, title="Stop Loss", message="Supertrend switched to Downtrend and Price below KAMA")