
이 전략은 사용자 정의 G 채널과 지수 이동 평균 (EMA) 에 기반한 트렌드 추적 거래 시스템이다. G 채널은 상단 (a), 하단 (b) 및 중도 (avg) 로 구성되어 있으며, 현재 및 역사적 가격을 동적으로 계산하여 채널 경계를 결정한다. 이 전략은 EMA를 트렌드 필터로 결합하여 가격과 채널 라인의 교차 및 EMA와의 위치 관계를 통해 거래 신호를 생성하여 시장 트렌드 전환점을 효과적으로 포착한다.
전략의 핵심 논리에는 두 가지 주요 구성 요소가 포함되어 있습니다: G 채널과 EMA 필터. G 채널의 계산은 현재 가격과 역사 데이터를 기반으로, 적응 알고리즘을 통해 채널 폭을 동적으로 조정합니다. 상궤도 (a) 는 현재 가격과 이전 단계의 상궤도의 큰 값을 가져다가 채널 폭과 길이 파라미터에 따라 동적으로 조정합니다. 하궤도 (b) 는 유사한 방법을 사용하여 최소 값을 계산합니다. 중궤도는 상하궤도의 수학적 평균입니다.
G 통로와 EMA 트렌드 필터링 거래 시스템은 통로 돌파와 트렌드 추적을 결합한 완전한 거래 전략이다. G 통로의 역동적인 특성과 EMA의 트렌드 확인 기능을 통해 이 전략은 시장 전환점을 효과적으로 포착하고 거래 위험을 통제할 수 있다.
/*backtest
start: 2024-11-04 00:00:00
end: 2024-12-04 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("G-Channel with EMA Strategy", overlay=true)
// G-Channel Indicator
length = input.int(100, title="G-Channel Length")
src = input(close, title="Source")
var float a = na
var float b = na
a := math.max(src, nz(a[1])) - (nz(a[1]) - nz(b[1])) / length
b := math.min(src, nz(b[1])) + (nz(a[1]) - nz(b[1])) / length
avg = (a + b) / 2
// G-Channel buy/sell signals
crossup = ta.crossover(close, b)
crossdn = ta.crossunder(close, a)
bullish = ta.barssince(crossdn) <= ta.barssince(crossup)
// EMA Indicator
emaLength = input.int(200, title="EMA Length")
ema = ta.ema(close, emaLength)
// Buy Condition: G-Channel gives a buy signal and price is below EMA
buySignal = bullish and close < ema
// Sell Condition: G-Channel gives a sell signal and price is above EMA
sellSignal = not bullish and close > ema
// Plotting the G-Channel and EMA
plot(a, title="Upper", color=color.blue, linewidth=2, transp=100)
plot(b, title="Lower", color=color.blue, linewidth=2, transp=100)
plot(avg, title="Average", color=bullish ? color.lime : color.red, linewidth=1, transp=90)
plot(ema, title="EMA", color=color.orange, linewidth=2)
// Strategy Execution
if (buySignal)
strategy.entry("Buy", strategy.long)
if (sellSignal)
strategy.entry("Sell", strategy.short)
// Plot Buy/Sell Signals
plotshape(buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")