볼링거 밴드와 DCA를 결합한 고주파 거래 전략

저자:차오장, 날짜: 2024-03-29 16:20:13
태그:

img

전반적인 설명

DCA 부스터 (DCA Booster, 1분) 는 1분 단위로 동작하는 고주파 트레이딩 전략이다. 이 전략은 볼링거 밴드 (Bollinger Band) 와 달러 비용 평균 (Dollar-Cost Averaging, DCA) 기법을 결합하여 수익을 창출하기 위해 여러 가지 구매 및 판매를 통해 시장 변동을 활용한다. 이 전략의 주요 아이디어는: 가격이 두 차례 연속적으로 낮은 볼링거 밴드 (Bollinger Band) 이하로 떨어지면 DCA를 사용하여 포지션을 구축하기 시작하며, 가격이 상위 볼링거 밴드 (Bollinger Band) 이상으로 상승하면 모든 포지션을 폐쇄한다. 또한, 이 전략은 피라미딩을 허용하며, 이는 가격이 계속 떨어지면 포지션을 추가할 수 있다는 것을 의미한다.

전략 원칙

  1. 볼링거 밴드 계산: 간단한 이동 평균과 표준편차를 사용하여 볼링거 밴드의 상부와 하부 밴드를 계산합니다.
  2. DCA 매개 변수를 설정: 고정된 금액을 여러 부분으로 나누고, 각 포지션의 자본으로 사용됩니다.
  3. 진입 조건: 닫기 가격이 2 개의 연속 기간 동안 낮은 볼링거 밴드 아래로 떨어지면 포지션을 구축하기 시작합니다. 가격이 낮은 밴드 아래로 계속 유지되는지에 따라 전략은 최대 5 개의 포지션을 설정할 수 있습니다.
  4. 출구 조건: 가격이 상단 볼링거 밴드를 넘으면 모든 포지션을 닫습니다.
  5. 피라미딩: 가격이 계속 하락하면 전략은 최대 5개의 포지션을 추가합니다.
  6. 포지션 관리: 전략은 각 포지션의 입상 상태를 기록하고 출구 조건이 충족되면 해당 포지션을 종료합니다.

전략적 장점

  1. 볼링거 밴드와 DCA 기술을 결합함으로써 전략은 시장 변동성을 효과적으로 파악하고 평균 구매 비용을 줄일 수 있습니다.
  2. 피라미딩을 허용하면 가격이 계속 하락할 때 전략이 계속해서 포지션을 쌓을 수 있고 수익률을 높일 수 있습니다.
  3. 탈퇴 조건은 간단하고 직설적이어서 빠른 수익을 얻을 수 있습니다.
  4. 1분 같은 짧은 시간 내에 사용하기에 적합하며, 고주파 거래가 가능합니다.

전략 위험

  1. 시장이 급격하게 변동하고 가격이 빠르게 상부 볼링거 밴드를 뚫면 전략은 당시에 포지션을 닫을 수 없을 수 있으며 손실이 발생할 수 있습니다.
  2. 피라미딩은 가격이 계속 떨어지면 과잉 노출로 이어질 수 있고, 위험도 증가합니다.
  3. 이 전략은 불안정한 시장에서 잘 작동하지 않을 수 있습니다. 자주 구매 및 판매가 높은 거래 비용을 발생시킬 수 있기 때문입니다.

전략 최적화 방향

  1. 거래 당 최대 손실을 제어하기 위해 출구 조건에 스톱 로스를 추가하는 것을 고려하십시오.
  2. 피라미드 로직을 최적화합니다. 예를 들어 가격 하락의 크기에 따라 포지션 크기를 조정하여 과잉 노출을 피합니다.
  3. 입출동의 정확성을 높이기 위해 RSI와 MACD와 같은 다른 지표를 포함합니다.
  4. 다양한 시장 조건에 적응하기 위해 볼링거 밴드의 기간 및 표준편차 곱셈자와 같은 매개 변수를 최적화합니다.

요약

DCA 부스터 (DCA Booster, 1분) 는 볼링거 밴드 (Bollinger Band) 와 DCA를 결합한 고주파 트레이딩 전략이다. 가격이 낮은 볼링거 밴드 (Bollinger Band) 이면 포지션을 구축하고 상위 볼링거 밴드 (Bollinger Band) 이면 포지션을 폐쇄하여 수익을 창출하는 것을 목표로 한다. 이 전략은 피라미딩을 허용하지만 급격한 시장 변동성 및 과잉 노출과 같은 위험에 직면한다. 스톱 로스를 도입하고, 피라미딩 논리를 최적화하고, 다른 지표를 통합하고, 매개 변수를 최적화함으로써 이 전략의 성능을 더욱 향상시킬 수 있다.


/*backtest
start: 2024-02-27 00:00:00
end: 2024-03-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("DCA Booster (1 minute)",
  overlay=true )

// Parameters for Bollinger Bands
length = input.int(50, title="BB Length")
mult = input.float(3.0, title="BB Mult")

// Bollinger Bands calculation
basis = ta.sma(close, length)
dev = mult * ta.stdev(close, length)
upper = basis + dev
lower = basis - dev

// Variables for DCA
cantidad_dolares = 50000
orden1 = cantidad_dolares / close
orden2 = orden1 * 1.2
orden3 = orden2 * 1.3
orden4 = orden3 * 1.5
orden5 = orden4 * 1.5

// Variables for tracking purchases
var comprado1 = false
var comprado2 = false
var comprado3 = false
var comprado4 = false
var comprado5 = false

// Buy conditions
condicion_compra1 = close < lower and close[1] < lower[1] and not comprado1
condicion_compra2 = close < lower and close[1] < lower[1] and comprado1 and not comprado2
condicion_compra3 = close < lower and close[1] < lower[1] and comprado2 and not comprado3
condicion_compra4 = close < lower and close[1] < lower[1] and comprado3 and not comprado4
condicion_compra5 = close < lower and close[1] < lower[1] and comprado4 and not comprado5
// Variables de control
var int consecutive_closes_below_lower = 0
var int consecutive_closes_above_upper = 0

// Entry logic
if condicion_compra1 and barstate.isconfirmed
    consecutive_closes_below_lower := consecutive_closes_below_lower + 1
    if consecutive_closes_below_lower >= 2
        strategy.entry("Compra1", strategy.long, qty=orden1)
        comprado1 := true
        consecutive_closes_below_lower := 0

if condicion_compra2 and barstate.isconfirmed
    consecutive_closes_below_lower := consecutive_closes_below_lower + 1
    if consecutive_closes_below_lower >= 2
        strategy.entry("Compra2", strategy.long, qty=orden2)
        comprado2 := true
        consecutive_closes_below_lower := 0

if condicion_compra3 and barstate.isconfirmed
    consecutive_closes_below_lower := consecutive_closes_below_lower + 1
    if consecutive_closes_below_lower >= 2
        strategy.entry("Compra3", strategy.long, qty=orden3)
        comprado3 := true
        consecutive_closes_below_lower := 0

if condicion_compra4 and barstate.isconfirmed
    consecutive_closes_below_lower := consecutive_closes_below_lower + 1
    if consecutive_closes_below_lower >= 2
        strategy.entry("Compra4", strategy.long, qty=orden4)
        comprado4 := true
        consecutive_closes_below_lower := 0

if condicion_compra5 and barstate.isconfirmed
    consecutive_closes_below_lower := consecutive_closes_below_lower + 1
    if consecutive_closes_below_lower >= 2
        strategy.entry("Compra5", strategy.long, qty=orden5)
        comprado5 := true
        consecutive_closes_below_lower := 0


// Sell conditions
if close > upper  and comprado1 and barstate.isconfirmed
    strategy.close("Compra1")
    comprado1 := false

if close > upper  and comprado2 and barstate.isconfirmed
    strategy.close("Compra2")
    comprado2 := false

if close > upper  and comprado3 and barstate.isconfirmed
    strategy.close("Compra3")
    comprado3 := false

if close > upper and comprado4 and barstate.isconfirmed
    strategy.close("Compra4")
    comprado4 := false

if close > upper and comprado5 and barstate.isconfirmed
    strategy.close("Compra5")
    comprado5 := false



더 많은