
Chiến lược này là một hệ thống giao dịch định lượng dựa trên phá vỡ mở cửa 5 phút, kết hợp với chỉ số ATR để quản lý lỗ hổng dừng dừng động. Chiến lược chủ yếu bằng cách xác định điểm cao và thấp của đường K 5 phút đầu tiên sau khi mở cửa như là một phạm vi giá quan trọng, kích hoạt tín hiệu giao dịch khi giá phá vỡ phạm vi đó và sử dụng dừng động dựa trên ATR để kiểm soát rủi ro.
Logic cốt lõi của chiến lược bao gồm các bước chính sau:
Đây là một chiến lược giao dịch định lượng có cấu trúc, logic rõ ràng, thực hiện giao dịch tự động có thể kiểm soát rủi ro thông qua việc giám sát mức giá mở và sử dụng ATR động. Ưu điểm cốt lõi của chiến lược là khái niệm thiết kế đơn giản và hiệu quả, nhưng cũng cần tối ưu hóa liên tục cho các môi trường thị trường và loại giao dịch khác nhau.
/*backtest
start: 2025-02-13 00:00:00
end: 2025-02-19 00:00:00
period: 5m
basePeriod: 5m
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=5
strategy("5-Min Open Candle Breakout", overlay=true)
// Get the current bar's year, month, and day
currentYear = year
currentMonth = month
currentDay = dayofmonth
// Define session start time (adjust based on market)
sessionStart = timestamp(currentYear, currentMonth, currentDay, 9, 30) // 9:30 AM for NYSE
// Identify the first 5-minute candle
isFirstCandle = (time >= sessionStart and time < sessionStart + 300000) // 5 min = 300,000 ms
var float openPrice = na
var float highPrice = na
var float lowPrice = na
if isFirstCandle
openPrice := open
highPrice := high
lowPrice := low
// Breakout Conditions
longEntry = ta.crossover(close, highPrice)
shortEntry = ta.crossunder(close, lowPrice)
// Define Stop Loss & Take Profit (Ratio 1:1.5)
slFactor = 1.0 // Stop Loss Multiplier
tpFactor = 1.5 // Take Profit Multiplier
atrValue = ta.atr(14) // Fix: Use ta.atr() instead of atr()
longSL = lowPrice - atrValue * slFactor
longTP = highPrice + (highPrice - lowPrice) * tpFactor
shortSL = highPrice + atrValue * slFactor
shortTP = lowPrice - (highPrice - lowPrice) * tpFactor
// Execute Trades
strategy.entry("Long", strategy.long, when=longEntry)
strategy.exit("Exit Long", from_entry="Long", stop=longSL, limit=longTP)
strategy.entry("Short", strategy.short, when=shortEntry)
strategy.exit("Exit Short", from_entry="Short", stop=shortSL, limit=shortTP)
// Plot High/Low of First Candle
plot(highPrice, title="First 5m High", color=color.green, linewidth=2)
plot(lowPrice, title="First 5m Low", color=color.red, linewidth=2)