다중 시간 프레임 RSI-SRSI 거래 전략

저자:차오장, 날짜: 2024-02-18 16:13:50
태그:

img

전반적인 설명

이 거래 전략은 거래 신호를 생성하기 위해 상대적 강도 지수 (RSI) 와 스토카스틱 상대적 강도 지수 (Stochastic RSI) 기술 지표를 결합합니다. 또한 트렌드를 확인하고 신호 신뢰성을 높이기 위해 더 높은 시간 프레임에서 암호화폐의 가격 추세를 활용합니다.

전략 이름

다중 시간 프레임 RSI-SRSI 거래 전략

전략 논리

이 전략은 RSI 값에 기초하여 과반 구매 및 과반 판매 조건을 판단합니다. 30 이하의 RSI는 과반 판매 신호로 간주되며 70 이상의 RSI는 과반 구매 신호로 간주됩니다. 스토카스틱 RSI 지표는 RSI 값의 변동을 관찰합니다. 5 이하의 스토카스틱 RSI는 과반 판매이며 50 이상의 스토카스틱 RSI는 과반 구매입니다.

이 전략은 또한 더 높은 시간 프레임 (예: 주간) 에서 암호화폐의 가격 추세를 포함합니다. 더 높은 시간 프레임 RSI가 한계 (예: 45) 이상일 때만 긴 신호가 유발됩니다. 이는 전체 추세가 하락 할 때 지속되지 않는 과판 신호를 필터링합니다.

실제 거래 신호가 생성되기 전에 구매 및 판매 신호는 가짜 신호를 피하기 위해 몇 가지 기간 (예를 들어 8 바) 에 확인되어야 합니다.

장점

  • RSI를 이용한 고전적인 기술 분석 방법
  • RSI의 반전을 잡기 위해 스토카스틱 RSI를 포함합니다.
  • 가짜 신호를 필터링하고 품질을 향상시키기 위해 멀티 타임프레임 기술을 적용합니다.

위험 과 해결책

  • RSI는 잘못된 신호를 생성하는 경향이 있습니다.
    • 가짜 신호를 필터링하기 위해 다른 지표를 결합
    • 트렌드 확인 기술을 적용
  • 부적절 한계 설정은 너무 많은 신호를 생성 할 수 있습니다.
    • 가장 좋은 조합을 찾기 위해 매개 변수를 최적화
  • 신호는 확인 시간이 필요합니다.
    • 잔액 확인 기간 - 기회를 놓치지 않고 가짜 신호를 필터

개선 영역

  • 더 강한 신호를 위해 더 많은 표시기 조합을 테스트
    • 예를 들어 MACD 지표를 포함합니다.
  • 최적의 매개 변수를 찾기 위해 기계 학습 방법을 사용
    • 예를 들어 자동 최적화를 위한 유전 알고리즘/진화 알고리즘
  • 단일 거래 위험을 제어하기 위해 스톱 로스 전략을 추가하십시오.
    • 가격이 지원 수준을 넘을 때 손해 중지 설정

결론

이 전략은 주로 두 가지 고전적인 기술 지표인 RSI와 스토카스틱 RSI에 의존하여 거래 신호를 생성합니다. 또한 더 높은 시간 프레임에서 트렌드 확인을 도입하면 가짜 신호를 효과적으로 필터링하고 신호 품질을 향상시킵니다. 매개 변수를 최적화하고 스톱 로스 및 기타 방법을 추가하여 추가 성능 향상을 달성 할 수 있습니다. 논리는 간단하고 이해하기 쉽습니다. 양자 거래에 좋은 출발점이 됩니다.


/*backtest
start: 2023-02-11 00:00:00
end: 2024-02-17 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("RSI and Stochatic Strategy", overlay=true, use_bar_magnifier = false)


/////// Inputs ///////////////

// RSI and SRSI
rsiLength = input(14, title="RSI Length") 
stochLength = input(14, title="Stochastic Length")
kSmooth = input(3, title="K Smooth")
dSmooth = input(3, title="D Smooth")


//////// thresholds ///////////////
st_low = input(5, title="Low SRSI") // stochastic RSI low -- prepare to sell
st_hi = input(50, title="High SRSI") // stochastic RSI high -- prepare to buy
diff = input(5, title="difference") // minimum change in RSI
// inval_diff = input(12, title="difference") // invalidation difference: change in the oposite direction that invalidates rsi falling/rising
rsi_low = input(30, title="Low RSI") // RSI considered low
rsi_hi = input(60, title="High RSI") // RSI considered high
rsi_ht_hi = input(45, title="High higher time frame RSI") // RSI in higher time frame considered high


/// buy trigger duration 
tr_dur = input(8, title="Trigger duration")
low_dur = input(20, title="Monitoring last low")


///////////////// Higher time frame trend ///////////////////
// higher time frame resolution
res2 = input.timeframe("W", title="Higher time-frame")
// Input for the ticker symbol, default is an empty string
// For instance we could monitor BTC higher time frame trend
symbol = input("BTC_USDT:swap", "Input Ticker (leave empty for current)")

// Determine the symbol to use
inputSymbol = symbol == "" ? syminfo.tickerid : symbol
//////////////////////////////////////////////////////////

// Calculate RSI //
rsi = ta.rsi(close, rsiLength)

// Calculate Stochastic RSI //
rsiLowest = ta.lowest(rsi, stochLength)
rsiHighest = ta.highest(rsi, stochLength)
stochRsi = 100 * (rsi - rsiLowest) / (rsiHighest - rsiLowest)

// Apply smoothing
K = ta.sma(stochRsi, kSmooth)
D = ta.sma(K, dSmooth)

// Higher time Frame RSI
cl2 = request.security(inputSymbol, res2, close)
rsi2 = ta.rsi(cl2, 14)

// SRSI BUY/SELL signals 
sell_stoch = (ta.lowest(K, tr_dur) < st_low) or (ta.highest(rsi, tr_dur) < rsi_low)
buy_stoch = ((ta.lowest(K, tr_dur) > st_hi) or (ta.lowest(rsi, tr_dur) > rsi_hi)) and (rsi2 > rsi_ht_hi)

 // valitation / invalidation sell signal
ll = ta.barssince(not sell_stoch)+1
sell_validation = (ta.highest(rsi, ll)>rsi[ll]+diff and rsi < rsi[ll]) or (rsi < rsi[ll]-diff)

// valitation / invalidation buy signal
llb = ta.barssince(not buy_stoch)+1
buy_validation = (ta.lowest(rsi, llb)<rsi[llb]-diff and rsi > rsi[llb]) or (rsi > rsi_hi and rsi - rsi[tr_dur] > 0)

sell_signal = sell_stoch and sell_validation
buy_signal = buy_stoch and buy_validation 

// Define the start date for the strategy
startYear = input(2019, "Start Year")
startMonth = input(1, "Start Month")
startDay = input(1, "Start Day")

// Convert the start date to Unix time
startTime = timestamp(startYear, startMonth, startDay, 00, 00)

// Define the end date for the strategy
endYear = input(2030, "End Year")
endMonth = input(1, "End Month")
endDay = input(1, "End Day")

// Convert the end date to Unix time
endTime = timestamp(endYear, endMonth, endDay, 00, 00)


if true
    if buy_signal
        strategy.entry("buy", strategy.long, comment = "Buy")
    if sell_signal
        strategy.close("buy", "Sell")

더 많은