本策略是一个结合了指数移动平均线(EMA)交叉和一目云图(Ichimoku Cloud)的复合型交易系统。EMA交叉主要用于捕捉趋势启动信号并确认买入时机,而一目云图则用于识别市场转向和确定卖出时机。该策略通过多维度技术指标的协同配合,既能有效把握趋势,又能及时规避风险。
策略运行机制主要包含两个核心部分: 1. EMA交叉买入信号:利用短周期(9日)和长周期(21日)指数移动平均线的交叉来确认趋势方向。当短期EMA向上穿越长期EMA时,表明短期动能增强,产生买入信号。 2. 一目云图卖出信号:通过价格与云图的位置关系以及云图内部结构来判断趋势转向。当价格跌破云图下边界或者先行带A跌破先行带B时,触发卖出信号。策略同时设置了止损和获利了结机制,止损设在1.5%,获利目标为3%。
该策略通过EMA交叉和一目云图的有机结合,构建了一个兼具趋势跟踪和反转捕捉能力的交易系统。策略设计合理,风险控制到位,具有较好的实战应用价值。通过建议的优化方向,策略还有进一步提升的空间。在实盘应用时,建议先通过回测确定适合的参数组合,并根据实际市场情况进行动态调整。
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-04 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover Buy + Ichimoku Cloud Sell Strategy", overlay=true)
// Input Parameters for the EMAs
shortEmaPeriod = input.int(9, title="Short EMA Period", minval=1)
longEmaPeriod = input.int(21, title="Long EMA Period", minval=1)
// Input Parameters for the Ichimoku Cloud
tenkanPeriod = input.int(9, title="Tenkan-Sen Period", minval=1)
kijunPeriod = input.int(26, title="Kijun-Sen Period", minval=1)
senkouSpanBPeriod = input.int(52, title="Senkou Span B Period", minval=1)
displacement = input.int(26, title="Displacement", minval=1)
// Calculate the EMAs
shortEma = ta.ema(close, shortEmaPeriod)
longEma = ta.ema(close, longEmaPeriod)
// Ichimoku Cloud Calculations
tenkanSen = ta.sma(close, tenkanPeriod)
kijunSen = ta.sma(close, kijunPeriod)
senkouSpanA = ta.sma(tenkanSen + kijunSen, 2)
senkouSpanB = ta.sma(close, senkouSpanBPeriod)
chikouSpan = close[displacement]
// Plot the EMAs on the chart
plot(shortEma, color=color.green, title="Short EMA")
plot(longEma, color=color.red, title="Long EMA")
// Plot the Ichimoku Cloud
plot(tenkanSen, color=color.blue, title="Tenkan-Sen")
plot(kijunSen, color=color.red, title="Kijun-Sen")
plot(senkouSpanA, color=color.green, title="Senkou Span A", offset=displacement)
plot(senkouSpanB, color=color.purple, title="Senkou Span B", offset=displacement)
plot(chikouSpan, color=color.orange, title="Chikou Span", offset=-displacement)
// Buy Condition: Short EMA crosses above Long EMA
buyCondition = ta.crossover(shortEma, longEma)
// Sell Condition: Tenkan-Sen crosses below Kijun-Sen, and price is below the cloud
sellCondition = ta.crossunder(tenkanSen, kijunSen) and close < senkouSpanA and close < senkouSpanB
// Plot Buy and Sell signals
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Execute Buy and Sell Orders
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Optional: Add Stop Loss and Take Profit (risk management)
stopLossPercentage = input.float(1.5, title="Stop Loss Percentage", minval=0.1) / 100
takeProfitPercentage = input.float(3.0, title="Take Profit Percentage", minval=0.1) / 100
longStopLoss = close * (1 - stopLossPercentage)
longTakeProfit = close * (1 + takeProfitPercentage)
shortStopLoss = close * (1 + stopLossPercentage)
shortTakeProfit = close * (1 - takeProfitPercentage)
strategy.exit("Take Profit/Stop Loss", "Buy", stop=longStopLoss, limit=longTakeProfit)
strategy.exit("Take Profit/Stop Loss", "Sell", stop=shortStopLoss, limit=shortTakeProfit)