
이 글은 SuperTrend 지표와 Stochastic RSI 필터를 결합한 개선된 트렌드 추적 전략을 상세히 분석한다. 이 전략은 시장 추세를 고려하고 가짜 신호를 줄이는 동시에 구매 및 판매 신호를 생성하는 것을 목표로 한다.
먼저, 실제 변동 범위 ((TR) 와 평균 실제 변동 범위 ((ATR) 를 계산한다. 그리고 ATR를 사용하여 상반 및 하반의 변동 범위를 계산한다:
상반기 = SMA ((폐쇄 가격, ATR 주기) + ATR 곱하기 × ATR 하위 궤도 = SMA ((폐쇄 가격, ATR 주기) - ATR 곱하기 ATR
만약 종결 가격이 하반기보다 높으면 상승 트렌드; 만약 종결 가격이 상반기보다 낮으면 하반기 트렌드. 상승 트렌드에서, SuperTrend은 하반기; 하향 트렌드에서, SuperTrend은 상반기 트렌드.
가짜 신호를 줄이기 위해, SuperTrend을 이동 평균으로 처리하여 SuperTrend을 필터링합니다.
RSI의 값을 계산하고, 스토카스틱 지표를 적용하면 스토카스틱 RSI를 생성한다. 이것은 RSI가 과매매 또는 과매매 영역에 있는지 여부를 나타냅니다.
구매 조건: 종결 가격 상의 SuperTrend이 경계를 통과하고 상승 추세이며 Stochastic RSI < 80 판매 조건: 종결 가격 아래의 수퍼 트렌드, 하향 추세, 스토카스틱 RSI > 20
입출출: 마감 가격 아래에서 수퍼트렌드를 통과하고 상승 추세에 있습니다. 출구 판매: 종결 가격에서 상승한 슈퍼 트렌드 이후 하향 추세에 있다
이것은 개선된 트렌드 추적 전략으로, 간단한 이동 평균과 같은 지표에 비해 다음과 같은 장점이 있습니다:
이 전략은 SuperTrend와 Stochastic RSI 두 지표의 장점을 통합하여 트렌드를 효과적으로 식별하고 고품질의 거래 신호를 발산합니다. 또한 필터링 메커니즘은 시장의 소음에 대해 더 거칠게 만듭니다. 이 전략은 변수 최적화를 통해 더 나은 전략 효과를 얻을 수 있으며 다른 지표 또는 모델과 결합하는 것도 고려할 수 있습니다.
/*backtest
start: 2024-01-09 00:00:00
end: 2024-01-16 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Improved SuperTrend Strategy with Stochastic RSI", shorttitle="IST+StochRSI", overlay=true)
// Input parameters
atr_length = input(14, title="ATR Length")
atr_multiplier = input(1.5, title="ATR Multiplier")
filter_length = input(5, title="Filter Length")
stoch_length = input(14, title="Stochastic RSI Length")
smooth_k = input(3, title="Stochastic RSI %K Smoothing")
// Calculate True Range (TR) and Average True Range (ATR)
tr = ta.rma(ta.tr, atr_length)
atr = ta.rma(tr, atr_length)
// Calculate SuperTrend
upper_band = ta.sma(close, atr_length) + atr_multiplier * atr
lower_band = ta.sma(close, atr_length) - atr_multiplier * atr
is_uptrend = close > lower_band
is_downtrend = close < upper_band
super_trend = is_uptrend ? lower_band : na
super_trend := is_downtrend ? upper_band : super_trend
// Filter for reducing false signals
filtered_super_trend = ta.sma(super_trend, filter_length)
// Calculate Stochastic RSI
rsi_value = ta.rsi(close, stoch_length)
stoch_rsi = ta.sma(ta.stoch(rsi_value, rsi_value, rsi_value, stoch_length), smooth_k)
// Entry conditions
long_condition = ta.crossover(close, filtered_super_trend) and is_uptrend and stoch_rsi < 80
short_condition = ta.crossunder(close, filtered_super_trend) and is_downtrend and stoch_rsi > 20
// Exit conditions
exit_long_condition = ta.crossunder(close, filtered_super_trend) and is_uptrend
exit_short_condition = ta.crossover(close, filtered_super_trend) and is_downtrend
// Plot SuperTrend and filtered SuperTrend
plot(super_trend, color=color.orange, title="SuperTrend", linewidth=2)
plot(filtered_super_trend, color=color.blue, title="Filtered SuperTrend", linewidth=2)
// Plot Buy and Sell signals
plotshape(series=long_condition, title="Buy Signal", color=color.green, style=shape.triangleup, location=location.belowbar)
plotshape(series=short_condition, title="Sell Signal", color=color.red, style=shape.triangledown, location=location.abovebar)
// Output signals to the console for analysis
plotchar(long_condition, "Long Signal", "▲", location.belowbar, color=color.green, size=size.small)
plotchar(short_condition, "Short Signal", "▼", location.abovebar, color=color.red, size=size.small)
// Strategy entry and exit
strategy.entry("Long", strategy.long, when=long_condition)
strategy.entry("Short", strategy.short, when=short_condition)
strategy.close("Long", when=exit_long_condition)
strategy.close("Short", when=exit_short_condition)