
This is a dynamic trading strategy based on the Relative Strength Index (RSI) combined with a flexible stop-loss mechanism. The strategy primarily targets oversold market conditions, aiming to capture price rebounds for profit. The core approach involves using the RSI indicator to identify potential oversold conditions, implementing percentage-based stop-losses for risk control, and utilizing previous high breakouts as profit-taking signals.
The strategy operates based on the following key elements: 1. RSI calculation uses a default period of 8, which is relatively short to quickly capture market oversold conditions. 2. Entry conditions are triggered when RSI falls below a threshold of 28, indicating potentially severe oversold conditions. 3. Stop-loss mechanism employs a percentage-based approach from entry price, defaulting to 5%, providing clear risk control boundaries. 4. Exit signals are based on price breakouts above previous highs, allowing profits to extend. 5. The strategy employs fixed position sizing and allows up to 2x pyramiding.
This well-designed trading strategy achieves a good balance between risk control and profit opportunity capture through the combination of RSI oversold conditions and stop-loss mechanisms. The strategy’s high adjustability makes it suitable for performance optimization under different market conditions. While there are some potential risks, the suggested optimization directions can further enhance the strategy’s stability and profitability.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI Strategy with Adjustable RSI and Stop-Loss", overlay=false,
default_qty_type=strategy.fixed, default_qty_value=2,
initial_capital=10000, pyramiding=2,
commission_type=strategy.commission.percent, commission_value=0.05,
slippage=1)
// Input fields for RSI parameters
rsi_length = input.int(8, title="RSI Length", minval=1)
rsi_threshold = input.float(28, title="RSI Threshold", minval=1, maxval=50)
// Input for Stop-Loss percentage
stop_loss_percent = input.float(5, title="Stop-Loss Percentage", minval=0.1, maxval=100)
// Calculate the RSI
rsi = ta.rsi(close, rsi_length)
// Condition for buying: RSI below the defined threshold
buyCondition = rsi < rsi_threshold
// Condition for selling: Close price higher than yesterday's high
sellCondition = close > ta.highest(high, 1)[1]
// Calculate the Stop-Loss level based on the entry price
var float stop_loss_level = na
if (buyCondition)
stop_loss_level := close * (1 - stop_loss_percent / 100)
strategy.entry("Long", strategy.long)
// Create Stop-Loss order
strategy.exit("Stop-Loss", from_entry="Long", stop=stop_loss_level)
// Selling signal
if (sellCondition)
strategy.close("Long")
// Optional: Plot the RSI for visualization
plot(rsi, title="RSI", color=color.blue)
hline(rsi_threshold, "RSI Threshold", color=color.red)