该策略是一个结合了G通道(G-Channel)和指数移动平均线(EMA)的量化交易系统。策略核心是通过G通道捕捉市场趋势方向,同时利用EMA进行信号确认和风险控制,从而在市场双向波动中获取收益。策略采用全自动化交易模式,不需要人工干预。
策略运作基于两个核心指标:G通道和EMA。G通道通过动态计算上下轨道来识别价格趋势,当价格突破通道时发出交易信号。具体来说,策略使用100周期的G通道计算,通过数学公式不断更新通道的上下边界。同时,策略引入50周期的EMA作为二次确认,只有当价格与EMA的相对位置符合预期时才执行交易。买入条件是G通道发出做多信号且收盘价位于EMA下方,卖出条件是G通道发出做空信号且收盘价位于EMA上方。
该策略通过结合G通道和EMA两个技术指标,构建了一个稳健的量化交易系统。策略逻辑清晰,实现简单,具有较好的可扩展性。通过合理的参数优化和风险控制措施,该策略有望在实盘交易中取得稳定收益。建议在实盘应用时结合市场特征进行针对性优化,并严格执行风险管理制度。
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-18 08:00:00 period: 1d basePeriod: 1d 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/ // © stanleygao01 //@version=5 strategy('G-Channel with EMA Strategy', overlay=true) // G-Channel parameters length = input(100, title='G-Channel Length') src = input(close, title='Source') a = 0.0 b = 0.0 a := math.max(src, nz(a[1])) - nz(a[1] - b[1]) / length b := math.min(src, nz(b[1])) + nz(a[1] - b[1]) / length avg = math.avg(a, b) crossup = b[1] < close[1] and b > close crossdn = a[1] < close[1] and a > close bullish = ta.barssince(crossdn) <= ta.barssince(crossup) // EMA parameters emaLength = input(50, title='EMA Length') ema = ta.ema(close, emaLength) // Buy and Sell Conditions buyCondition = bullish and close < ema sellCondition = not bullish and close > ema // Plot G-Channel c = bullish ? color.lime : color.red p1 = plot(avg, title='Average', color=c, linewidth=1, transp=90) p2 = plot(close, title='Close Price', color=c, linewidth=1, transp=100) fill(p1, p2, color=c, transp=90) // Plot EMA plot(ema, title='EMA', color=color.new(color.blue, 0), linewidth=2) // Strategy Entries and Exits if buyCondition strategy.entry('Buy', strategy.long) if sellCondition strategy.close('Buy') // Plot Buy/Sell Labels plotshape(buyCondition, title='Buy Signal', location=location.belowbar, color=color.new(color.lime, 0), style=shape.labelup, text='Buy') plotshape(sellCondition, title='Sell Signal', location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text='Sell')