
이 전략은 변동률 기반의 동적 선택시 거래 시스템으로, 트렌드 추적과 위험 관리의 특징을 결합한다. 전략의 핵심은 변동률 채널을 통해 시장 추세 변화를 식별하는 것이며, 동시에 ATR 기반의 동적 포지션 관리 메커니즘을 도입하여 거래 위험에 대한 정확한 통제를 구현한다. 이 전략은 특히 변동성이 높은 시장 환경에서 작동하기 위해 적합하며, 시장의 변동성에 적응하여 포지션을 조정한다.
전략의 핵심 논리는 다음과 같은 핵심 구성 요소를 기반으로 합니다.
이것은 변동률, 트렌드 추적 및 위험 관리를 결합한 완전한 거래 시스템입니다. 전략은 변동률 채널을 통해 트렌드 변화를 포착하고 과학적인 자금 관리 방법을 사용하여 위험을 통제합니다. 불안정한 시장에서 좋지 않은 성능을 보일 수 있지만 합리적인 변수 최적화 및 추가 필터링 메커니즘을 통해 대부분의 시장 환경에서 안정적으로 작동 할 수 있습니다. 전략의 핵심 장점은 자율성과 위험 제어 능력으로 협력 중장기 전략의 기본 틀을 확장하고 최적화 할 수 있습니다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("BNF FUT 5 min Volatility Strategy", overlay=true)
// Inputs
length = input.int(20, "Length", minval=2)
src = input.source(close, "Source")
factor = input.float(2.0, "Multiplier", minval=0.25, step=0.25)
initial_capital = input.float(100000, "Initial Capital ($)")
risk_per_trade = input.float(1.0, "Risk per Trade (%)", minval=0.1, maxval=10.0)
// Volatility Stop Function
volStop(src, atrlen, atrfactor) =>
if not na(src)
var max = src
var min = src
var uptrend = true
var float stop = na
atrM = nz(ta.atr(atrlen) * atrfactor, ta.tr)
max := math.max(max, src)
min := math.min(min, src)
stop := nz(uptrend ? math.max(stop, max - atrM) : math.min(stop, min + atrM), src)
uptrend := src - stop >= 0.0
if uptrend != nz(uptrend[1], true)
max := src
min := src
stop := uptrend ? max - atrM : min + atrM
[stop, uptrend]
// Calculate Volatility Stop
[vStop, uptrend] = volStop(src, length, factor)
// Plot Volatility Stop
plot(vStop, "Volatility Stop", style=plot.style_cross, color=uptrend ? #009688 : #F44336)
// Risk Management and Position Sizing
atr = ta.atr(length)
stop_distance = math.abs(close - vStop) // Distance to stop level
position_size = (initial_capital * (risk_per_trade / 100)) / stop_distance // Position size based on risk per trade
position_size := math.max(position_size, 1) // Ensure minimum size of 1
// Strategy Logic
if not na(vStop)
if uptrend and not uptrend[1] // Transition to uptrend
strategy.close("Short")
strategy.entry("Long", strategy.long, qty=position_size)
if not uptrend and uptrend[1] // Transition to downtrend
strategy.close("Long")
strategy.entry("Short", strategy.short, qty=position_size)
// Exit on Stop Hit
if strategy.position_size > 0 and low < vStop // Exit long if stop hit
strategy.close("Long", comment="Stop Hit")
if strategy.position_size < 0 and high > vStop // Exit short if stop hit
strategy.close("Short", comment="Stop Hit")
if (hour == 15 and minute == 15)
strategy.close_all()