
この策略は,ドンチアンチャネルに基づく海取引策略と呼ばれています.この策略は,有名な海取引法典の主要な思想を汲み取り,ドンチアンチャネルを介して市場動向を判断し,移動平均と組み合わせたフィルタリングを行い,比較的単純なトレンド追跡策略を実現しています.
この戦略の主な判断指標はDonchian channelである.Donchian channelは,最高価格と最低価格のN日間の波動範囲で構成され,価格がチャネルを突破すると,長信号で,下破ると,短信号で.この戦略は,速いDonchian channel ((10日) を使って信号を発信し,遅いDonchian channel ((20日) を使って止損する.
さらに,この戦略は,2つの移動平均 ((50日線と125日線) を導入して,シグナルをフィルターします. 複数の取引は,高速移動平均線上を通過するときにのみ行われます. 空頭取引は,高速移動平均線の下を通過するときに行われます. これは,部分的に偽の信号を効果的にフィルターします.
この戦略の開設条件は,価格がドンチアンチャネルを上線して,急速な移動平均を遅い移動平均を上線して,この2つの条件を満たすだけなら多項を開くことができる.価格がドンチアンチャネルを下線して,急速な移動平均を遅い移動平均を下線して,空券を開く.平仓条件は,価格が逆の方向の遅いドンチアンチャネル境界に触れるためである.
この戦略の利点は以下の通りです.
ドンチアンチャネルはトレンドの方向を判断し,トレンドをうまく捉えることができました.
移動平均のフィルタリングを追加し,偽信号をフィルターし,損失を回避します.
取引頻度とストップ・ロスの精度をバランスさせるための,スロー・ドンチアン・チャネルとスロー・ムービング・アベアンの組み合わせ.
リスク管理が整っており,単一損失を抑えるためのストップ・ローズ・メカニズムがあります.
この戦略にはいくつかのリスクがあります.
震災の時には,より小さな損失が起こる可能性があります.
移動平均のフィルタリングは,トレンドが逆転したときに倉庫建設コストを上げます.
の場合,止損が追及される場合がある.
対応策と解決策:
Donchian周期を短縮し,移動平均周期を低減して異なる市場に対応するためにパラメータを適切に調整できます.
大規模なトレンドの判断を高め,逆のトレンドの準備を避ける.
この戦略は以下の点で最適化できます.
突破力の判断を高めること.例えば,取引量を導入し,取引量が大きくなった場合にのみポジションを開くこと.
熱点区域の判断を増加させる. サポート圧力位,波段,パターンなどの判断価格熱点,熱点区域の倉庫建設を回避する.
ストップを最適化する戦略. ストップをスマートにするために,追跡ストップ,振幅ストップ,時間ストップなどを導入できます.
この戦略は,全体として非常に典型的でシンプルなトレンド追跡戦略である.ドンチアン通路による判断方向,移動平均フィルター信号により,優れた反測効果を実現している.この戦略は,大きなトレンドを追求する投資家に適しており,リスクがコントロールされ,実地での操作が容易である.いくつかのパラメータとルールの最適化により,戦略の勝利率と収益性をさらに向上させることができる.
/*backtest
start: 2023-11-24 00:00:00
end: 2023-12-24 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
// Coded by Vladkos
strategy("Donchian strategy with filter", overlay=true,default_qty_type = strategy.percent_of_equity, default_qty_value = 4,pyramiding=5)
fromyear = input(2017, defval = 2018, minval = 1800, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(21, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
term = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59))
ATR=input(20,minval=1)
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
needstoploss= input(true,defval=true,title="Stop LOSS")
///////////ATR
tra=atr(ATR)
////////////Переменные
Donchian_slow=input(20,minval=1)
Donchian_fast=input(10,minval=1)
Slow_EMA=input(125,minval=1)
Fast_EMA=input(50,minval=1)
/////////// Медленный Дончан
lower = lowest(Donchian_slow)
upper = highest(Donchian_slow)
basis = avg(upper, lower)
plot(lower,color=blue)
plot(upper,color=blue)
/////////// быстрый Дончан
lowerF = lowest(Donchian_fast)
upperF = highest(Donchian_fast)
basisF = avg(upperF, lowerF)
plot(lowerF,color=red)
plot(upperF,color=red)
////////// Скользящие средние
ema_S=ema(close,Slow_EMA)
ema_F=ema(close,Fast_EMA)
plot(ema_S,color=red)
plot(ema_F,color=green)
///////// Условия сделок
long_condition= close>=upper[1] and ema_F>ema_S
long_exit= close<lowerF[1]
short_condition=close<=lower[1] and ema_F<ema_S
short_exit=close>upperF[1]
////////// Отправка ордеров
strategy.entry("Long",strategy.long,when=long_condition and term and needlong==true)
strategy.exit("stop loss","Long",stop=strategy.position_avg_price-(tra*2),when= (needstoploss==true))
strategy.close("Long",when=long_exit and (time < timestamp(toyear, tomonth, today, 23, 59)))
strategy.entry("Short",strategy.short,when=short_condition and term and (needshort==true))
strategy.exit("stoploss","Short",stop=strategy.position_avg_price+(tra*2),when= (needstoploss==true))
strategy.close("Short",when=short_exit and (time < timestamp(toyear, tomonth, today, 23, 59)))
if time > timestamp(toyear, tomonth, today, 23, 59)
strategy.close_all()