该策略结合了8周期和21周期的指数移动平均线(EMA)以及抛物线SAR指标,旨在捕捉趋势并管理风险。策略根据特定的交叉和价格行为条件开仓和平仓,并定义了包括固定止损和强制在特定时间平仓的出场规则。
该策略使用两条不同周期的EMA(8周期和21周期)以及抛物线SAR指标来确定开仓和平仓条件。当短期EMA在长期EMA上方交叉,且收盘价高于SAR时,策略开多头仓位;当短期EMA在长期EMA下方交叉,且收盘价低于SAR时,策略开空头仓位。多头仓位在收盘价低于SAR时平仓,空头仓位在收盘价高于SAR时平仓。策略还设置了固定止损点数,以控制单笔交易的风险。此外,该策略要求在每个交易日的15:15强制平掉所有仓位。
EMA均线与抛物线SAR组合策略通过结合两种常用的技术指标,试图捕捉趋势并控制风险。该策略简单易懂,适合初学者学习和使用。然而,该策略也存在一些局限性,如对市场波动适应性不足,缺乏对市场情绪和基本面因素的考量等。因此,在实际应用中,需要根据具体市场和交易品种对策略进行优化和改进,以提高其稳定性和盈利能力。
/*backtest start: 2024-05-01 00:00:00 end: 2024-05-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("EMA and Parabolic SAR Strategy", overlay=true) // Input parameters for EMAs and Parabolic SAR emaShortPeriod = input.int(8, title="Short EMA Period") emaLongPeriod = input.int(21, title="Long EMA Period") sarStart = input.float(0.02, title="Parabolic SAR Start") sarIncrement = input.float(0.02, title="Parabolic SAR Increment") sarMaximum = input.float(0.2, title="Parabolic SAR Maximum") fixedSL = input.int(83, title="Fixed Stop Loss (pts)") // Calculate EMAs and Parabolic SAR emaShort = ta.ema(close, emaShortPeriod) emaLong = ta.ema(close, emaLongPeriod) sar = ta.sar(sarStart, sarIncrement, sarMaximum) // Entry conditions longCondition = ta.crossover(emaShort, emaLong) and close > sar shortCondition = ta.crossunder(emaShort, emaLong) and close < sar // Exit conditions longExitCondition = close < sar shortExitCondition = close > sar // Strategy entry and exit if (longCondition) strategy.entry("Long", strategy.long) if (shortCondition) strategy.entry("Short", strategy.short) if (longExitCondition) strategy.close("Long") if (shortExitCondition) strategy.close("Short") // Fixed Stop Loss strategy.exit("Long Exit", "Long", stop=close - fixedSL * syminfo.mintick) strategy.exit("Short Exit", "Short", stop=close + fixedSL * syminfo.mintick) // Exit all positions at 15:15 exitHour = 15 exitMinute = 15 exitTime = timestamp(year(timenow), month(timenow), dayofmonth(timenow), exitHour, exitMinute) if (timenow >= exitTime) strategy.close_all() // Plot EMAs and Parabolic SAR plot(emaShort, color=color.blue, title="8 EMA") plot(emaLong, color=color.red, title="21 EMA") plot(sar, style=plot.style_cross, color=color.green, title="Parabolic SAR")