ドンチアン運河のトレンド追跡戦略

作者: リン・ハーンチャオチャン, 日付: 2023年11月6日 15:52:56
タグ:

img

概要

ドンチアンチャネルトレンドトラッキング戦略は,ドンチアンチャネル指標に基づくトレンドトラッキング戦略である.この戦略は,トレンドトラッキング取引のトレンド方向を決定するために,上,下,中帯を形成するために,異なる期間の最高高と最低低を計算する.

戦略の論理

戦略はまずバックテストの時間帯を設定し,その後,長目と短目エントリールールを定義します.

ロングポジションでは,価格がドンキアン・チャネル上部帯を超えるとロングを開く.価格が下部帯を超えるとロングを閉じる.

ショートポジションでは,価格がドンキアン・チャネルの下部帯を下回るとショートを開く.価格が上部帯を下回るとショート閉じる.

この戦略には,ストップ・ロスの出口メカニズムを設定するためのATRインジケーターも含まれています.ストップ・ロスのレベルとして,ATR値を係数で掛け算します.

長期ストップ損失は,入場価格からATRストップ損失値を引いた値であり,短期ストップ損失は,入場価格からATRストップ損失値を引いた値である.

この戦略は,ドンチアン運河の上下帯とATRストップ損失線を,完全な取引システムを形成するために描画しています.

利点

  • ドンチアン・チャネルを使って 傾向の方向を特定し 傾向を追跡する機能も備えています

  • ドンチアンチャネルスムーズパーマータは調整可能で,最適なパラメータ組み合わせを見つけるためにパラメータ最適化が可能です.

  • ATRによるストップ・ロスのメカニズムは,リスクを効果的に制御することができます.

  • 長いと短い取引ルールはシンプルで分かりやすいし,初心者にも適しています.

  • コード構造は明確で 分かりやすく 変更も可能です

リスク

  • ドンチアン運河は 価格変動の間には ショットソー取引があるかもしれません

  • ATRの停止損失範囲の設定が不適切である場合,停止損失が幅が広いか敏感すぎる可能性があります.

  • ロングとショートポジションは集中しすぎたため,ポジションのサイズのルールが必要になる.

  • 戦略は,異なる製品で適用可能性をテストし,パラメータを独立して最適化する必要があります.

  • 取引コストも考慮する必要があります 高コスト環境ではパラメータを調整する必要があります

増進 の 機会

  • ドンチアン運河の周期パラメータを最適化して 最適なパラメータ組み合わせを見つけます

  • ATR係数を試して 最適のストップ損失範囲を見つけます

  • ATRストップロスの上に ストップロスを導入して 利益を固定してみてください

  • 市場状況に基づいて,ロング/ショートポジション比を調整する.

  • 汎用パラメータを見つけるため,異なる製品でパラメータの強さをテストする.

  • 安定性を高めるためにMACDやその他のフィルターを組み込む研究.

  • 異なる取引コスト環境下でパラメータの適応性をテストする.

概要

概要すると,これはドンチアンチャネルの適用を中心とした比較的単純なトレンド追跡戦略である.その利点は,学習目的に適したシンプルさと理解しやすさにあるが,パラメータとリスクはまださらなる最適化が必要である.多様な強化技術により,戦略の安定性と収益性は潜在的に改善される可能性がある.


/*backtest
start: 2022-10-30 00:00:00
end: 2023-11-05 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kriswaters

//@version=4
strategy("Donchian Channels Strategy by KrisWaters", overlay=true ) 

// Date filter
FromDay   = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromYear  = input(defval = 2017, title = "From Year", minval = 1900)
ToDay     = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToMonth   = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToYear    = input(defval = 9999, title = "To Year", minval = 2017)

start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window
finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)        // backtest finish window
window()  => true // create function "within window of time"

// Strategy Settings
canEnterLong = input(true, title="Can Enter Long Position")
canEnterShort = input(false, title="Can Enter Short Position")

showLongChannel = input(true, title="Show Donchian Long Channels")
showShortChannel = input(false , title="Show Donchian Short Channels")

useAtrAsStopRule = input(false, title="Enable ATR Stop Rule") 

// DonCcian Channel Lengths
longUpperLength = input(20, minval=1)
longLowerLength = input(10, minval=1)

shortUpperLength = input(10, minval=1)
shortLowerLength = input(20, minval=1)

// Donchian indicator calculations
longUpperValue = highest(high,longUpperLength)
longLowerValue = lowest(low,longLowerLength)

shortUpperValue = highest(high,shortUpperLength)
shortLowerValue = lowest(low,shortLowerLength)

// Plot Donchian Channels
uLong = plot(showLongChannel ? longUpperValue : na, color=color.green, offset=1)
lLong = plot(showLongChannel ? longLowerValue : na, color=color.green, offset=1)

uShort = plot(showShortChannel ? shortUpperValue : na, color=color.red, offset=1)
lShort = plot(showShortChannel ? shortLowerValue : na, color=color.red, offset=1)

// Styling
fill(uLong,lLong, color=color.green, transp=95, title="Long Arkaplan")
fill(uShort,lShort, color=color.red, transp=95, title="Short Arkaplan")

// Stop-loss value calculations
atrMultiplier = 2.0
atrValue = atr(20)
longStopValue = open - (atrMultiplier*atrValue)
shortStopValue = open + (atrMultiplier*atrValue)

// Plot stop-loss line
plot(useAtrAsStopRule ? longStopValue : na, color=color.red, linewidth=2, offset=1)
plot(useAtrAsStopRule ? shortStopValue : na, color=color.red, linewidth=2, offset=1)

// Long and Short Position Rules
if canEnterLong and na(longUpperValue) != true and na(longLowerValue) != true and window()
    strategy.entry("Long", true, stop=longUpperValue)
    strategy.exit("Long Exit", "Long", stop=useAtrAsStopRule ? max(longLowerValue,longStopValue) : longLowerValue)
    
if canEnterShort and na(shortUpperValue) != true and na(shortLowerValue) != true and window()
    strategy.entry("Short", false, stop=shortLowerValue)
    strategy.exit("Short Exit", "Short", stop=useAtrAsStopRule ? min(shortUpperValue,shortStopValue) : shortUpperValue)
    


もっと