
이것은 상대적으로 약한 지표 ((RSI) 와 임의의 상대적으로 강한 지표 ((Stochastic RSI) 를 결합한 트렌드 반전 거래 전략이다. 이 전략은 시장의 과매매 과매매 상태와 동력의 변화를 식별하여 잠재적인 반전을 포착하여 거래한다. 이 전략의 핵심은 RSI 지표를 기본 동력의 지표로 삼고, 그 기초에 Stochastic RSI를 계산하여 가격 동력의 변화 방향을 추가적으로 확인한다.
전략의 주요 논리는 다음과 같은 몇 가지 핵심 단계를 포함합니다.
이는 동력과 트렌드 반전의 결합된 종합 전략으로 RSI와 Stochastic RSI의 연동 작용을 통해 잠재적인 거래 기회를 식별한다. 전략은 합리적으로 설계되어 있으며, 더 나은 조정성과 적응력을 가지고 있다. 그러나 실제 응용에서는 시장 환경의 선택과 위험 통제에 주의를 기울여야하며, 실전 거래 전에 충분한 피드백과 파라미터 최적화를 권장한다.
/*backtest
start: 2024-06-15 00:00:00
end: 2025-02-19 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=5
strategy("RSI + Stochastic RSI Strategy", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// INPUTS
// RSI settings
rsiLength = input.int(14, "RSI Length", minval=1)
rsiOverbought = input.int(70, "RSI Overbought Level")
rsiOversold = input.int(30, "RSI Oversold Level")
// Stochastic RSI settings
stochLength = input.int(14, "Stoch RSI Length", minval=1)
smoothK = input.int(3, "Stoch %K Smoothing", minval=1)
smoothD = input.int(3, "Stoch %D Smoothing", minval=1)
stochOverbought = input.int(80, "Stoch Overbought Level")
stochOversold = input.int(20, "Stoch Oversold Level")
// CALCULATIONS
// Compute RSI value on the closing price
rsiValue = ta.rsi(close, rsiLength)
// Calculate Stochastic RSI using the RSI value as source
rsiStoch = ta.stoch(rsiValue, rsiValue, rsiValue, stochLength)
kValue = ta.sma(rsiStoch, smoothK)
dValue = ta.sma(kValue, smoothD)
// PLOTTING
// Plot RSI and reference lines
plot(rsiValue, title="RSI", color=color.blue)
hline(rsiOverbought, "RSI Overbought", color=color.red)
hline(rsiOversold, "RSI Oversold", color=color.green)
// Plot Stochastic RSI %K and %D along with overbought/oversold levels
plot(kValue, title="Stoch %K", color=color.orange)
plot(dValue, title="Stoch %D", color=color.purple)
hline(stochOverbought, "Stoch Overbought", color=color.red, linestyle=hline.style_dotted)
hline(stochOversold, "Stoch Oversold", color=color.green, linestyle=hline.style_dotted)
// STRATEGY CONDITIONS
// Long Condition: RSI below oversold and Stoch RSI crosses upward while in oversold territory
longCondition = (rsiValue < rsiOversold) and (kValue < stochOversold) and ta.crossover(kValue, dValue)
// Long Exit: When RSI goes above overbought or a downward cross occurs on the Stoch RSI
longExit = (rsiValue > rsiOverbought) or ta.crossunder(kValue, dValue)
// Short Condition: RSI above overbought and Stoch RSI crosses downward while in overbought territory
shortCondition = (rsiValue > rsiOverbought) and (kValue > stochOverbought) and ta.crossunder(kValue, dValue)
// Short Exit: When RSI goes below oversold or an upward cross occurs on the Stoch RSI
shortExit = (rsiValue < rsiOversold) or ta.crossover(kValue, dValue)
// EXECUTE TRADES
if (longCondition)
strategy.entry("Long", strategy.long)
if (longExit)
strategy.close("Long")
if (shortCondition)
strategy.entry("Short", strategy.short)
if (shortExit)
strategy.close("Short")