
Chiến lược này kết hợp với hỗ trợ / kháng cự (S / R), phá vỡ / đảo ngược, lọc khối lượng giao dịch và hệ thống cảnh báo nhằm nắm bắt các điểm biến động quan trọng trong thị trường. Chiến lược này sử dụng xác nhận khối lượng giao dịch bất thường để nâng cao độ tin cậy của tín hiệu giao dịch bằng cách nhận ra các tín hiệu phá vỡ hoặc đảo ngược giá. Chiến lược sử dụng tỷ lệ dừng cố định 2% và tỷ lệ dừng có thể điều chỉnh (bằng cách mặc định 3%) để quản lý rủi ro.
ta.pivothigh()Vàta.pivotlow()Chức năng nhận diện mức giá quan trọng trong chu kỳ được chỉ định. Nó sẽ kích hoạt tín hiệu khi giá vượt qua ngưỡng kháng cự (bước lên 1%) hoặc bật trở lại từ mức hỗ trợ (bước xuống và quay trở lại).strategy.exit()hoàn thành.Chiến lược này thiết kế một khuôn khổ giao dịch có xác suất cao, đặc biệt phù hợp với việc bắt đầu xu hướng bằng cách xác minh ba lần (vị trí giá, khối lượng giao dịch, hành vi giá). Lợi thế cốt lõi là tính minh bạch của logic, rủi ro có thể được kiểm soát, nhưng cần lưu ý đến giới hạn của nó trong thị trường xung đột.
/*backtest
start: 2024-04-24 00:00:00
end: 2024-12-31 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"DOGE_USDT"}]
*/
//@version=5
strategy("S/R Breakout/Reversal + Volume + Alerts", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// === INPUTS ===
pivotLen = input.int(10, "Pivot Lookback for S/R")
volSmaLength = input.int(20, "Volume SMA Length")
volMultiplier = input.float(1.5, "Volume Multiplier")
tpPerc = input.float(3.0, "Take Profit %", step=0.1)
slPerc = 2.0 // Stop Loss fixed at 2%
// === S/R ZONES ===
pivotHigh = ta.pivothigh(high, pivotLen, pivotLen)
pivotLow = ta.pivotlow(low, pivotLen, pivotLen)
var float resZone = na
var float supZone = na
if not na(pivotHigh)
resZone := pivotHigh
if not na(pivotLow)
supZone := pivotLow
plot(supZone, title="Support", color=color.green, linewidth=2, style=plot.style_linebr)
plot(resZone, title="Resistance", color=color.red, linewidth=2, style=plot.style_linebr)
// === VOLUME FILTER ===
volSma = ta.sma(volume, volSmaLength)
highVolume = volume > volSma * volMultiplier
// === LONG LOGIC ===
priceAboveRes = close > resZone * 1.01
nearSupport = close >= supZone * 0.99 and close <= supZone * 1.01
rejectSupport = low <= supZone and close > supZone
longBreakoutCond = priceAboveRes and highVolume
longReversalCond = nearSupport and rejectSupport and highVolume
longCondition = longBreakoutCond or longReversalCond
// === SHORT LOGIC ===
priceBelowSup = close < supZone * 0.99
nearResistance = close >= resZone * 0.99 and close <= resZone * 1.01
rejectResistance = high >= resZone and close < resZone
shortBreakoutCond = priceBelowSup and highVolume
shortReversalCond = nearResistance and rejectResistance and highVolume
shortCondition = shortBreakoutCond or shortReversalCond
// === ENTRIES WITH LABELS ===
if (longCondition)
strategy.entry("Long", strategy.long)
label.new(bar_index, low * 0.995, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white)
if (shortCondition)
strategy.entry("Short", strategy.short)
label.new(bar_index, high * 1.005, "SELL", style=label.style_label_down, color=color.red, textcolor=color.white)
// === TP/SL ===
longTP = close * (1 + tpPerc / 100)
longSL = close * (1 - slPerc / 100)
shortTP = close * (1 - tpPerc / 100)
shortSL = close * (1 + slPerc / 100)
strategy.exit("Long TP/SL", from_entry="Long", limit=longTP, stop=longSL)
strategy.exit("Short TP/SL", from_entry="Short", limit=shortTP, stop=shortSL)
// === ALERT CONDITIONS ===
alertcondition(longCondition, title="Buy Alert", message="🔔 BUY signal: S/R + Volume breakout/reversal")
alertcondition(shortCondition, title="Sell Alert", message="🔔 SELL signal: S/R + Volume breakout/reversal")