该策略基于RSI指标和两条EMA线的交叉信号来判断买卖点。当收盘价跌破EMA100和EMA20,且RSI值低于30时产生买入信号;当收盘价突破EMA100和EMA20,且RSI值高于70时产生卖出信号。该策略的主要思路是利用RSI指标判断超买超卖情况,同时结合EMA线的趋势判断,以此来捕捉市场的波动低点和高点,进行低吸高抛操作。
RSI与双EMA交叉信号量化策略是一个简单实用的量化交易策略,通过将RSI指标与EMA均线相结合,能较好地捕捉震荡行情中的高低点,进行差价套利。但是该策略也存在一些局限性和风险,如趋势行情下失效,缺乏仓位管理和风控措施等。因此在实际应用中还需要根据市场特点和个人偏好进行适当的优化和改进,以提高策略的稳健性和盈利能力。该策略可以作为量化交易的入门策略来学习和使用,但需要谨慎对待,严格控制风险。
/*backtest start: 2024-03-01 00:00:00 end: 2024-03-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("RSI-EMA100&20 Buy/Sell Signal", overlay=true) // Input parameters rsiLength = input.int(14, "RSI Length") emaCloseLength = input.int(100, "EMA Length (Closing Price)") emaLowLength = input.int(20, "EMA Length (Low Price)") oversoldLevel = input.int(30, "Oversold Level") overboughtLevel = input.int(70, "Overbought Level") // Calculate RSI rsi = ta.rsi(close, rsiLength) // Calculate EMA of closing price emaClose = ta.ema(close, emaCloseLength) // Calculate EMA of low price emaLow = ta.ema(low, emaLowLength) // Determine overbought and oversold conditions isOversold = rsi <= oversoldLevel isOverbought = rsi >= overboughtLevel // Plot RSI and its EMAs plot(rsi, color=color.blue, title="RSI") plot(emaClose, color=color.green, title="EMA 100 (Closing Price)") plot(emaLow, color=color.orange, title="EMA 20 (Low Price)") // Strategy entry condition: Closing price is below both EMAs and RSI is less than or equal to oversold level buySignal = close < emaClose and close < emaLow and isOversold // Plot buy signals plotshape(series=buySignal, style=shape.triangleup, location=location.abovebar, color=color.green, size=size.small) // Strategy entry if (buySignal) strategy.entry("Buy", strategy.long) // Strategy exit condition: Price crosses above both EMAs and RSI is greater than or equal to overbought level sellSignal = close > emaClose and close > emaLow and isOverbought // Plot sell signals plotshape(series=sellSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small) // Strategy exit if (sellSignal) strategy.entry("Sell", strategy.short) // Plot sell signals plotshape(series=sellSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small) // Strategy exit if (sellSignal) strategy.entry("Sell", strategy.short)