볼링거 밴드 및 MACD를 기반으로 한 양적 거래 전략

저자:차오장, 날짜: 2024-02-23 14:30
태그:

img

전반적인 설명

이 전략은 볼링거 밴드 및 MACD 지표를 기반으로 한 양적 거래 전략입니다. 거래 신호의 품질을 향상시키기 위해 볼링거 밴드 브레이크아웃 거래와 MACD 트렌드 추적을 결합합니다.

전략 원칙

이 전략은 주로 거래 신호를 결정하기 위해 볼링거 밴드 및 MACD 지표를 사용합니다.

볼링거 밴드는 중간 밴드, 상위 밴드 및 하위 밴드로 구성됩니다. 가격이 하위 밴드를 통과 할 때 구매 신호가 생성됩니다. 가격이 상위 밴드를 통과 할 때 판매 신호가 생성됩니다. 전략은 더 강한 브레이크 아웃 신호를 결정하기 위해 볼링거 밴드의 브레이크 아웃 원리를 사용합니다.

MACD 지표는 단기 및 장기 이동 평균 사이의 관계를 반영합니다. 이 전략은 진입 및 출구 지점을 결정하기 위해 차선 라인과 신호 라인의 교차를 사용합니다. 이 전략은 MACD 지표의 사용을 통합하여 볼링거 밴드 거래 신호를 필터하고 차선 라인이 신호 라인 위에 넘어가면 더 효과적인 구매 신호를 생성합니다.

전체적으로 이 전략은 볼린저 밴드와 MACD의 이동 평균의 트렌드 추적을 결합하여 강력한 트렌드에서 더 큰 시장 변동을 포착하는 것을 목표로 합니다.

전략 의 장점

  1. 볼링거 반드와 MACD 지표를 결합하면 거래 신호가 더 신뢰할 수 있습니다.

  2. 볼링거 밴드 트렌드 추적 및 MACD 이동 평균 크로스오버는 트렌딩 시장에서 더 강력한 진입 신호를 생성 할 수 있습니다.

  3. 잘못된 신호는 이중 지표 판단을 통해 효과적으로 필터링하여 거래 위험을 줄일 수 있습니다.

  4. 전략의 매개 변수 최적화에 많은 여지가 있으며, 다른 제품과 주기에 따라 조정 될 수 있습니다.

전략 의 위험

  1. 범위에 묶인 시장에서는 볼링거 밴드 (Bollinger Bands) 와 MACD (MACD) 에 의해 생성되는 거래 신호가 빈번하게 발생할 수 있으며, 과도한 거래의 위험을 초래할 수 있습니다.

  2. MACD가 3번 연속 하락하는 경우 하락할 위험이 있습니다.

  3. 이 전략은 여러 지표를 사용하므로 매개 변수 최적화와 전략 테스트가 상당히 어렵습니다.

이러한 위험을 해결하기 위해, 보유 기간을 조정하고, 손해를 멈추거나, 매개 변수를 최적화하는 방법과 같은 방법을 사용하여 제어할 수 있습니다.

전략 최적화의 방향

  1. 거래 빈도를 줄이기 위해 더 긴 기간 볼링거 밴드 매개 변수를 테스트합니다.

  2. 지표의 감수성을 향상시키기 위해 MACD 빠른 라인 및 느린 라인 매개 변수를 최적화하십시오.

  3. 신호 품질을 향상시키기 위해 KDJ, RSI 등 필터링을 위한 다른 지표를 추가합니다.

  4. 동적 스톱을 설정하여 자동으로 거래를 종료하고 단일 거래 위험을 제어합니다.

결론

이론적으로 볼링거 밴드 브레이크아웃 트레이딩과 MACD 지표 필터링을 통합함으로써 이 전략은 고품질의 트레이딩 신호를 생산할 수 있다. 매개 변수 최적화와 위험 통제 조치를 통해 좋은 백테스트 결과를 얻을 수 있다. 그러나 어떤 전략도 손실을 완전히 피할 수 없다. 실제 거래 성과는 신중한 평가가 필요하다.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Nabz-BBMACD-2022-V1.1", shorttitle="BBM-Nabz", overlay=true)


// My 1st Pine Scrpt Indicator
// Work on best on 1Hr Chart
// Open for Help/Donations.


var float lastentry=1
int result = 0
float x = 0
drawshape = false

/////////////EMA
shortest = ta.ema(close, 20)
short = ta.ema(close, 50)
longer = ta.ema(close, 100)
longest = ta.ema(close, 200)

plot(shortest, color = color.red)
plot(short, color = color.orange)
plot(longer, color = color.aqua)
plot(longest, color = color.blue)

///////////// RSI
RSIlength = input(6,title="RSI Period Length") 
RSIoverSold = 50
RSIoverBought = 50
price = close
vrsi = ta.rsi(price, RSIlength)


///////////// Bollinger Bands
BBlength = input.int(200, minval=1,title="Bollinger Period Length")
BBmult = 2 // input(2.0, minval=0.001, maxval=50,title="Bollinger Bands Standard Deviation")
BBbasis = ta.sma(price, BBlength)
BBdev = BBmult * ta.stdev(price, BBlength)
BBupper = BBbasis + BBdev
BBlower = BBbasis - BBdev
source = close
buyEntry = ta.crossover(source, BBlower)
sellEntry = ta.crossunder(source, BBupper)



////////////// MACD
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)
MACD = ta.ema(close, fastLength) - ta.ema(close, slowlength)
aMACD = ta.ema(MACD, MACDLength)
delta = MACD - aMACD


///////////// Colors
switch1=input(true, title="Enable Bar Color?")
switch2=input(true, title="Enable Background Color?")
TrendColor = RSIoverBought and (price[1] > BBupper and price < BBupper) and BBbasis < BBbasis[1] ? color.red : RSIoverSold and (price[1] < BBlower and price > BBlower) and BBbasis > BBbasis[1] ? color.green : na


///////////Strategy

bool tcu = not (ta.crossunder(price[0],shortest[0]))


if (((price[1]<BBlower[1]) and (ta.crossover(price,BBlower))))
    lastentry := low[1]
    strategy.entry("RSI_BB_L", strategy.long, comment="Buy 1st IF")
    
if (((ta.crossover(delta, 0.0) and (ta.crossover(price,BBlower)))))
    lastentry := low[1]
    strategy.entry("RSI_BB_L", strategy.long, comment="Buy 2nd IF")    
    
if (((ta.crossover(delta, 0.0)) and (low[0]>shortest[0])) and (price[1]<low))
    lastentry := low[1]
    strategy.entry("RSI_BB_L", strategy.long, comment="Buy 3rd IF")   //else

if (((ta.crossover(delta, 0.01)) and (high[1]<BBupper)) and (tcu))
    lastentry := low[1]
    strategy.entry("RSI_BB_L", strategy.long, comment="Buy 4th IF")

       
if ((ta.crossunder(low[0],shortest[0]) and close<shortest))
    strategy.close(id="RSI_BB_L", comment="Close by 1st IF")
    
    
    
if (price<lastentry)
    drawshape := true
    
if (price<strategy.opentrades.entry_price(0)/1.01175734321249)
    strategy.close(id="RSI_BB_L", comment="Close by 2nd IF")



plot(strategy.opentrades.entry_price(0), color=color.yellow)


더 많은