
This is a trend-following strategy that combines dual-period moving averages (21-day and 55-day), RSI momentum indicator, and volume analysis. The strategy analyzes market information from three dimensions - price, momentum, and volume - while confirming trend direction and filtering trading signals through RSI and volume indicators to improve trading accuracy. The strategy requires price breakthrough of short-term moving average, RSI crossing above its average, and increased volume to confirm trend validity.
The strategy employs a triple-filtering mechanism: 1. Price Filter: Uses 21-day and 55-day moving averages to confirm price trends, with prices above 21-day MA indicating potential long opportunities 2. Momentum Filter: Calculates 13-period RSI and its 13-period average, confirming momentum direction when RSI crosses above its average 3. Volume Filter: Calculates 21-period volume moving average, requiring entry volume to exceed its average, confirming market participation
Buy conditions require all of the following: - Close price above 21-day MA - RSI above its average - Volume above volume MA
Sell conditions require any of the following: - Price falls below 55-day MA - RSI falls below its average
This is a trend-following strategy that comprehensively utilizes the three essential elements of technical analysis (price, volume, momentum). Through multiple filtering mechanisms, the strategy ensures signal reliability while maintaining risk control capabilities. Although it has some inherent limitations, through continuous optimization and improvement, the strategy has the potential to achieve stable returns in actual trading. The strategy may perform particularly well in markets with clear trends and sufficient liquidity.
/*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")