
이 거래 전략은 상대적으로 약한 지표 ((RSI) 와 임의의 상대적으로 강한 지표 ((Stochastic RSI) 를 결합하여 거래 신호를 생성합니다. 전략은 더 높은 시간 프레임의 암호화폐 가격 움직임을 사용하여 트렌드를 확인하여 신호의 신뢰성을 높입니다.
멀티 타임 프레임 RSI-SRSI 트레이딩 전략
이 전략은 RSI 지표 값의 높낮이에 따라 과매매 현상을 판단한다. RSI가 30보다 낮으면 과매매 신호이며, 70보다 높으면 과매매 신호이다. 스토카스틱 RSI 지표는 RSI 지표 자체의 변동을 관찰한다.
전략은 동시에 더 높은 시간 프레임 (예: 주주선) 의 암호화폐 가격 움직임과 결합한다. 구매 거래 신호는 더 높은 시간 프레임의 RSI가 하락보다 높을 때만 생성된다. (예: 45). 이 설정은 전체적으로 하락 추세에있을 때 발생하는 비 지속적 인 과매매 신호를 필터링 할 수 있습니다.
구매 및 판매 신호는 트리거 후, 일정 주기 (예: 8개의 K선) 를 거쳐 확인해야 하며, 잘못된 신호를 발생하지 않도록 한다.
이 전략은 주로 RSI와 Stochastic 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")