Entry Buy/Sell + Support/Resistance Zones

indicator("Entry Buy/Sell + Support/Resistance Zones", overlay=true)
// === Tham số ===
length = input.int(5, title="Pivot Length")
maxZones = input.int(10, title="Số lượng vùng tối đa")
zoneWidth = input.int(20, title="Độ rộng vùng (số nến)")
showEntry = input.bool(true, title="Hiển thị Entry Buy/Sell?")
// === Phát hiện pivot ===
pivotHigh = ta.pivothigh(high, length, length)
pivotLow = ta.pivotlow(low, length, length)
// === Mảng vùng hỗ trợ/kháng cự ===
var supportLevels = array.new_float()
var resistanceLevels = array.new_float()
// === Cập nhật vùng hỗ trợ ===
if pivotLow
sLevel = low[length]
if not array.includes(supportLevels, sLevel)
array.unshift(supportLevels, sLevel)
if array.size(supportLevels) > maxZones
array.pop(supportLevels)
// === Cập nhật vùng kháng cự ===
if pivotHigh
rLevel = high[length]
if not array.includes(resistanceLevels, rLevel)
array.unshift(resistanceLevels, rLevel)
if array.size(resistanceLevels) > maxZones
array.pop(resistanceLevels)
// === Vẽ vùng hỗ trợ ===
for i = 0 to array.size(supportLevels) - 1
sl = array.get(supportLevels, i)
box.new(bar_index - zoneWidth, sl, bar_index, sl, border_color=color.green, bgcolor=color.new(color.green, 85))
// === Vẽ vùng kháng cự ===
for i = 0 to array.size(resistanceLevels) - 1
rl = array.get(resistanceLevels, i)
box.new(bar_index - zoneWidth, rl, bar_index, rl, border_color=color.red, bgcolor=color.new(color.red, 85))
// === Entry logic ===
entryLong = showEntry and close > array.get(resistanceLevels, 0)
entryShort = showEntry and close < array.get(supportLevels, 0)
// === Vẽ tín hiệu Entry ===
plotshape(entryLong, title="Entry Buy", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(entryShort, title="Entry Sell", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Đảm bảo script hợp lệ
plot(na)
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.
Declinazione di responsabilità
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.