This strategy is a trend-following trading system based on the custom G-Channel and Exponential Moving Average (EMA). The G-Channel consists of upper (a), lower (b), and middle (avg) lines, determining channel boundaries through dynamic calculation of current and historical prices. The strategy combines EMA as a trend filter, generating trading signals through price crossovers with channel lines and relative position to EMA, effectively capturing market trend reversal points.
The core logic comprises two main components: G-Channel and EMA filter. The G-Channel calculations are based on current prices and historical data, dynamically adjusting channel width through an adaptive algorithm. The upper line (a) takes the maximum of current price and previous upper line, adjusted by channel width and length parameters; the lower line (b) uses a similar method for minimum values; the middle line is the arithmetic mean. Trading signals are triggered by combining price crossovers with channel lines and relative position to EMA: buy signals occur when price breaks above the lower line while below EMA; sell signals when price breaks below the upper line while above EMA.
The G-Channel and EMA Trend Filter Trading System is a complete trading strategy combining channel breakouts and trend following. Through G-Channel’s dynamic characteristics and EMA’s trend confirmation function, the strategy effectively captures market turning points while controlling trading risks. Though certain limitations exist, the strategy’s overall performance can be further improved through the proposed optimization directions. This strategy is suitable for trending markets and can serve as a foundation framework for building more complex trading systems.
/*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")