
이 전략은 채널 브레이크 이론을 기반으로 설계된 트렌드 추적 전략이다. 일정 주기 동안의 최고 가격과 최저 가격을 계산하여 채널을 구축하고, 가격이 채널을 뚫을 때 거래 신호를 발생시킨다. 이 전략은 트렌드 동작에 적용되며, 가격의 트렌드 방향을 포착하여 트렌드 추적을 한다.
이 전략은 먼저 길이의 주기 내의 최고 가격과 최저 가격을 계산하여 통로 상궤와 하궤를 구성한다. 상궤를 돌파할 때, 더 많이 한다. 상궤를 돌파할 때, 공백을 한다. 평점 조건으로 상궤가 다시 통로 내로 떨어진다.
이 전략은 length를*2의 EMA 지표는 트렌드 방향을 판단한다. 가격이 통로를 돌파할 때, EMA가 상승 추세에 있다면, 다중 의사 결정의 효과를 강화한다.
이 전략은 전체적으로 channel breakouts to capture trends에 기반한 간단한 트렌드 추적 전략이다. 그것은 강한 트렌드 추적 능력을 가지고 있으며, 트렌드 상황에서 좋은 수익을 얻을 수 있다. 그러나 또한 특정 위험이 있으며, 안정성을 높이기 위해 추가 최적화가 필요합니다.
/*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 )