다중 지표 비트코인 일일 거래 전략

저자:차오장, 날짜: 2023-10-30 10:37:58
태그:

img

전반적인 설명

이 전략은 비트코인의 일일 시간 틀 내에서 거래 기회를 식별하기 위해 여러 지표를 결합합니다. 주로 MACD, RSI, Stoch RSI와 같은 지표를 사용하고 이동평균의 방향과 함께 구매 및 판매 신호를 생성하는 현재 트렌드 방향을 결정합니다.

전략 논리

이 전략은 다음의 주요 지표를 이용합니다.

  1. MACD (Fast MA - Slow MA) 및 신호 라인. 신호 라인 위에 MACD를 넘어가면 구매 신호가 되고 0 아래로 넘어가면 판매 신호가 된다.

  2. RSI (Relative Strength Index). RSI가 한 임계치를 넘으면 구매 신호가 됩니다.

  3. 스톡 RSI. 스톡 RSI는 RSI의 과잉 구매/ 과잉 판매 수준을 보여줍니다. 스톡 RSI는 임계치 이하로 구매 신호를 주고, 임계치 이상의 경우 판매 신호를 줍니다.

  4. 이동평균 방향. MA 아래의 가격 경로를 닫는 것은 판매 신호를 제공합니다.

이 지표에 따르면 거래 신호는 다음과 같습니다.

구매 신호: 언제(Stoch RSI < Threshold) AND (MACD crossing above threshold OR RSI crossing above threshold)

판매 신호: 언제(MACD crossing below 0) AND (Close below MA OR Stoch RSI > Threshold)

여러 지표를 함께 사용하면 현재 트렌드 방향을 더 잘 파악하고 트렌드 전환 지점을 파악 할 수 있습니다.

장점

  1. 여러 지표를 결합하면 정확도가 향상되고 하나의 지표에서 잘못된 신호를 피합니다.

  2. MACD는 트렌드 방향과 강도를 나타냅니다. RSI는 과잉 구매 / 과잉 판매 수준을 반영합니다. 주식 RSI는 RSI의 과잉 구매 / 과잉 판매를 결정합니다. MA는 트렌드 방향을 보여줍니다. 이 지표는 서로 확인됩니다.

  3. 구매/판매 신호는 여러 지표의 조합을 요구하며 일부 잘못된 신호를 필터링하고 불필요한 거래를 피합니다.

  4. 백테스트는 2017년 1월 1일부터 시작되며, 2017년 말 비트코인의 거대한 상승세를 다루고 있습니다. 실제 상승 시장에서 전략 성능을 테스트합니다.

  5. 스톱 로즈는 단일 트레이드에서 손실을 제어하도록 설정됩니다.

위험성

  1. 여러 가지 지표를 사용하면 정확도가 향상되지만, 그 사이의 오차는 여전히 잘못된 신호로 이어질 수 있습니다.

  2. 최적화된 스톱 로스 레벨은 다른 시장 상황에 따라 조정될 수 있습니다. 너무 넓은 스톱 로스는 단일 트레이드에서 손실을 증가시키지만 너무 긴 것은 조기에 중단 될 수 있습니다.

  3. 매일의 시간 프레임은 더 짧은 시간대에 세부적인 작업을 방지합니다.

  4. 전략은 제한된 역사적 데이터에 대해서만 백테스트됩니다. 과잉 적합성 위험이 존재합니다. 더 긴 시간 프레임과 더 많은 시장에 대한 추가 테스트가 필요합니다.

더 나은 기회

  1. 최적의 다중 지표 전략을 찾기 위해 더 많은 지표 조합을 테스트합니다.

  2. 더 나은 값을 위해 지표의 매개 변수를 최적화합니다.

  3. 최적의 리스크/이익 비율을 찾기 위해 다른 스톱 로스 레벨을 테스트합니다.

  4. 더 긴 역사적인 데이터에 대한 백테스트를 수행하여 과잉 적합성을 피합니다.

  5. 더 빈번한 거래를 위해 더 높은 주파수 시간 프레임에서 전략 논리를 적용하는 것을 탐구하십시오.

결론

이 전략은 비트코인의 일일 트렌드 방향을 결정하고 거래 진입을 위한 트렌드 반전을 식별하기 위해 MACD, RSI, 스톡 RSI 및 기타 지표를 결합한다. 스톱 로스는 무역 위험을 제어하기 위해 설정된다. 백테스트는 긍정적인 결과를 보여주지만 더 긴 시간 프레임과 더 많은 시장에서 과잉 리스크를 피하기 위해 추가 검증이 필요하다. 지표 매개 변수 및 스톱 로스/트레이프 수준의 추가 최적화는 결과를 향상시킬 수 있다. 전략은 더 깊은 탐색과 향상 가치가 있는 멀티 지표 조합 접근의 초기 아이디어를 제공한다.


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

//@version=4
// Original code is from CredibleHulk and modified by bennef
strategy("BTC Daily Strategy BF", overlay=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.075)

/////////////// Time Frame ///////////////
testStartYear = input(2017, "Backtest Start Year") 
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay, 0, 0)

testStopYear = input(2019, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(31, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay, 0, 0)

testPeriod() => true

/////////////// Input Params /////////////// 
rsi_threshold = input(30)
rsi_length = input(4)
srsi_length = input(8)
srsi_smooth = input(4)
srsi_sell_threshold = input(57)
length = input(14)
dma_signal_threshold = input(-1)
fastLength = input(11)
slowlength = input(18)
MACDLength = input(6)
MACD_signal_threshold = input(-2)
short_loss_tol = input(5)
long_loss_tol = input(5)

stop_level_long = strategy.position_avg_price * (1 - long_loss_tol / 100.0)
stop_level_short = strategy.position_avg_price * (1 + short_loss_tol / 100.0)
    
///////////////  Signal generation ///////////////
// MACD 
MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD

// RSI and Stochastic RSI 
rs = rsi(close, rsi_length)
k = sma(stoch(rs, rs, rs, srsi_length), srsi_smooth)

// SMA 
norm = sma(ohlc4, length)
threshold = close - norm   

/////////////// Strategy ///////////////
long = ((crossover(delta, MACD_signal_threshold) or crossover(rs, rsi_threshold)) and k < srsi_sell_threshold)
short = (crossunder(delta, 0) or (crossunder(threshold, dma_signal_threshold) and k > srsi_sell_threshold))

if testPeriod()
    strategy.entry("L", strategy.long, when = long)
    strategy.entry("S", strategy.short, when = short)
    strategy.exit("stop loss L", from_entry = "L", stop = stop_level_long)
    strategy.exit("stop loss S", from_entry = "S", stop = stop_level_short)

/////////////// Plotting ///////////////
// MACD
plot(delta, color = delta > MACD_signal_threshold ? color.lime : delta < 0 ? color.red : color.yellow)
MACD_signal_threshold_line = hline(MACD_signal_threshold, color = color.yellow, title = "MACD Signal Threshold")

// RSI
plot(rs, color = rs > rsi_threshold ? color.lime : color.fuchsia)
rsi_threshold_line = hline(rsi_threshold, color = color.fuchsia, title = "RSI Threshold")

// Stochastic RSI 
plot(k, color = k > srsi_sell_threshold ? color.lime : color.red)
srsi_sell_threshold_line = hline(srsi_sell_threshold, color = color.white, title = "Stoch RSI Threshold")

// SMA
plot(threshold / 100, color = threshold < dma_signal_threshold ? color.red : color.blue)
dma_signal_threshold_line = hline (dma_signal_threshold, color = color.blue, title = "DMA Signal Threshold")

bgcolor(long ? color.lime : short ? color.red : na, transp=50)

더 많은