本策略结合了相位交叉信号和多周期指数移动平均线,通过平滑振荡器的交叉和EMA趋势来捕捉市场的买卖机会。该策略使用了领先相位(Leading Phase)和滞后相位(Lagging Phase)的交叉来产生交易信号,同时结合了13、26、50、100和200周期的指数移动平均线来确认市场趋势,提供了一个全面的趋势跟踪和短期交易的解决方案。
策略的核心逻辑包含两个主要部分:相位交叉系统和EMA趋势确认系统。相位交叉系统使用了带有上移偏移的简单移动平均线(SMA)作为领先相位,以及带有下移偏移的指数移动平均线(EMA)作为滞后相位。当领先相位上穿滞后相位时产生买入信号,下穿时产生卖出信号。EMA趋势确认系统则使用了多周期(13/26/50/100/200)的指数移动平均线来确认整体市场趋势,其中13期和26期EMA的交叉作为次级交易信号。
该策略通过结合相位交叉和多周期EMA系统,构建了一个全面的趋势跟踪交易系统。策略具有信号明确、趋势把握准确、风险控制合理等优势,但同时也存在一定的滞后性和假信号风险。通过添加波动率过滤、成交量确认等优化措施,可以进一步提升策略的稳定性和可靠性。该策略适合在趋势明显的市场中应用,交易者需要根据具体市场特征和个人风险偏好进行参数调整。
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-08 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Phase Cross Strategy with Zone", overlay=true)
// Inputs
length = input.int(20, title="Smoothing Length")
source = input(close, title="Source")
offset = input.float(0.5, title="Offset Amount", minval=0.0) // Offset for spacing
// Simulating "Phases" with Smoothed Oscillators
lead_phase = ta.sma(source, length) + offset // Leading phase with offset
lag_phase = ta.ema(source, length) - offset // Lagging phase with offset
// Signal Logic
buySignal = ta.crossover(lead_phase, lag_phase)
sellSignal = ta.crossunder(lead_phase, lag_phase)
// Plot Phases (as `plot` objects for `fill`)
lead_plot = plot(lead_phase, color=color.green, title="Leading Phase", linewidth=1)
lag_plot = plot(lag_phase, color=color.red, title="Lagging Phase", linewidth=1)
// Fill Zone Between Phases
fill_color = lead_phase > lag_phase ? color.new(color.green, 90) : color.new(color.red, 90)
fill(plot1=lead_plot, plot2=lag_plot, color=fill_color, title="Phase Zone")
// Plot Buy and Sell Signals
plotshape(buySignal, style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), title="Buy Signal", size=size.small)
plotshape(sellSignal, style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), title="Sell Signal", size=size.small)
// Strategy Entry and Exit
if buySignal
strategy.entry("Buy", strategy.long)
if sellSignal
strategy.close("Buy")
//indicator("EMA 13, 26, 50, 100, and 200 with Crossover, Value Zone, and Special Candles", overlay=true)
// Define the EMAs
ema13 = ta.ema(close, 13)
ema26 = ta.ema(close, 26)
ema50 = ta.ema(close, 50)
ema100 = ta.ema(close, 100)
ema200 = ta.ema(close, 200)
// Plot the EMAs
plot(ema13, color=color.blue, linewidth=2, title="EMA 13")
plot(ema26, color=color.red, linewidth=2, title="EMA 26")
plot(ema50, color=color.orange, linewidth=2, title="EMA 50")
plot(ema100, color=color.green, linewidth=2, title="EMA 100")
plot(ema200, color=color.purple, linewidth=2, title="EMA 200")
// Crossover conditions
uptrend = ta.crossover(ema13, ema26) // EMA 13 crosses above EMA 26 (buy)
downtrend = ta.crossunder(ema13, ema26) // EMA 13 crosses below EMA 26 (sell)
// Plot buy/sell arrows
plotshape(series=uptrend, location=location.belowbar, color=color.green, style=shape.labelup, size=size.small, title="Buy Signal")
plotshape(series=downtrend, location=location.abovebar, color=color.red, style=shape.labeldown, size=size.small, title="Sell Signal")