볼링거 밴드를 사용하는 다중 시간 프레임 거래 전략

저자:차오장, 날짜: 2023-09-20 15:47:46
태그:

전반적인 설명

이 전략은 적응적인 볼링거 밴드를 사용하여 두 가지 유형의 트레일링 스톱 전략을 설계하고 시간 프레임에 걸쳐 체계적으로 백테스트합니다. 트렌드를 따르는 전략에 속합니다.

전략 논리

  1. 조정 가능한 채널 너비의 적응형 볼린저 밴드의 상단 및 하단 밴드를 계산합니다.

  2. 브레이크오웃 추적 전략은 밴드 브레이크오웃에서 포지션을 열고, 가격이 밴드 내에서 역전될 때 멈추는 것입니다.

  3. 역전 역전 전략은 가격이 범위에 도달하면 포지션을 열고 가격이 범위에 돌아 올 때 중지합니다.

  4. CCI 지표를 사용하여 긴/단면을 결정하는 데 도움이 됩니다.

  5. 두 전략의 실행 가능성을 확인하기 위해 여러 시간 프레임에 걸쳐 백테스트

장점

  1. 볼링거 밴드는 가격 트렌드를 직관적으로 파악합니다.

  2. 두 전략은 안정성을 위해 다른 시장 조건에 적합합니다.

  3. CCI는 길고 짧은 방향을 결정하는데 도움이 됩니다.

  4. 다중 시간 프레임 백테스팅은 결과를 더 설득력 있게 만듭니다.

  5. 간단하고 명확한 전략 규칙

위험성

  1. 볼링거 밴드는 특정 상황에서 실패할 수 있습니다.

  2. 두 가지 전략에서 조기 또는 지연 중단의 위험.

  3. CCI는 잘못된 신호를 생성할 수 있습니다.

  4. 백테스트의 편견을 조심스럽게 다루세요.

  5. 최적화는 너무 적합할 위험이 있습니다.

강화

  1. 최적의 조합을 찾기 위한 테스트 매개 변수

  2. 다른 지표와 함께 필터를 추가하는 것을 평가하십시오.

  3. 위험을 줄이기 위해 정차를 최적화하십시오.

  4. 채널 너비에 대한 적응적인 방법을 연구합니다.

  5. 더 많은 기호와 시간 프레임으로 확인하세요.

  6. 매개 변수를 동적으로 최적화하기 위해 기계 학습을 사용하세요.

결론

이 전략은 볼링거 밴드를 기반으로 두 개의 트레일링 스톱 전략을 설계하고 여러 시간 프레임에 걸쳐 백테스트합니다. 매개 변수 최적화, 스톱 개선 등을 통해 정제하면 성숙한 트렌드 다음 시스템으로 견고함을 향상시킬 수 있습니다.


/*backtest
start: 2022-09-13 00:00:00
end: 2023-09-19 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy(title = "Underworld Hunter", overlay=true)

len = input(75, minval=1, title="Length")
src = input(close, title="Source")
basis = 0.0
basis := na(basis[1]) ? sma(src, len) : ema(ema(ema(src,len),len),len)

mult = input(1.9, minval=0.001, maxval=50, title="Deviation")
dev = mult * stdev(src, len)
upper = basis + dev
lower = basis - dev

//CCI calculation and inputs

lengthcci = input(20, minval=1, title="Period for CCI")
ma = sma(close, lengthcci)
ccivalue = (src - ma) / (0.015 * dev(src, lengthcci))

//CCI plotting

cciover0 = ccivalue >= 100 and ccivalue <= 120
cciover1 = ccivalue > 120 and ccivalue <= 140
cciover2 = ccivalue > 140 and ccivalue <= 160
cciover3 = ccivalue > 160 and ccivalue <= 180
cciover4 = ccivalue > 180

cciunder0 = ccivalue <= -100 and ccivalue >= -120
cciunder1 = ccivalue <= -120 and ccivalue > -140
cciunder2 = ccivalue <= -140 and ccivalue > -160
cciunder3 = ccivalue <= -160 and ccivalue > -180
cciunder4 = ccivalue <= -180

plotshape(cciover0, title="CCIO0", location=location.abovebar, color=#c6ff1a, transp=0, style=shape.circle, size=size.tiny)
plotshape(cciunder0, title="CCIU0", location=location.belowbar, color=#c6ff1a, transp=0, style=shape.circle, size=size.tiny)
plotshape(cciover1, title="CCIO1", location=location.abovebar, color=#ffff00, transp=0,style=shape.circle, size=size.tiny)
plotshape(cciunder1, title="CCIU1", location=location.belowbar, color=#ffff00, transp=0, style=shape.circle, size=size.tiny)
plotshape(cciover2, title="CCIO2", location=location.abovebar, color=#ff9900, transp=0, style=shape.circle, size=size.tiny)
plotshape(cciunder2, title="CCIU2", location=location.belowbar, color=#ff9900, transp=0, style=shape.circle, size=size.tiny)
plotshape(cciover3, title="CCIO3", location=location.abovebar, color=#ff0000, transp=0, style=shape.circle, size=size.tiny)
plotshape(cciunder3, title="CCIU3", location=location.belowbar, color=#ff0000, transp=0, style=shape.circle, size=size.tiny)
plotshape(cciover4, title="CCIO4", location=location.abovebar, color=#cc00cc, transp=0,style=shape.circle, size=size.tiny)
plotshape(cciunder4, title="CCIU4", location=location.belowbar, color=#cc00cc, transp=0,style=shape.circle, size=size.tiny)

//plotting

plot(upper, title="Upper shadow", color=color.black, transp = 30, linewidth = 4)
plot(upper, title="Upper line", color=#FF2E00, transp = 0, linewidth = 2)
plot(lower, title="Lower shadow", color=color.black, transp = 30, linewidth = 4)
plot(lower, title="Lower line", color=#FF2E00, transp = 0, linewidth = 2)
plot(basis, title="Basic line", color=color.red, transp = 50, linewidth = 2)

mean = input(title="Test Reverse to the Mean instead", type=input.bool, defval=false)
test = input(title="Enable testing", type=input.bool, defval=true)

ordersize=floor(50000/close)

if(close>upper and strategy.opentrades==0 and not mean and test)
    strategy.entry("Hunt Up", strategy.long, ordersize)
if (close<upper and close[1]<upper and close[2]<upper)
    strategy.close("Hunt Up", qty_percent = 100, comment = "Hunt End")

if(close<lower and strategy.opentrades==0 and not mean and test)
    strategy.entry("Hunt Down", strategy.short, ordersize)
if (close>lower and close[1]>lower and close[2]>lower)
    strategy.close("Hunt Down", qty_percent = 100, comment = "Hunt End")

//bounce of bands

if(close>upper and strategy.opentrades==0 and mean and test)
    strategy.entry("Sneak Down", strategy.short, ordersize)
if (close<upper and close[1]<upper and close[2]<upper and close>high[1])
    strategy.close("Sneak Down", qty_percent = 100, comment = "SneakEnd")

if(close<lower and strategy.opentrades==0 and mean and test)
    strategy.entry("Sneak Up", strategy.long, ordersize)
if (close>lower and close[1]>lower and close[2]>lower and close<low[1])
    strategy.close("Sneak Up", qty_percent = 100, comment = "Sneak End")




더 많은