该策略结合了一目均衡图云以及短期(55)和长期(200)简单移动平均线(SMA)来识别潜在的买卖信号。买入信号需要价格高于云层和长期SMA,并在上穿短期SMA后回踩短期SMA。卖出信号需要价格低于云层和长期SMA,并在下穿短期SMA后回踩短期SMA。该策略避免在横盘市或重大新闻事件期间产生信号,因为这些时期虚假信号较多。回测表明该策略在1小时和2小时时间框架上表现最佳。
该策略基于以下原则: 1. 当价格高于云层和长期SMA时,市场处于上升趋势。 2. 当价格低于云层和长期SMA时,市场处于下降趋势。 3. 短期SMA的上穿和下穿可以确认趋势,回踩短期SMA提供低风险入场机会。 4. 横盘市和重大新闻事件期间虚假信号较多,应该避免交易。
程序首先计算所需的一目云组件(转换线、基准线、先行span A和B),以及短期和长期SMA。然后定义多个条件来识别价格相对于云层和均线的位置。当满足所有买入/卖出条件时,程序分别产生买入和卖出信号。
该”一云多均线交易策略”通过结合一目均衡图云和简单移动平均线,在已确立的趋势中寻找回踩均线的低风险入场机会。通过过滤掉横盘市和重大新闻事件期间的交易,该策略能够降低虚假信号风险,从而提高整体表现。策略主要适用于中长期交易者,在1小时和2小时等时间框架上表现良好。但该策略仍有进一步优化空间,如引入明确止损位、优化信号组合、对参数进行调试等,以期获得更加稳健的策略表现。
/*backtest start: 2023-05-11 00:00:00 end: 2024-05-16 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Ichimoku Cloud and Moving Average Strategy", shorttitle="ICMA", overlay=true) // Input parameters shortMA = input.int(55, title="Short-term Moving Average Length") longMA = input.int(200, title="Long-term Moving Average Length") // Calculate moving averages shortSMA = ta.sma(close, shortMA) longSMA = ta.sma(close, longMA) // Ichimoku Cloud settings conversionPeriod = input.int(9, title="Conversion Line Period") basePeriod = input.int(26, title="Base Line Period") spanBPeriod = input.int(52, title="Span B Period") displacement = input.int(26, title="Displacement") // Calculate Ichimoku Cloud components conversionLine = ta.sma(high + low, conversionPeriod) / 2 baseLine = ta.sma(high + low, basePeriod) / 2 leadSpanA = (conversionLine + baseLine) / 2 leadSpanB = ta.sma(high + low, spanBPeriod) / 2 // Plot Ichimoku Cloud components plot(leadSpanA, color=color.blue, title="Leading Span A") plot(leadSpanB, color=color.red, title="Leading Span B") // Entry conditions aboveCloud = close > leadSpanA and close > leadSpanB belowCloud = close < leadSpanA and close < leadSpanB aboveShortMA = close > shortSMA aboveLongMA = close > longSMA belowShortMA = close < shortSMA belowLongMA = close < longSMA // Buy condition (Price retests 55 moving average after being above it) buyCondition = aboveCloud and aboveLongMA and close[1] < shortSMA and close > shortSMA // Sell condition (Price retests 55 moving average after being below it) sellCondition = belowCloud and belowLongMA and close[1] > shortSMA and close < shortSMA // Strategy entry and exit strategy.entry("Buy", strategy.long, when = buyCondition) strategy.entry("Sell", strategy.short, when = sellCondition) // Plot moving averages plot(shortSMA, color=color.green, title="Short-term SMA") plot(longSMA, color=color.red, title="Long-term SMA") // Plot buy and sell signals plotshape(series=buyCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal") plotshape(series=sellCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")