
この戦略は、スーパートレンド インジケーターとカウフマン適応移動平均 (KAMA) を組み合わせたトレンド フォロー トレーディング システムです。この戦略は、市場トレンドの変化を動的に識別し、上昇トレンドにおける長期的な機会を探し、柔軟なストップロスメカニズムを使用してリスクを制御します。この戦略の核となる考え方は、スーパートレンド指標のトレンド方向判断能力と、市場変動に対するKAMA指標の適応特性を組み合わせて、市場の上昇トレンドでロングポジションを確立することです。
この戦略では、デュアルテクニカル指標確認システムを使用します。まず、スーパートレンド インジケーターは、ATR とカスタム係数を使用してトレンドの方向を計算します。インジケーターの線が価格より下にある場合、上昇トレンドを示します。第二に、KAMA インジケーターは適応メカニズムを通じて移動平均の感度を調整し、さまざまな市場環境により適応できるようになります。エントリーシグナルは、スーパートレンドが上昇トレンドを示し、価格が KAMA ラインを上回っているという 2 つの条件を同時に満たす必要があります。同様に、終了シグナルも二重の確認が必要です。スーパートレンドが下降トレンドに変わり、価格が KAMA ラインを下回ります。この二重確認メカニズムにより、誤った信号の影響が効果的に軽減されます。
この戦略は、Supertrend と KAMA という 2 つのテクニカル指標を組み合わせて、強力なトレンド追従型取引システムを構築します。この戦略の主な利点は、適応性とリスク管理能力であり、二重確認メカニズムによって取引シグナルの信頼性が向上します。不安定な市場ではいくつかの課題があるかもしれませんが、適切なパラメータ設定と最適化の方向性の実装により、戦略の全体的なパフォーマンスをさらに向上させることができます。この戦略は、中期および長期のトレンド取引に特に適しており、明確なトレンドのある市場環境でより良いパフォーマンスを発揮します。
/*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")