
Chiến lược này là một hệ thống giao dịch định lượng dựa trên sự kết hợp giữa hình dạng giá và các chỉ số kỹ thuật. Nó chủ yếu được giao dịch bằng cách xác định các đột phá hình dạng tam giác và kết hợp với xác nhận động lực của chỉ số RSI. Chiến lược sử dụng phương pháp hồi quy tuyến tính để xây dựng đường xu hướng lên xuống, xác định tín hiệu giao dịch thông qua vị trí giá và RSI, thực hiện sự kết hợp hữu cơ của phân tích hình dạng với phân tích động lực.
Lịch lý cốt lõi của chiến lược bao gồm hai phần chính: nhận dạng hình dạng tam giác và xác nhận động lực RSI. Đầu tiên, sử dụng phương pháp hồi quy tuyến tính toán các điểm cao và thấp trong N chu kỳ gần đây nhất để xây dựng đường xu hướng lên xuống tạo thành tam giác.
Chiến lược đột phá tam giác kết hợp với động lực RSI là một hệ thống giao dịch định lượng có cấu trúc, logic rõ ràng. Bằng cách xác nhận cơ chế kép hình thức và động lực, hiệu quả nâng cao độ tin cậy của tín hiệu giao dịch. Mặc dù có một số rủi ro, nhưng thông qua các biện pháp tối ưu hóa tham số và kiểm soát rủi ro hợp lý, chiến lược này có giá trị thực tế tốt.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-04 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Triangle Breakout with RSI", overlay=true)
// Input parameters
len = input.int(15, title="Triangle Length")
rsiPeriod = input.int(14, title="RSI Period")
rsiThresholdBuy = input.int(50, title="RSI Threshold for Buy")
rsiThresholdSell = input.int(50, title="RSI Threshold for Sell")
// Calculate the RSI
rsi = ta.rsi(close, rsiPeriod)
// Calculate highest high and lowest low for triangle pattern
highLevel = ta.highest(high, len)
lowLevel = ta.lowest(low, len)
// Create trendlines for the triangle
upperTrend = ta.linreg(high, len, 0)
lowerTrend = ta.linreg(low, len, 0)
// Plot the trendlines on the chart
plot(upperTrend, color=color.green, linewidth=2, title="Upper Trendline")
plot(lowerTrend, color=color.red, linewidth=2, title="Lower Trendline")
// Detect breakout conditions
breakoutUp = close > upperTrend
breakoutDown = close < lowerTrend
// Confirm breakout with RSI
buyCondition = breakoutUp and rsi > rsiThresholdBuy
sellCondition = breakoutDown and rsi < rsiThresholdSell
// Plot breakout signals with confirmation from RSI
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, size=size.small)
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, size=size.small)
// Strategy: Buy when triangle breaks upwards and RSI is above 50; Sell when triangle breaks downwards and RSI is below 50
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Plot RSI on the bottom pane
hline(50, "RSI 50 Level", color=color.gray, linestyle=hline.style_dotted)
plot(rsi, color=color.blue, linewidth=2, title="RSI")