
이 전략은 부린 대역 (Bollinger Bands) 과 5 일 EMA를 결합하여 거래 신호를 생성합니다. 가격이 부린 대역을 초과하고 5 일 EMA보다 낮은 가격으로 닫히면 공백 포지션을 열고, 가격이 부린 대역을 벗어났을 때 5 일 EMA보다 낮은 가격으로 닫히면 다중 포지션을 열고, 반향 신호가 발생하면 기존 포지션을 해제하고 새로운 반향 포지션을 열고 있습니다. 이 전략은 시장의 변동성과 추세 변화를 포착하고, 부린을 통해 가격의 상대적인 높이를 판단하고, EMA를 트렌드의 으로 사용하여 거래 신호를 생성합니다.
이 전략은 브린띠와 EMA를 결합하여, 중장기 거래 전략에 적용되는 유동적 기회와 변동적 기회를 비교적 효과적으로 포착 할 수 있습니다. 그러나 파라미터의 최적화, 포지션의 제어 및 위험의 관리에 주의를 기울여야하며, 다른 기술 지표와 기본 분석과 결합하여 전략의 효과를 더 잘 발휘 할 수 있습니다. 전략의 성과는 시장 상태에 영향을 받을 수 있으며 실제 상황에 따라 조정 및 최적화가 필요합니다.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Bollinger Bands and EMA Strategy", overlay=true)
// Define the Bollinger Bands
length = input.int(20, title="BB Length")
src = input(close, title="BB Source")
mult = input.float(2.0, title="BB Multiplier")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
// Plot Bollinger Bands
plot(upper, "Upper Band", color=color.red)
plot(lower, "Lower Band", color=color.green)
plot(basis, "Middle Band", color=color.blue) // Use plot instead of hline for basis
// Define the 5-period EMA
ema5 = ta.ema(close, 5)
// Plot the 5 EMA
plot(ema5, "5 EMA", color=color.orange)
// Generate signals
var float entry_price = na
var string trade_direction = "none"
if (na(close[1]))
trade_direction := "none"
// Condition for entering a short trade
if (open > upper and close < ema5)
if (trade_direction != "short")
strategy.entry("Short", strategy.short)
entry_price := close
trade_direction := "short"
// Condition for entering a long trade
if (open < lower and close > ema5)
if (trade_direction != "long")
strategy.entry("Long", strategy.long)
entry_price := close
trade_direction := "long"
// Close short trade on a long signal
if (trade_direction == "short" and open < lower and close > ema5)
strategy.close("Short")
strategy.entry("Long", strategy.long)
entry_price := close
trade_direction := "long"
// Close long trade on a short signal
if (trade_direction == "long" and open > upper and close < ema5)
strategy.close("Long")
strategy.entry("Short", strategy.short)
entry_price := close
trade_direction := "short"
// Close trades when opposite signal is generated
if (trade_direction == "long" and open > upper and close < ema5)
strategy.close("Long")
trade_direction := "none"
if (trade_direction == "short" and open < lower and close > ema5)
strategy.close("Short")
trade_direction := "none"