
이 전략은 슈퍼 트렌드 지표와 부린 밴드 지표를 결합하여 시장의 트렌드 기회를 잡기 위해 고안되었습니다. 슈퍼 트렌드 지표는 현재 시장의 트렌드 방향을 판단하는 데 사용되며, 부린 밴드 지표는 시장의 변동률을 측정합니다.
슈퍼 트렌드 브린 밴드 포지션 전략은 트렌드 추적형 전략으로, 트렌드 및 변동률 두 가지 시장 요소를 결합하여 트렌드 기회를 비교적 효과적으로 포착 할 수 있습니다. 그러나 이 전략에는 파라미터에 민감하고, 높은 변동률 환경에서 위험이 증가하는 등의 제한이 있습니다. 따라서 실제 응용에서는 시장 특성과 자체 위험 선호도에 따라 전략에 적절한 최적화 및 개선이 필요합니다.
/*backtest
start: 2024-03-21 00:00:00
end: 2024-03-28 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sabhiv27
//@version=4
strategy("Supertrend & Bollinger Bands Strategy", shorttitle="ST_BB_Strategy", overlay=true)
// Input options
factor = input(3, title="Supertrend Factor")
length = input(10, title="ATR Length")
bollinger_length = input(20, title="Bollinger Bands Length")
bollinger_deviation = input(2, title="Bollinger Bands Deviation")
// Calculate True Range for Supertrend
truerange = rma(tr, length)
// Calculate Supertrend
var float up_trend = na
var float dn_trend = na
var float trend = na
up_signal = hl2 - (factor * truerange)
dn_signal = hl2 + (factor * truerange)
up_trend := close[1] > up_trend[1] ? max(up_signal, up_trend[1]) : up_signal
dn_trend := close[1] < dn_trend[1] ? min(dn_signal, dn_trend[1]) : dn_signal
trend := close > dn_trend ? 1 : close < up_trend ? -1 : nz(trend[1], 1)
// Calculate Bollinger Bands
basis = sma(close, bollinger_length)
dev = stdev(close, bollinger_length)
upper_band = basis + bollinger_deviation * dev
lower_band = basis - bollinger_deviation * dev
// Entry conditions
long_condition = crossover(close, up_trend) and close < lower_band
short_condition = crossunder(close, dn_trend) and close > upper_band
// Exit conditions
exit_long_condition = crossover(close, dn_trend)
exit_short_condition = crossunder(close, up_trend)
// Plot Supertrend
plot(trend == 1 ? up_trend : dn_trend, color=trend == 1 ? color.green : color.red, linewidth=2)
// Plot Bollinger Bands
plot(upper_band, color=color.blue)
plot(lower_band, color=color.blue)
// Generate buy and sell signals
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)