这是一个结合了双周期移动平均线(21日和55日)、RSI动量指标和成交量的趋势跟踪策略。该策略通过分析价格、动量和成交量三个维度的市场信息,在确认趋势方向的同时,通过RSI和成交量指标对交易信号进行过滤,以提高交易的准确性。策略在价格突破短期均线且RSI突破均线的同时,要求成交量放大,从而确认趋势的有效性。
策略采用了三重过滤机制: 1. 价格过滤:使用21日和55日两个周期的移动平均线来确认价格趋势,当收盘价站上21日均线时视为潜在的做多机会 2. 动量过滤:计算13周期的RSI指标及其13周期均线,当RSI突破其均线时确认动量方向 3. 成交量过滤:计算21周期的成交量移动平均线,要求在入场时成交量大于其均线值,确认市场参与度
买入条件需同时满足: - 收盘价大于21日均线 - RSI大于其均线 - 成交量大于成交量均线
卖出条件满足以下任一即可: - 价格跌破55日均线 - RSI跌破其均线
这是一个综合运用技术分析三大要素(价格、成交量、动量)的趋势跟踪策略。通过多重过滤机制,策略在保证信号可靠性的同时,也具备了一定的风险控制能力。虽然存在一些固有的局限性,但通过持续优化和完善,该策略有望在实际交易中取得稳定的收益。特别是在趋势明确、流动性充足的市场中,策略的表现可能会更加理想。
/*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("21/55 MA with RSI Crossover", overlay=true)
// Inputs for moving averages
ma21_length = input.int(21, title="21-day Moving Average Length", minval=1)
ma55_length = input.int(55, title="55-day Moving Average Length", minval=1)
// RSI settings
rsi_length = input.int(13, title="RSI Length", minval=1)
rsi_avg_length = input.int(13, title="RSI Average Length", minval=1)
// Moving averages
ma21 = ta.sma(close, ma21_length)
ma55 = ta.sma(close, ma55_length)
// Volume settings
vol_ma_length = input.int(21, title="Volume MA Length", minval=1)
// Volume moving average
vol_ma = ta.sma(volume, vol_ma_length)
// RSI calculation
rsi = ta.rsi(close, rsi_length)
rsi_avg = ta.sma(rsi, rsi_avg_length)
// Buy condition
// buy_condition = close > ma21 and ta.crossover(rsi, rsi_avg) and volume > vol_ma
buy_condition = close > ma21 and rsi > rsi_avg and volume > vol_ma
// Sell condition
// sell_condition = close < ma55 or ta.crossunder(rsi, rsi_avg)
sell_condition = ta.crossunder(close, ma55) or ta.crossunder(rsi, rsi_avg)
// Execute trades
if (buy_condition)
strategy.entry("Buy", strategy.long, comment="Buy Signal")
if (sell_condition)
strategy.close("Buy", comment="Sell Signal")
// Plot moving averages for reference
plot(ma21, color=color.blue, title="21-day MA")
plot(ma55, color=color.red, title="55-day MA")
// Plot RSI and RSI average for reference
rsi_plot = input.bool(true, title="Show RSI?", inline="rsi")
plot(rsi_plot ? rsi : na, color=color.green, title="RSI")
plot(rsi_plot ? rsi_avg : na, color=color.orange, title="RSI Average")