OPEN-SOURCE SCRIPT

Entry Buy/Sell + Support/Resistance Zones

97
//version=5
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)

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.