この戦略は,唐津通路とSMPの2つの技術指標を組み合わせている.価格が唐津通路の下軌道に突破し,SMPより高いときに多ポジションを開く,価格が唐津通路上軌道に突破し,SMPより低いときに空白ポジションを開く.多ポジションは価格が唐津通路上軌道に触れたときに平仓,空頭ポジションは価格が唐津通路下軌道に触れたときに平仓する.この戦略は,傾向が強い市場に適用される.
ダイナミック・ドンチアン・チャネルとシンプル・ムービング・アベアンの組み合わせ戦略は,簡単に使いやすい量化取引戦略の枠組みである.それは,トレンド・トラッキングとボリュレント・ブレイクという2つの角度から平仓の論理を構築し,強いトレンド性のある品種に適している.しかし,この戦略は,頻繁に変動する市場ではうまく機能せず,パラメータの安定性が一般的である.補助的なポジション開設条件,ダイナミック・ストップとパラメータ自数適応メカニズムを導入することによって,この戦略の適応性と強さを向上させることができる.全体的に,この戦略は,基礎戦略の枠組みとして,この基礎をさらに改修して,より高度な量化戦略を構築することができる.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("FBK Donchian Channel Strategy", overlay=true)
// Inputs
donchian_period = input.int(20, title="Donchian Channel Period")
donchian_offset = input.int(1, title="Donchian Channel Offset")
sma_period = input.int(200, title="SMA Period")
start_date = input(timestamp("2023-01-01 00:00 +0000"), title="Start Date")
end_date = input(timestamp("2023-12-31 23:59 +0000"), title="End Date")
trade_type = input.string("Both", title="Trade Type", options=["Buy Only", "Sell Only", "Both"])
// Calculate indicators
donchian_upper = ta.highest(high, donchian_period)[donchian_offset]
donchian_lower = ta.lowest(low, donchian_period)[donchian_offset]
sma = ta.sma(close, sma_period)
// Plot indicators
plot(donchian_upper, color=color.red, title="Donchian Upper")
plot(donchian_lower, color=color.green, title="Donchian Lower")
plot(sma, color=color.blue, title="SMA")
// Helper function to check if within testing period
is_in_testing_period() => true
// Entry conditions
long_condition = low <= donchian_lower and close > sma
short_condition = high >= donchian_upper and close < sma
// Exit conditions
exit_long_condition = high >= donchian_upper
exit_short_condition = low <= donchian_lower
// Open long position
if (is_in_testing_period() and (trade_type == "Buy Only" or trade_type == "Both") and long_condition)
strategy.entry("Long", strategy.long)
// Close long position
if (is_in_testing_period() and exit_long_condition)
strategy.close("Long")
// Open short position
if (is_in_testing_period() and (trade_type == "Sell Only" or trade_type == "Both") and short_condition)
strategy.entry("Short", strategy.short)
// Close short position
if (is_in_testing_period() and exit_short_condition)
strategy.close("Short")
// Close all positions at the end of the testing period
if not is_in_testing_period()
strategy.close_all()