
この戦略は、コーラルトレンドインジケーターとドンチャンチャネルを組み合わせたトレンドフォロー取引システムです。市場の勢いを正確に捉え、トレンドの突破を何度も確認することで、不安定な市場における誤ったシグナルが効果的に除去され、取引の精度が向上します。この戦略では、市場の状況に応じてパラメータを動的に調整できる適応型移動平均技術を使用しているため、さまざまな市場環境で安定したパフォーマンスを維持できます。
戦略の核となるロジックは、次の 2 つの主要指標の相乗効果に基づいています。
両方の指標が上昇トレンドを確認した場合(coralTrendVal == 1およびdonchianTrendVal == 1)、システムはロングシグナルを生成します。両方の指標が下降トレンドを確認した場合(coralTrendVal == -1およびdonchianTrendVal == -1)、システムはロングシグナルを生成します。短い信号。この戦略では、ステート マシン (trendState) を使用して現在のトレンド状態を追跡し、重複する信号を回避します。
この戦略は、複数のトレンド確認メカニズムと柔軟なパラメータ設定を通じて、堅牢なトレンド追跡システムを実装します。適応性と明確なシグナルロジックにより、さまざまな取引サイクルや市場環境に適しています。推奨される最適化の方向を通じて、戦略のパフォーマンスをさらに向上させることができます。実際の取引に適用する場合は、リスク管理策を組み合わせて、特定の取引商品の特性に応じてパラメータを最適化することをお勧めします。
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-16 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=5
strategy("Coral Tides Strategy", shorttitle="CoralTidesStrat", overlay=true)
// === Inputs ===
dlen = input.int(defval=20, title="Donchian Channel Period", minval=10)
coralPeriod = input.int(defval=14, title="Coral Trend Period")
// === Functions ===
// Coral Trend Calculation
coralTrend(period) =>
smooth = (high + low + close) / 3
coral = ta.ema(smooth, period)
trend = 0
trend := close > coral ? 1 : close < coral ? -1 : trend[1]
[trend, coral]
// Donchian Trend Calculation
donchianTrend(len) =>
hh = ta.highest(high, len)
ll = ta.lowest(low, len)
trend = 0
trend := close > hh[1] ? 1 : close < ll[1] ? -1 : trend[1]
trend
// === Trend Calculation ===
[coralTrendVal, coralLine] = coralTrend(coralPeriod)
donchianTrendVal = donchianTrend(dlen)
// === Signal Logic ===
var int trendState = 0
buySignal = false
sellSignal = false
if (coralTrendVal == 1 and donchianTrendVal == 1 and trendState != 1)
buySignal := true
sellSignal := false
trendState := 1
else if (coralTrendVal == -1 and donchianTrendVal == -1 and trendState != -1)
sellSignal := true
buySignal := false
trendState := -1
else
buySignal := false
sellSignal := false
// === Strategy Execution ===
// Entry Signals
if (buySignal)
strategy.entry("Long", strategy.long)
if (sellSignal)
strategy.entry("Short", strategy.short)
// === Plots ===
// Coral Trend Line
plot(coralLine, color=color.green, linewidth=2, title="Coral Trend Line")
// Buy/Sell Signal Labels
if buySignal
label.new(bar_index, low, "BUY", color=color.green, textcolor=color.white, style=label.style_label_down, size=size.normal)
if sellSignal
label.new(bar_index, high, "SELL", color=color.red, textcolor=color.white, style=label.style_label_up, size=size.normal)