
Chiến lược này là hệ thống giao dịch đảo ngược động lượng kết hợp các chỉ báo kỹ thuật kép RSI và Bollinger Bands để giao dịch bằng cách xác định các vùng quá mua và quá bán. Chiến lược này sử dụng tỷ lệ rủi ro-lợi nhuận là 1:2 và kết hợp lệnh dừng lỗ di động để kiểm soát rủi ro. Nguyên tắc cốt lõi là giao dịch khi cả RSI và Bollinger Bands đều cho thấy tín hiệu quá mua hoặc quá bán cùng một lúc và bảo vệ tiền thông qua quản lý rủi ro chặt chẽ.
Chiến lược này sử dụng RSI 14 kỳ và Bollinger Bands 20 kỳ làm chỉ báo chính. Các điều kiện mua phải được đáp ứng đồng thời: RSI dưới 30 (quá bán) và giá chạm hoặc giảm xuống dưới Dải Bollinger dưới. Các điều kiện bán phải được đáp ứng cùng lúc: RSI trên 70 (mua quá mức) và giá chạm hoặc vượt quá Dải Bollinger trên. Hệ thống sử dụng điểm cao nhất/thấp nhất của 5 đường K làm điểm dừng lỗ di động và vị thế chốt lời gấp đôi khoảng cách dừng lỗ, thực hiện nghiêm ngặt tỷ lệ rủi ro-lợi nhuận là 1:2.
Đây là một chiến lược giao dịch đảo chiều có cấu trúc tốt, sử dụng các chỉ báo kỹ thuật kép để tăng độ chính xác và áp dụng quản lý rủi ro chặt chẽ. Mặc dù chiến lược này đơn giản và trực quan, nhưng nó chứa đựng những yếu tố chính cần thiết cho một hệ thống giao dịch hoàn thiện. Thông qua các hướng tối ưu hóa được đề xuất, chiến lược này vẫn còn có thể được cải thiện thêm. Trong giao dịch thực tế, trước tiên bạn nên tiến hành kiểm tra ngược và tối ưu hóa tham số.
/*backtest
start: 2024-12-06 00:00:00
end: 2025-01-04 08:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI + Bollinger Bands with 1:2 Risk/Reward", overlay=true)
// Define Inputs
length_rsi = input.int(14, title="RSI Period")
oversold_level = input.int(30, title="RSI Oversold Level")
overbought_level = input.int(70, title="RSI Overbought Level")
length_bb = input.int(20, title="Bollinger Bands Period")
src = close
risk_to_reward = input.float(2.0, title="Risk-to-Reward Ratio", minval=1.0, step=0.1)
// Calculate Indicators
rsi_value = ta.rsi(src, length_rsi)
basis = ta.sma(src, length_bb)
dev = ta.stdev(src, length_bb)
upper_band = basis + 2 * dev
lower_band = basis - 2 * dev
// Define Buy and Sell Conditions
rsi_buy_condition = rsi_value < oversold_level // RSI below 30 (buy signal)
bollinger_buy_condition = close <= lower_band // Price at or near lower Bollinger Band (buy signal)
rsi_sell_condition = rsi_value > overbought_level // RSI above 70 (sell signal)
bollinger_sell_condition = close >= upper_band // Price at or near upper Bollinger Band (sell signal)
// Combine Buy and Sell Conditions
buy_condition = rsi_buy_condition and bollinger_buy_condition
sell_condition = rsi_sell_condition and bollinger_sell_condition
// Plot Buy and Sell Signals with white text and green/red boxes
plotshape(series=buy_condition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY", textcolor=color.white, size=size.small)
plotshape(series=sell_condition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL", textcolor=color.white, size=size.small)
// Calculate Swing Points (for Stop Loss)
swing_low = ta.lowest(low, 5) // Last 5 bars' low
swing_high = ta.highest(high, 5) // Last 5 bars' high
// Calculate Risk (Distance from Entry to SL)
long_risk = close - swing_low
short_risk = swing_high - close
// Calculate Take Profit using 1:2 Risk-to-Reward Ratio
take_profit_long = close + 2 * long_risk
take_profit_short = close - 2 * short_risk
// Strategy Execution: Enter Buy/Sell Positions
if buy_condition
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit", "Buy", limit=take_profit_long, stop=swing_low) // Set TP and SL for Buy
if sell_condition
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit", "Sell", limit=take_profit_short, stop=swing_high) // Set TP and SL for Sell
// Plotting the Indicators for Visualization (Optional - comment out if not needed)
plot(rsi_value, color=color.blue, title="RSI", linewidth=2, display=display.none)
plot(upper_band, color=color.red, title="Upper BB", display=display.none)
plot(lower_band, color=color.green, title="Lower BB", display=display.none)