
Đây là một chiến lược giao dịch động dựa trên chỉ số tương đối mạnh (RSI) kết hợp với cơ chế dừng lỗ linh hoạt. Chiến lược này chủ yếu nhắm vào các khu vực bán tháo của thị trường, thu lợi nhuận bằng cách nắm bắt cơ hội phục hồi của giá.
Chiến lược này hoạt động dựa trên các yếu tố quan trọng sau:
Đây là một chiến lược giao dịch được thiết kế tốt, kết hợp các phán quyết bán tháo RSI và cơ chế dừng lỗ, có sự cân bằng tốt giữa kiểm soát rủi ro và nắm bắt cơ hội lợi nhuận. Chiến lược có khả năng điều chỉnh mạnh mẽ, phù hợp để nâng cao hiệu suất thông qua tối ưu hóa tham số trong các môi trường thị trường khác nhau. Mặc dù có một số rủi ro tiềm ẩn, nhưng có thể nâng cao hơn nữa sự ổn định và lợi nhuận của chiến lược thông qua hướng tối ưu hóa được đề xuất.
/*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)