골든 크로스와 볼링거 밴드 모멘텀 전략

저자:차오장, 날짜: 2023-11-21 12:01:25
태그:

img

전반적인 설명

이 전략은 이동 평균, 볼링거 밴드 및 볼륨 가중 평균 가격 (VWAP) 인디케이터를 결합합니다. 황금 십자가가 형성되고 빠른 이동 평균이 느린 상위를 깨는 경우 긴 포지션을 입력합니다. 이 전략은 또한 볼링거 밴드 채널을 활용하고 가격이 하위 밴드에 닿을 때만 입력하는 것을 고려하여 시장 변동 속의 빈번한 입출출출을 피합니다.

전략 논리

핵심 논리는 트렌드 방향을 결정하기 위해 이동 평균과 구매 신호의 변동 범위를 찾기 위해 볼링거 대역에 의존합니다. 구체적으로 다음과 같은 주요 규칙이 있습니다.

  1. 50일 EMA와 200일 EMA를 사용하여 골든 크로스 시스템을 구성합니다. 빠른 EMA가 느린 EMA를 넘을 때 상승 추세가 확인됩니다.

  2. 가격이 VWAP보다 높으면 가격이 상승 단계에 있다는 것을 나타냅니다. 이는 긴 포지션을 선호합니다.

  3. 가격이 볼링거 하부 밴드를 만지거나 돌파하면 가격이 리바운드 포인트 근처에있을 수 있음을 암시하여 좋은 기회를 제공합니다.

  4. 가격이 볼링거 상단선을 초과할 때 수익으로 긴 포지션을 종료합니다.

이 규칙들을 결합함으로써 전략은 황소 시장에서 적절한 긴 입시를 찾아내고 수익을 확보하기 위해 스톱 로스/프로프트 테킹을 설정할 수 있습니다.

장점

  • 골든 크로스 시스템은 주요 트렌드 방향을 결정하고, 통합 중 작은 승과 손실을 피합니다.

  • VWAP는 더 정확한 구매 신호를 위해 가격 파동 방향을 측정합니다.

  • 볼링거 대역은 매입을 설정하면서 매출에 스톱 로스/프로프트 포크를 설정함으로써 탄력성을 높여줍니다.

  • 여러 가지 확인 지표가 신뢰성을 높여줍니다.

위험 과 해결책

  • 황금 십자가는 잘못된 신호를 줄 수 있습니다.

  • 부적절한 볼링거 매개 변수는 전략을 비효율적으로 만들 수 있습니다.

  • 너무 큰 스톱 로스 문턱은 손실을 효과적으로 제한하지 않습니다. 통제 가능한 위험을 보장하기 위해 스톱 로스 범위를 좁히십시오.

최적화 방향

  • 가장 좋은 것을 찾기 위해 다양한 매개 변수를 테스트하여 MA 조합을 최적화하십시오.

  • 더 나은 대역폭과 변동성을 위해 볼링거 기간과 매개 변수 세트를 테스트하십시오.

  • 위험 조절을 균형을 맞추고 조기 발사 방지하기 위해 중지 손실 범위를 테스트하고 조정합니다.

결론

이 전략은 입시에 대한 MA, 볼링거 및 VWAP 분석을 통합함으로써 기회를 발견하고 위험을 제어하는 균형을 이룬다. 지속적인 정밀 조정 및 최적화는 시간이 지남에 따라 부문 및 시장 동향을 활용 할 수 있습니다.


/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
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/
// © mohanee

//@version=4
strategy(title="VWAP and BB strategy [$$]", overlay=true,pyramiding=2, default_qty_value=1, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)


fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
fromMonth = input(defval = 6, title = "From Month", minval = 1, maxval = 12)
fromYear = input(defval = 2020, title = "From Year", minval = 1970)
 
// To Date Inputs
toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
toMonth = input(defval = 8, title = "To Month", minval = 1, maxval = 12)
toYear = input(defval = 2020, title = "To Year", minval = 1970)
 
// Calculate start/end date and time condition
DST = 1 //day light saving for usa
//--- Europe
London = iff(DST==0,"0000-0900","0100-1000")
//--- America
NewYork = iff(DST==0,"0400-1300","0500-1400")
//--- Pacific
Sydney = iff(DST==0,"1300-2200","1400-2300")
//--- Asia
Tokyo = iff(DST==0,"1500-2400","1600-0100")

//-- Time In Range
timeinrange(res, sess) => time(res, sess) != 0

london = timeinrange(timeframe.period, London)
newyork = timeinrange(timeframe.period, NewYork)

startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = time >= startDate and time <= finishDate 


is_price_dipped_bb(pds,source1) =>
    t_bbDipped=false
    for i=1 to pds
        t_bbDipped:=  (t_bbDipped   or  close[i]<source1) ? true : false
        if t_bbDipped==true
            break
        else
            continue
            
    t_bbDipped


is_bb_per_dipped(pds,bbrSrc) =>
    t_bbDipped=false
    for i=1 to pds
        t_bbDipped:=  (t_bbDipped   or  bbrSrc[i]<=0) ? true : false
        if t_bbDipped==true
            break
        else
            continue
            
    t_bbDipped
    

// variables  BEGIN
shortEMA = input(50, title="fast EMA", minval=1)
longEMA = input(200, title="slow EMA", minval=1)

//BB

smaLength = input(7, title="BB SMA Length", minval=1)
bbsrc = input(close, title="BB Source")

strategyCalcOption = input(title="strategy to use", type=input.string, options=["BB", "BB_percentageB"],      defval="BB")



//addOnDivergence = input(true,title="Add to existing on Divergence")
//exitOption = input(title="exit on RSI or BB", type=input.string, options=["RSI", "BB"],      defval="BB")

//bbSource = input(title="BB  source", type=input.string, options=["close", "vwap"],      defval="close")
     
//vwap_res = input(title="VWAP Resolution", type=input.resolution, defval="session")
stopLoss = input(title="Stop Loss%", defval=1, minval=1)

//variables  END

longEMAval= ema(close, longEMA)
shortEMAval= ema(close, shortEMA)
ema200val = ema(close, 200)


vwapVal=vwap(close)



// Drawings

//plot emas
plot(shortEMAval, color = color.green, linewidth = 1, transp=0)
plot(longEMAval, color = color.orange, linewidth = 1, transp=0)
plot(ema200val, color = color.purple, linewidth = 2, style=plot.style_line ,transp=0)



//bollinger calculation 
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
basis = sma(bbsrc, smaLength)
dev = mult * stdev(bbsrc, smaLength)
upperBand = basis + dev
lowerBand = basis - dev
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)

bbr = (bbsrc - lowerBand)/(upperBand - lowerBand) 
//bollinger calculation 

//plot bb
//plot(basis, "Basis", color=#872323, 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=#198787, transp=95)


plot(vwapVal, color = color.purple, linewidth = 2, transp=0)


// Colour background

//barcolor(shortEMAval>longEMAval and close<=lowerBand ? color.yellow: na)
  

//longCondition=  shortEMAval > longEMAval and  close>open and  close>vwapVal
longCondition=  ( shortEMAval > longEMAval  and close>open and close>vwapVal and close<upperBand ) //and time_cond //     and  close>=vwapVal 



//Entry
strategy.entry(id="long", comment="VB LE" , long=true,  when= longCondition and ( strategyCalcOption=="BB"? is_price_dipped_bb(10,lowerBand) : is_bb_per_dipped(10,bbr)  )   and strategy.position_size<1 )   //is_price_dipped_bb(10,lowerBand))  //and strategy.position_size<1       is_bb_per_dipped(15,bbr) 


//add to the existing position
strategy.entry(id="long", comment="Add" , long=true,  when=strategy.position_size>=1 and close<strategy.position_avg_price and close>vwapVal) //and time_cond)

barcolor(strategy.position_size>=1  ? color.blue: na)



strategy.close(id="long", comment="TP Exit",   when=crossover(close,upperBand) )

//stoploss
stopLossVal =   strategy.position_avg_price * (1-(stopLoss*0.01) )
//strategy.close(id="long", comment="SL Exit",   when= close < stopLossVal)

//strategy.risk.max_intraday_loss(stopLoss, strategy.percent_of_equity)

더 많은