
この戦略の核心構想は,唐通路の価格突破状況に基づいて取引を行うことであり,トレンド追跡型の量化戦略である.これは,価格通路を自動的に識別し,価格が通路の突破に沿ってポジションを開くことができ,価格が通路の下沿いの近くまたは止損点に戻ると平仓する.この戦略は,中長線の価格トレンドを捕捉することを目的としており,株式指数などの金融デリバティブのアルゴリズム取引に適用される.
この戦略は,唐通道指数に基づいており,唐通道は,与えられた周期内の最高価格と最低価格で描かれた通道領域である.その計算方法は:
軌道上 = 近 n サイクル間の最高値 下線 = 近 n 周期間の最低値
価格が上線を突破すると多頭トレンドに入ると考えられ,価格が下線を突破すると空頭トレンドに入ると考えられる。この戦略は上線を突破した場合にのみ考慮される。
取引の論理は以下の通りです.
この戦略の利点は以下の通りです.
この戦略にはいくつかのリスクがあります.
対応方法:
この戦略は,以下の点で最適化できます.
この戦略の全体的な考え方は明確で,理解しやすく,実行しやすく,成熟した唐津通道指標を利用してトレンドの方向を自動的に識別する.同時に,配置は柔軟で,実際の需要に応じて調整することができる.止損とパラメータの最適化により,よりよい効果を得ることができる.全体的に,この戦略は,操作が容易で,一定の効率性を持ち,量化取引の入門戦略の一つとして適している.
/*backtest
start: 2022-12-07 00:00:00
end: 2023-12-07 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/
// © Giovanni_Trombetta
// Strategy to capture price channel breakouts
//@version=4
strategy("ChannelsBreakout", max_bars_back=50, overlay=true)
instrument = input(1, title = "Select 1: Stock/Forex, 2: Future")
money = input(10000, title = "Money for each trade")
backtest_start = input(2000, "Insert first year to backtest")
period = input(50, title = "Period in bars of Donchian Channel")
monetary_stoploss = input(1000, title = "Monetary Stop Loss")
quantity = if instrument != 1
1
else
int(money / close)
upBarrier = highest(high,period)
downBarrier = lowest(low,period)
up = highest(high,period / 4)
down = lowest(low,period / 4)
plot(upBarrier, color=color.green, linewidth=2)
plot(downBarrier, color=color.red, linewidth=2)
plot(up, color=color.lime, linewidth=1)
plot(down, color=color.orange, linewidth=2)
longCondition = crossover(close, upBarrier[1]) and year >= backtest_start
if (longCondition)
strategy.entry("Long", strategy.long, quantity, when = strategy.position_size == 0)
closeCondition = crossunder(close, down[1]) or down < down[1]
if (closeCondition)
strategy.close("Long", comment = "Trailing")
stop_level = strategy.position_avg_price - monetary_stoploss / strategy.position_size
strategy.exit("StopLoss", from_entry = "Long", stop = stop_level)
plot(stop_level, color=color.yellow, linewidth=2)
// l = label.new(bar_index, na,
// text="PineScript Code", color= color.lime, textcolor = color.white,
// style=label.style_labelup, yloc=yloc.belowbar, size=size.normal)
// label.delete(l[1])