
이 전략은 상대적으로 약한 지표 ((RSI) 와 임의의 상대적으로 강한 지표 ((Stochastic RSI) 에 기반한 트렌드 추적 거래 시스템이다. 이 전략은 RSI와 스토카스틱 RSI의 오버 바이 오버 시드 수준을 모니터링하여 시장에서 오버 바이 또는 오버 시드 신호가 발생하면 거래한다. 이 전략은 일선과 주선 시간 주기에서 작동하는 것을 지원하여 거래자에게 유연한 거래 옵션을 제공합니다.
전략은 주로 두 가지 기술 지표에 기반합니다: RSI와 스토카스틱 RSI. RSI는 가격 변화의 속도와 폭을 측정하는 데 사용되며, 스토카스틱 RSI는 RSI 값에 대한 무작위 지표 계산을 통해 더 민감한 시장 오버 바이 오버 세일 신호를 제공합니다. 구매 신호는 RSI가 35보다 낮고 스토카스틱 RSI의 K 값이 20보다 낮으면 시장이 오버 세일 상태임을 나타냅니다.
이 전략은 RSI와 Stochastic RSI의 장점을 결합하여 비교적 신뢰할 수있는 거래 시스템을 구축합니다. 제한이 있지만, 합리적인 위험 관리와 지속적인 최적화를 통해 전략은 좋은 실용적 가치를 가지고 있습니다. 거래자는 실제 사용 전에 다양한 변수 조합을 충분히 테스트하고 시장 환경과 개인 위험 선호도에 따라 적절하게 조정하는 것이 좋습니다.
/*backtest
start: 2023-12-20 00:00:00
end: 2024-12-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("BTC Buy & Sell Strategy (RSI & Stoch RSI)", overlay=true)
// Input Parameters
rsi_length = input.int(14, title="RSI Length")
stoch_length = input.int(14, title="Stochastic Length")
stoch_smooth_k = input.int(3, title="Stochastic %K Smoothing")
stoch_smooth_d = input.int(3, title="Stochastic %D Smoothing")
// Threshold Inputs
rsi_buy_threshold = input.float(35, title="RSI Buy Threshold")
stoch_buy_threshold = input.float(20, title="Stochastic RSI Buy Threshold")
rsi_sell_threshold = input.float(70, title="RSI Sell Threshold")
stoch_sell_threshold = input.float(80, title="Stochastic RSI Sell Threshold")
use_weekly_data = input.bool(false, title="Use Weekly Data", tooltip="Enable to use weekly timeframe for calculations.")
// Timeframe Configuration
timeframe = use_weekly_data ? "W" : timeframe.period
// Calculate RSI and Stochastic RSI
rsi_value = request.security(syminfo.tickerid, timeframe, ta.rsi(close, rsi_length))
stoch_rsi_k_raw = request.security(syminfo.tickerid, timeframe, ta.stoch(close, high, low, stoch_length))
stoch_rsi_k = ta.sma(stoch_rsi_k_raw, stoch_smooth_k)
stoch_rsi_d = ta.sma(stoch_rsi_k, stoch_smooth_d)
// Define Buy and Sell Conditions
buy_signal = (rsi_value < rsi_buy_threshold) and (stoch_rsi_k < stoch_buy_threshold)
sell_signal = (rsi_value > rsi_sell_threshold) and (stoch_rsi_k > stoch_sell_threshold)
// Strategy Execution
if buy_signal
strategy.entry("Long", strategy.long, comment="Buy Signal")
if sell_signal
strategy.close("Long", comment="Sell Signal")
// Plot Buy and Sell Signals
plotshape(buy_signal, style=shape.labelup, location=location.belowbar, color=color.green, title="Buy Signal", size=size.small, text="BUY")
plotshape(sell_signal, style=shape.labeldown, location=location.abovebar, color=color.red, title="Sell Signal", size=size.small, text="SELL")
// Plot RSI and Stochastic RSI for Visualization
hline(rsi_buy_threshold, "RSI Buy Threshold", color=color.green)
hline(rsi_sell_threshold, "RSI Sell Threshold", color=color.red)
plot(rsi_value, color=color.blue, linewidth=2, title="RSI Value")
plot(stoch_rsi_k, color=color.purple, linewidth=2, title="Stochastic RSI K")
plot(stoch_rsi_d, color=color.orange, linewidth=1, title="Stochastic RSI D")