コントリアン ドンチアンチャネルタッチエントリー戦略

作者: リン・ハーンチャオチャン開催日: 2024-01-24 15:07:18
タグ:

img

概要

コントラリアンドンキアンチャネルタッチエントリー戦略は,ドンキアンチャネル指標に基づいた定量的な取引戦略である.リスク管理のためにストップ・ロスの一時停止とトライリング・ストップ・ロスを組み込む.

この戦略は,価格がドンチアンチャネル上下帯に触るとロング/ショートポジションに入ります.ストップ・ロストとテイク・プロフィートのレベルは,各取引に設定されます.ストップ・ロストがヒットした後,同じ方向に新しい取引を行う前に数バーの停止があります.取引中に,トライリング・ストップ・ロスは,利益をロックするために使用されます.

戦略の論理

この戦略は,上部帯,下部帯,中部線からなる20期ドンチアン運河を使用しています.

エントリー論理

価格が下位帯に触れたらロング,上位帯に触れたらショート.

前回のストップ損失を同じ方向にすると,トレンドを追いかけるのを避けるため,一時停止 (例えば3バー) が必要です.

損失 を 止めて 利益 を 得る

各取引に対して,固定したストップ損失率 (例: 22%) と,リスク/報酬比 (例: 2) に基づいて計算されるダイナミック・テイク・プロフィート (例: 22%) を設定します.

追尾停止損失

トレーリング・ストップ・ロスは,

長取引の場合,価格が中間線を超えると,ストップロスをエントリー価格と中間線の真ん中に調整します.

中間線を下に切るショートポジションでは逆です.

利点

  1. ドンチアン運河の 突破口を使って トレンドの動きを捉える

  2. トレンドに逆らって取引する

  3. ストップ・ロスの停止とトラッキング・ストップによる効果的なリスク管理

  4. 明確で実行しやすいルール

リスク

  1. 市場を横切って 傾向に則ったシステムを作る

  2. 固定ストップロスは 早期に停止される可能性があります

  3. 過度に積極的な遅延ストップ調整は 利潤のある取引を早すぎに 打ち消す可能性があります

  4. パラメータの最適化は極めて重要です

増進 の 機会

  1. 最適なパラメータを 確保するために ドンチアン運河の 復旧期間を最適化します

  2. 位置のサイズ設定規則を組み込む.例えば,一時停止数を定期的にリセットする.

  3. 偽のブレイクを避けるために他の指標を用いたフィルターを追加します

  4. ダイナミックストップ損失実験

概要

Contrarian Donchian Channel Touch Entry Strategyは,トレンド識別,リスク管理などを統合している.さらなるパラメータ調整と他のモデルとの組み合わせにより,経験豊富なトレーダーにとってより強固性と収益性を達成することができる.


/*backtest
start: 2023-01-17 00:00:00
end: 2024-01-23 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Contrarian Donchian Channel Strategy - Touch Entry with Post-SL Pause and Trailing Stop", overlay=true, default_qty_value=0.01, default_qty_type=strategy.percent_of_equity)

// Inputs
length = input(20, minval=1, title="Donchian Channel Length")
riskRewardRatio = input(2, title="Risk/Reward Ratio")
stopLossPercent = input(0.22, title="Stop Loss (%)") / 100
pauseCandles = input(3, minval=1, title="Pause After SL (Candles)")

// Donchian Channel Calculation
upper = highest(high, length)
lower = lowest(low, length)
centerline = (upper + lower) / 2  // Calculating the Centerline

// Plotting Donchian Channel and Centerline
plot(upper, color=color.red, title="Upper Band")
plot(lower, color=color.green, title="Lower Band")
plot(centerline, color=color.blue, title="Centerline")

// Tracking Stop Loss Hits and Pause
var longSLHitBar = 0
var shortSLHitBar = 0
var int lastTradeDirection = 0 // 1 for long, -1 for short, 0 for none

// Update SL Hit Bars
if (strategy.position_size[1] > 0 and strategy.position_size == 0)
    if (close[1] < strategy.position_avg_price[1])
        longSLHitBar := bar_index
        lastTradeDirection := 1

if (strategy.position_size[1] < 0 and strategy.position_size == 0)
    if (close[1] > strategy.position_avg_price[1])
        shortSLHitBar := bar_index
        lastTradeDirection := -1

// Entry Conditions - Trigger on touch
longCondition = (low <= lower) and (bar_index - longSLHitBar > pauseCandles or lastTradeDirection != 1)
shortCondition = (high >= upper) and (bar_index - shortSLHitBar > pauseCandles or lastTradeDirection != -1)

// Trade Execution
if (longCondition)
    strategy.entry("Long", strategy.long)
if (shortCondition)
    strategy.entry("Short", strategy.short)

// Initial Stop Loss and Take Profit Calculation
stopLoss = strategy.position_avg_price * (1 - stopLossPercent)
takeProfit = strategy.position_avg_price * (1 + stopLossPercent * riskRewardRatio)

// Trailing Stop Loss Logic
var float trailingStopLong = na
var float trailingStopShort = na

// Update Trailing Stop for Long Position
if (strategy.position_size > 0)
    if (close > centerline)
        trailingStopLong := (strategy.position_avg_price + centerline) / 2
    stopLoss := na(trailingStopLong) ? stopLoss : max(trailingStopLong, stopLoss)

// Update Trailing Stop for Short Position
if (strategy.position_size < 0)
    if (close < centerline)
        trailingStopShort := (strategy.position_avg_price + centerline) / 2
    stopLoss := na(trailingStopShort) ? stopLoss : min(trailingStopShort, stopLoss)

// Setting Stop Loss and Take Profit for each trade
strategy.exit("SL_TP_Long", "Long", stop=stopLoss, limit=takeProfit)
strategy.exit("SL_TP_Short", "Short", stop=stopLoss, limit=takeProfit)


もっと