
이 전략은 다중 기술 지표의 결합으로 트렌드 추적 시스템, 주로 5 개의 다른 기간의 지수 이동 평균 (EMA), 상대적으로 강한 지표 (RSI) 및 두 개의 다른 기간의 돈치안 채널 (Donchian Channel) 을 통합합니다. 시스템은 다중 지표의 조합을 통해 시장 추세를 포착하고, 동적 스톱 손실과 수익 목표를 사용하여 위험과 수익을 관리합니다.
전략은 다층적인 기술 지표로 신호 확인을 한다: 먼저 5개의 EMA (9, 21, 55, 89, 144주기) 를 사용하여 트렌드 프레임워크를 구축하고, 빠른 EMA와 느린 EMA의 교차를 통해 초기 트렌드 방향을 결정한다. 다음으로, RSI (주기 14) 를 트렌드 필터로 사용하여, RSI가 초매권 (60 이상) 에서만 더 많이 허용하도록 하고, 초매권 (40 이하) 에서만 공백을 허용하도록 하고, 이렇게 하면 평형 시장에서 자주 거래되는 것을 피할 수 있다. 마지막으로, 21주기 및 74주기의 돈치안 통로를 통해 가격 변동 범위를 결정하고, 거래에 대한 더 많은 시장 구조를 제공한다.
이 전략은 여러 가지 기술 지표의 조합을 통해 비교적 완전한 거래 시스템을 구축한다. 약간의 지연이 있음에도 불구하고, 엄격한 신호 필터링과 위험 관리를 통해 트렌드 시장에서 안정적인 수익을 얻을 수 있다. 거래자는 실제 적용에서 특정 시장 특성과 자신의 위험 용량에 따라 매개 변수를 적절하게 조정하도록 권장한다. 동시에, 시스템의 성능을 지속적으로 모니터링하고, 정기적으로 최적화 방향을 평가하여 전략이 항상 시장 변화에 적응하도록 보장한다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-04 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA RSI Donchian Strategy", overlay=true)
// Input parameters
fastEmaLength = input(9, title="Fast EMA Length")
midEmaLength = input(21, title="Mid EMA Length")
slowEmaLength = input(55, title="Slow EMA Length")
ema89Length = input(89, title="89 EMA Length")
ema144Length = input(144, title="144 EMA Length")
rsiPeriod = input(14, title="RSI Period")
rsiOverbought = input(60, title="RSI Overbought Level")
rsiOversold = input(40, title="RSI Oversold Level")
donchianLength1 = input(21, title="Donchian Channel Length 1")
donchianLength2 = input(74, title="Donchian Channel Length 2")
// EMA calculations
fastEma = ta.ema(close, fastEmaLength)
midEma = ta.ema(close, midEmaLength)
slowEma = ta.ema(close, slowEmaLength)
ema89 = ta.ema(close, ema89Length)
ema144 = ta.ema(close, ema144Length)
// RSI calculation
rsi = ta.rsi(close, rsiPeriod)
// Donchian Channel calculations
donchianUpper1 = ta.highest(high, donchianLength1)
donchianLower1 = ta.lowest(low, donchianLength1)
donchianUpper2 = ta.highest(high, donchianLength2)
donchianLower2 = ta.lowest(low, donchianLength2)
donchianMid1 = (donchianUpper1 + donchianLower1) / 2
donchianMid2 = (donchianUpper2 + donchianLower2) / 2
// Plot EMAs
plot(fastEma, color=color.green, linewidth=2, title="Fast EMA")
plot(midEma, color=color.blue, linewidth=2, title="Mid EMA")
plot(slowEma, color=color.orange, linewidth=2, title="Slow EMA")
plot(ema89, color=color.red, linewidth=2, title="89 EMA")
plot(ema144, color=color.purple, linewidth=2, title="144 EMA")
// Plot Donchian Channels
plot(donchianUpper1, color=color.new(color.blue, 0), title="Donchian Upper 1")
plot(donchianLower1, color=color.new(color.blue, 0), title="Donchian Lower 1")
plot(donchianMid1, color=color.new(color.blue, 80), title="Donchian Mid 1")
plot(donchianUpper2, color=color.new(color.red, 0), title="Donchian Upper 2")
plot(donchianLower2, color=color.new(color.red, 0), title="Donchian Lower 2")
plot(donchianMid2, color=color.new(color.red, 80), title="Donchian Mid 2")
// Entry Conditions
longCondition = ta.crossover(fastEma, slowEma) and rsi > rsiOverbought
shortCondition = ta.crossunder(fastEma, slowEma) and rsi < rsiOversold
// Stop Loss and Take Profit
var float longStopLoss = na
var float longTakeProfit1 = na
var float longTakeProfit2 = na
var float shortStopLoss = na
var float shortTakeProfit1 = na
var float shortTakeProfit2 = na
if longCondition
longStopLoss := high * 0.99
longTakeProfit1 := longStopLoss * 1.02618
longTakeProfit2 := longStopLoss * 1.036185
strategy.entry("Long", strategy.long)
if shortCondition
shortStopLoss := low * 1.01
shortTakeProfit1 := shortStopLoss * 0.97382
shortTakeProfit2 := shortTakeProfit1 * 0.96381
strategy.entry("Short", strategy.short)
// Exit Conditions
if not na(longStopLoss)
strategy.exit("Take Profit 1", "Long", limit=longTakeProfit1)
strategy.exit("Take Profit 2", "Long", limit=longTakeProfit2)
strategy.exit("Stop Loss", "Long", stop=longStopLoss)
if not na(shortStopLoss)
strategy.exit("Take Profit 1", "Short", limit= shortTakeProfit1)
strategy.exit("Take Profit 2", "Short", limit=shortTakeProfit2)
strategy.exit("Stop Loss", "Short", stop=shortStopLoss)
// Labels for buy and sell signals
if longCondition
label.new(bar_index, low, "Buy", color=color.green, style=label.style_label_up, textcolor=color.white)
if shortCondition
label.new(bar_index, high, "Sell", color=color.red, style=label.style_label_down, textcolor=color.white)
// Alerts
alertcondition(longCondition, title="Long Entry Alert", message="Long entry signal")
alertcondition(shortCondition, title="Short Entry Alert", message="Short entry signal")