均线突破陷阱策略是一种多时间框架通用的交易工具,适用于1分钟和1小时时间框架。该策略利用21日移动平均线识别重要的市场趋势,同时运用ATR指标识别潜在的多头和空头陷阱。该策略获利率高达85%,在最佳环境下可达88%。
该策略首先计算21日指数移动平均线,以判断总体趋势和方向。然后计算最近N天的最高价和最低价(N是可调参数)。如果收盘价高于最近一日最高价,并且随后低点已跌破最近最高价与ATR指标相乘后的价位,同时收盘价已跌破21日线,则判定为多头陷阱信号。空头陷阱信号判断逻辑类似。
一旦识别出陷阱信号,就按照最近最高价与最低价之间的距离的80%设定止损止盈,进行反向操作。例如识别多头陷阱后,就做空头交易并设置止盈止损;识别空头陷阱后,做多头交易并设置止盈止损。
可通过优化EMA参数,调整ATR系数,动态 trailing stoploss等方法降低风险。
均线突破陷阱策略整合趋势判断和陷阱识别的优点,回撤小、获利率高,适合多种交易风格,是值得推荐的高效策略。可通过参数优化和机制优化进一步增强稳定性和获利空间。
/*backtest start: 2023-02-14 00:00:00 end: 2024-02-20 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Bull and Bear Trap Strategy with EMA 21 - 1min Chart", overlay=true) // Inputs length = input(5, "Length") atrMultiplier = input(1.0, "ATR Multiplier") emaLength = input(21, "EMA Length") price = close atr = ta.atr(length) // EMA Calculation ema21 = ta.ema(price, emaLength) // Define recent high and low recentHigh = ta.highest(high, length) recentLow = ta.lowest(low, length) // Bull and Bear Trap Detection bullTrap = price > recentHigh[1] and low <= recentHigh - atr * atrMultiplier and price < ema21 bearTrap = price < recentLow[1] and high >= recentLow + atr * atrMultiplier and price > ema21 // Plotting plotshape(series=bullTrap, title="Bull Trap", location=location.abovebar, color=color.red, style=shape.triangleup, size=size.small) plotshape(series=bearTrap, title="Bear Trap", location=location.belowbar, color=color.green, style=shape.triangledown, size=size.small) plot(ema21, title="EMA 21", color=color.blue) // Measured Move Implementation moveSize = recentHigh - recentLow targetDistance = moveSize * 0.8 // Target at 80% of the move size // Strategy Execution with Measured Move Targets if (bullTrap) strategy.entry("Enter Short (Sell)", strategy.short) strategy.exit("Exit Short (Buy to Cover)", "Enter Short (Sell)", limit=price - targetDistance) if (bearTrap) strategy.entry("Enter Long (Buy)", strategy.long) strategy.exit("Exit Long (Sell)", "Enter Long (Buy)", limit=price + targetDistance)