This strategy is a trend-following trading system that combines the Relative Strength Index (RSI) with Moving Average (MA). The core mechanism utilizes RSI to capture price momentum changes while incorporating a 90-day moving average as a trend filter, effectively tracking market trends. The strategy features adjustable RSI overbought/oversold thresholds and implements a 2500-day lookback period limitation to ensure practicality and stability.
The strategy is built on several core components:
Buy signals are triggered when RSI crosses above 70, while sell signals generate when RSI drops below 62. The system automatically calculates and executes full position entries when entry conditions are met within the valid lookback period.
Risk Control Recommendations:
Signal System Optimization:
Position Management Optimization:
Risk Control Optimization:
Backtesting System Optimization:
The strategy constructs a relatively complete trading system by combining RSI momentum indicator with MA trend filter. Its strengths lie in strong adaptability and comprehensive risk control, but attention must be paid to parameter sensitivity and market environment changes. Through the suggested optimization directions, the strategy has significant room for improvement to enhance its stability and profitability further.
/*backtest start: 2019-12-23 08:00:00 end: 2024-11-11 00:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Simple RSI Strategy - Adjustable Levels with Lookback Limit and 30-Day MA", overlay=true) // Parameters rsi_length = input.int(12, title="RSI Length", minval=1) // RSI period rsi_overbought = input.int(70, title="RSI Overbought Level", minval=1, maxval=100) // Overbought level rsi_oversold = input.int(62, title="RSI Oversold Level", minval=1, maxval=100) // Oversold level ma_length = input.int(90, title="Moving Average Length", minval=1) // Moving Average period // Calculate lookback period (2000 days) lookback_period = 2500 start_date = timestamp(year(timenow), month(timenow), dayofmonth(timenow) - lookback_period) // RSI Calculation rsi_value = ta.rsi(close, rsi_length) // 30-Day Moving Average Calculation ma_value = ta.sma(close, ma_length) // Buy Condition: Buy when RSI is above the overbought level long_condition = rsi_value > rsi_overbought // Sell Condition: Sell when RSI drops below the oversold level sell_condition = rsi_value < rsi_oversold // Check if current time is within the lookback period in_lookback_period = (time >= start_date) // Execute Buy with 100% equity if within lookback period if (long_condition and strategy.position_size == 0 and in_lookback_period) strategy.entry("Buy", strategy.long, qty=strategy.equity / close) if (sell_condition and strategy.position_size > 0) strategy.close("Buy") // Plot RSI on a separate chart for visualization hline(rsi_overbought, "Overbought", color=color.red) hline(rsi_oversold, "Oversold", color=color.green) plot(rsi_value, title="RSI", color=color.blue) // Plot the 30-Day Moving Average on the chart plot(ma_value, title="30-Day MA", color=color.orange, linewidth=2)