
この戦略は,チャネルブレイク理論に基づいて設計されたトレンド追跡戦略である.これは,特定の周期の最高価格と最低価格を計算してチャネルを構築し,価格がチャネルを突破すると取引信号を生成する.この戦略は,トレンド行動に適用され,価格のトレンド方向を捉え,トレンド追跡を行う.
この戦略は,まず,長さである周期内の最高値と最低値を計算し,通路の上軌道と下軌道を構築する. 閉盘価格が上軌道を破るとき,多めにする. 閉盘価格が下軌道を破るとき,空っぽにする. 閉盘価格が通路の中に戻るため,平仓条件である.
この策略は,長さをlengthにマッピングします.*2のEMA指標はトレンドの方向を判断する. 価格がチャネルを突破して軌道に乗ったとき,EMAが上昇傾向にある場合,多意思決定の効果を高める.
この戦略は,全体として,チャネルブレークアウトをベースにトレンドをキャプチャする簡単なトレンド追跡戦略である.これは,トレンドを追跡する強力な能力があり,トレンドの状況で良い収益を得ることができます.しかし,一定のリスクがあり,安定性を高めるためにさらに最適化する必要があります.パラメータ調整,ストップ・損失設定,および他の指標判断により,この戦略は,実際の取引に適用できます.
/*backtest
start: 2023-11-15 00:00:00
end: 2023-11-22 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
initial_capital = 1000,
default_qty_value = 90,
default_qty_type = strategy.percent_of_equity,
pyramiding = 0,
commission_value = 0.002,
commission_type = strategy.commission.percent,
calc_on_every_tick = true
length_val = 2
max_bars_back = 1440
risk_max_drawdown = 9
strategy("Channel Break",max_bars_back=max_bars_back,initial_capital = initial_capital,default_qty_value = default_qty_value,default_qty_type = default_qty_type,pyramiding = pyramiding,commission_value = commission_value,commission_type = commission_type,calc_on_every_tick = calc_on_every_tick)
// strategy.risk.max_drawdown(risk_max_drawdown, strategy.percent_of_equity)
length = input(title="Length", minval=1, maxval=1000, defval=length_val)
upBound = highest(high, length)
downBound = lowest(low, length)
//plot (upBound)
//plot (downBound)
//plot (close, color=red)
//plot (ema(close,length * 2), color=green)
//
if (not na(close[length]) and time>timestamp(2018, 02, 24, 0, 00) )
strategy.entry("Buy", strategy.long, stop=upBound + syminfo.mintick, comment="Buy")
strategy.entry("Short", strategy.short, stop=downBound - syminfo.mintick, comment="Short")
position = strategy.position_size
//plot(position , title="equity", color=red,style=cross,linewidth=4)
plot(variance(position,2)>0?1:0,style=circles,linewidth=4)
message = ""
if (position > 0)
message = "BTCUSD L: " + tostring(strategy.position_size)
na(position)
if (position < 0)
message = "BTCUSD S: " + tostring(strategy.position_size)
na(position)
alertcondition(variance(strategy.position_size,2) > 0, "test", message )