
Chiến lược này là một hệ thống giao dịch định lượng dựa trên tín hiệu bán tháo RSI và điểm dừng ATR động. Chiến lược sử dụng dữ liệu cấp độ ngày, kết hợp với tín hiệu bán tháo của chỉ số RSI và lọc xu hướng của đường trung bình 200 ngày, để nắm bắt cơ hội bật lên khi thị trường bán tháo. Chiến lược này sử dụng cơ chế bảo vệ kép cho điểm dừng ATR động và điểm dừng phần trăm tĩnh, và đặt mục tiêu lợi nhuận ba lần để tối đa hóa lợi nhuận bằng cách giảm vị trí theo giai đoạn.
Logic cốt lõi của chiến lược bao gồm các yếu tố chính sau:
Xu hướng phụ thuộc: Chiến lược có thể thường xuyên gây ra lỗ dừng trong thị trường biến động. Lưu ý: Bạn có thể thêm bộ lọc cho các tín hiệu giả trong chỉ số rung động.
Giảm lỗ lớn: Giảm lỗ cố định 25% có thể dẫn đến tổn thất quá lớn. Khuyến nghị: Điều chỉnh tỷ lệ dừng lỗ theo khả năng chịu rủi ro của cá nhân.
Rủi ro rút lui: Lợi nhuận phân đoạn có thể giảm vị thế quá sớm trong tình hình tăng trưởng mạnh. Đề xuất: Bạn có thể thay đổi mục tiêu lợi nhuận hoặc giữ một số vị trí theo xu hướng.
Chiến lược này xây dựng một hệ thống giao dịch hoàn chỉnh bằng cách kết hợp các tín hiệu bán tháo RSI và lọc xu hướng đồng nhất, kết hợp với ATR dừng động và mục tiêu lợi nhuận ba lần. Ưu điểm của chiến lược là khả năng kiểm soát rủi ro linh hoạt, quản lý lợi nhuận hợp lý, nhưng vẫn cần điều chỉnh tối ưu hóa theo tình hình thị trường thực tế và sở thích rủi ro cá nhân.
/*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"}]
*/
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA/4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © wielkieef
//@version=5
strategy("Simple RSI stock Strategy [1D] ", overlay=true, pyramiding=1, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=75, calc_on_order_fills=false, slippage=0, commission_type=strategy.commission.percent, commission_value=0.03)
// Rsi
oversoldLevel = input(30, title="Oversold Level")
overboughtLevel = input(70, title="Overbought Level")
rsi = ta.rsi(close, 5)
rsi_overbought = rsi > overboughtLevel
rsi_oversold = rsi < oversoldLevel
// Sma 200
lenghtSMA = input(200, title = "SMA lenght")
sma200 = ta.sma(close, lenghtSMA)
// ATR stop-loss
atrLength = input.int(20, title="ATR Length")
atrMultiplier = input.float(1.5, title="ATR Multiplier")
atrValue = ta.atr(atrLength)
var float long_stop_level = na
var float short_stop_level = na
var float tp1_level = na
var float tp2_level = na
var float tp3_level = na
// Strategy entry
long = (rsi_oversold ) and close > sma200
// Take Profit levels
tp_1 = input.float(5.0, "TP 1", minval=0.1, step=0.1)
tp_2 = input.float(10.0, "TP 2", minval=0.2, step=0.1)
tp_3 = input.float(15.0, "TP 3", minval=0.3, step=0.1)
if long
strategy.entry('Long', strategy.long)
long_stop_level := close - atrMultiplier * atrValue
tp1_level := strategy.position_avg_price * (1 + tp_1 / 100)
tp2_level := strategy.position_avg_price * (1 + tp_2 / 100)
tp3_level := strategy.position_avg_price * (1 + tp_3 / 100)
// basic SL - this code is from author RafaelZioni, modified by wielkieef
sl = input.float(25.0, 'Basic Stop Loss %', step=0.1)
per(procent) =>
strategy.position_size != 0 ? math.round(procent / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)
// ATR SL
if (strategy.position_size > 0 and (close <= long_stop_level))
strategy.close("Long")
tp1_level := na
tp2_level := na
tp3_level := na
plot(long_stop_level, color=color.orange, linewidth=2, title="Long Stop Loss")
// TP levels
if (strategy.position_size > 0)
if (not na(tp1_level) and close >= tp1_level)
tp1_level := na
if (not na(tp2_level) and close >= tp2_level)
tp2_level := na
if (not na(tp3_level) and close >= tp3_level)
tp3_level := na
plot(strategy.position_size > 0 and not na(tp1_level) ? tp1_level : na, color=color.gray, style=plot.style_circles , linewidth=1, title="Take Profit 1")
plot(strategy.position_size > 0 and not na(tp2_level) ? tp2_level : na, color=color.gray, style=plot.style_circles , linewidth=1, title="Take Profit 2")
plot(strategy.position_size > 0 and not na(tp3_level) ? tp3_level : na, color=color.gray, style=plot.style_circles , linewidth=1, title="Take Profit 3")
// Strategy exit points for Take Profits
strategy.exit('TP 1', from_entry="Long", qty_percent=33, profit=per(tp_1), loss=per(sl))
strategy.exit('TP 2', from_entry="Long", qty_percent=66, profit=per(tp_2), loss=per(sl))
strategy.exit('TP 3', from_entry="Long", qty_percent=100, profit=per(tp_3), loss=per(sl))
// by wielkieef