Bollinger Bands와 VWAP를 기반으로 한 강세 돌파 전략


생성 날짜: 2024-02-06 14:36:26 마지막으로 수정됨: 2024-02-06 14:36:26
복사: 1 클릭수: 885
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

Bollinger Bands와 VWAP를 기반으로 한 강세 돌파 전략

개요

이 전략은 부린띠 지표를 사용하여 VWAP를 추적하고, VWAP가 부린띠 중간 궤도를 상향으로 돌파할 때 다중 돌파로 판단하고, 다중 돌파 전략을 취한다. VWAP가 부린띠 궤도를 하향으로 돌파할 때 공중으로 판단하고, 평소 포지션 이탈한다. 동시에, 전략은 주요 지지점 Pivot Point을 진입 신호의 보조 판단 조건으로 도입하여, 일부 가짜 돌파를 필터링 할 수 있다.

전략 원칙

  1. VWAP값을 계산한다.
  2. VWAP의 브린 띠를 계산하고, 상반, 중반, 하반을 포함한다.
  3. VWAP가 부린 반도 중간 궤도를 상향으로 돌파하는지 판단하고, 만약 그렇다면 주요 지지점 Pivot Point보다 높으면 다중 전략으로 진입한다.
  4. 5%로 정해져 있습니다.
  5. 만약 VWAP이 아래로 부린을 뚫고 내려간다면, 공허가 확인되었다고 간주하고, 평상시 퇴장한다. 만약 정지 손실이 유발되면, 퇴장한다.

우위 분석

  1. VWAP는 매우 강력한 트렌드 추적 능력을 가지고 있으며, 브린 띠와 결합하여 트렌드를 정확하게 판단할 수 있는 이니셔티브를 가지고 있다.
  2. Pivot Point을 추가하여 많은 가짜 돌파구를 필터링하여 불필요한 손실을 방지할 수 있습니다.
  3. 일부 탈퇴 전략으로 수익을 잠금하고 위험을 통제할 수 있다.
  4. 이 전략은 황소 시장에서 우수한 성과를 거두었고, 높은 안정성을 보였다.

위험 분석

  1. 위기상황에서는 허위 돌파가 발생하여 손실이 발생할 수 있습니다.
  2. Pivot Point는 가짜 돌파구를 완전히 피할 수 없으며, 더 많은 지표 필터링 신호를 결합해야 한다.
  3. 일부 퇴출은 거래 빈도를 증가시키고 거래 비용을 증가시킵니다.
  4. 하지만 이 시장은 위험 통제가 필요하기 때문에 아주 효과적이지 않습니다.

최적화 방향

  1. MACD, KDJ 등의 다른 지표와 결합하여 출전 신호를 필터링 할 수 있습니다.
  2. 부린 대역의 길이와 표준 차이를 최적화하여 최적의 변수 조합을 찾을 수 있다.
  3. 기계 학습 알고리즘을 도입하여 부린 대역 변수를 동적으로 최적화할 수 있다.
  4. 다양한 스톱 레이저를 테스트하여 최적의 스톱 레이저를 찾을 수 있습니다.
  5. 시장의 변동에 따라 목표 수익을 조정할 수 있습니다.

요약하다

이 전략은 전체적으로 안정적인 돌파구 시스템이다. 표준화 된 운영 방식, 변수 최적화 공간이 넓고, 양적 거래에 적합하다. 또한 위험을 통제하고, 비정상적인 행위로 인한 손실을 방지하는 데 주의를 기울여야 한다. 전체적으로, 그것은 깊이 연구하고 지속적으로 최적화 할 가치가 있는 돌파구 유형의 전략이다.

전략 소스 코드
/*backtest
start: 2024-01-06 00:00:00
end: 2024-02-05 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ediks123

//@version=4
strategy("BBofVWAP with entry at Pivot Point", overlay=false, pyramiding=1,   default_qty_type=strategy.percent_of_equity,  default_qty_value=20, initial_capital=10000, currency=currency.USD)  //default_qty_value=10, default_qty_type=strategy.fixed,

// Function outputs 1 when it's the first bar of the D/W/M/Y
is_newbar(res) =>
    ch = 0
    if(res == 'Y')
        t  = year(time('D'))
        ch := change(t) != 0 ? 1 : 0
    else
        t = time(res)
        ch := change(t) != 0 ? 1 : 0
    ch


//variables BEGIN
//smaLength=input(200,title="Slow MA Length")

bbLength=input(50,title="BB Length")  
//bbsrc = input(close, title="BB Source")
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)

pp_period = input(title = "Pivot Period", type=input.string, defval="Week", options = ['Day', 'Week'])

pp_res = pp_period == 'Day' ? 'D' : pp_period == 'Week' ? 'W' : pp_period == 'Month' ? 'M' : 'Y' 

riskCapital = input(title="Risk % of capital", defval=10, minval=1)
stopLoss=input(5,title="Stop Loss",minval=1)



//sma200=sma(close,smaLength)
//plot(sma200, title="SMA 200", color=color.orange)

myVwap=vwap(hlc3)

//bollinger calculation
basis = sma(myVwap, bbLength)
dev = mult * stdev(myVwap, bbLength)
upperBand = basis + dev
lowerBand = basis - dev

//plot bb
plot(basis, "Basis", color=color.teal, style=plot.style_circles , offset = offset)
p1 = plot(upperBand, "Upper", color=color.teal, offset = offset)
p2 = plot(lowerBand, "Lower", color=color.teal, offset = offset)
fill(p1, p2, title = "Background", color=color.teal, transp=95)

plot(myVwap, title="VWAP", color=color.purple)


//pivot points 


// Calc High
high_cur = 0.0
high_cur := is_newbar(pp_res) ? high : max(high_cur[1], high)

phigh = 0.0
phigh := is_newbar(pp_res) ? high_cur[1] : phigh[1]

// Calc Low
low_cur = 0.0
low_cur := is_newbar(pp_res) ? low : min(low_cur[1], low)

plow = 0.0
plow := is_newbar(pp_res) ? low_cur[1] : plow[1]

// Calc Close
pclose = 0.0
pclose := is_newbar(pp_res) ? close[1] : pclose[1]


vPP = (phigh + plow + pclose) / 3

//pivot points


//Entry--
//Echeck how many units can be purchased based on risk manage ment and stop loss
qty1 = (strategy.equity  * riskCapital / 100 ) /  (close*stopLoss/100)  

//check if cash is sufficient  to buy qty1  , if capital not available use the available capital only
qty1:= (qty1 * close >= strategy.equity ) ? (strategy.equity / close) : qty1


strategy.entry(id="BB_VWAP_PP",long=true, qty=qty1, when=   crossover(myVwap,basis)  and close>=vPP  )

bgcolor(strategy.position_size>=1?color.blue:na, transp=75)
barcolor(strategy.position_size>=1?color.green:na)

stopLossVal=  strategy.position_size>=1 ?  close * (1 - (stopLoss*0.01) ) : 0.00

//partial exit
//strategy.close(id="BBofVwap", qty=strategy.position_size/3, when=crossunder(myVwap,upperBand) and strategy.position_size>=1 )  //and close>strategy.position_avg_price)



//exit on lowerband or stoploss 
strategy.close(id="BB_VWAP_PP", comment="P" , qty=strategy.position_size/3, when= crossunder(myVwap,upperBand) and strategy.position_size>=1 and close>strategy.position_avg_price)  //
strategy.close(id="BB_VWAP_PP", comment="Exit All", when=crossunder(myVwap,lowerBand) and strategy.position_size>=1 )
//strategy.close(id="BBofVwapWithFibPivot", comment="Exit All", when=crossunder(close,vPP) and strategy.position_size>=1 )

strategy.close(id="BB_VWAP_PP", comment="Stop Loss Exit", when=crossunder(close,stopLossVal) and strategy.position_size>=1 )