OPEN-SOURCE SCRIPT

Support and Resistance Zones

//version=5
indicator("Support and Resistance Zones", overlay=true)

// Input parameters
lookback = input.int(20, "Lookback Period for Zones", minval=1)
zoneWidth = input.float(0.3, "Zone Width (%)", minval=0.1, step=0.1)
highlightZones = input.bool(true, "Highlight Zones", inline="Highlight")

// Identify swing highs and lows
isSwingHigh = ta.highest(high, lookback) == high and high > ta.highest(high[1], lookback)
isSwingLow = ta.lowest(low, lookback) == low and low < ta.lowest(low[1], lookback)

// Store significant levels using arrays
var float resistanceLevel = na
var float supportLevel = na

if isSwingHigh
resistanceLevel := high
if isSwingLow
supportLevel := low

// Define support and resistance zones
resistanceZoneTop = resistanceLevel * (1 + zoneWidth / 100)
resistanceZoneBottom = resistanceLevel * (1 - zoneWidth / 100)

supportZoneTop = supportLevel * (1 + zoneWidth / 100)
supportZoneBottom = supportLevel * (1 - zoneWidth / 100)

// Highlight zones if the price is within them
bgcolor(highlightZones and resistanceLevel and close >= resistanceZoneBottom and close <= resistanceZoneTop ? color.new(color.red, 85) : na, title="Resistance Zone")
bgcolor(highlightZones and supportLevel and close >= supportZoneBottom and close <= supportZoneTop ? color.new(color.green, 85) : na, title="Support Zone")

// Plot support and resistance levels
plot(resistanceLevel, title="Resistance", color=color.red, linewidth=2, style=plot.style_line)
plot(supportLevel, title="Support", color=color.green, linewidth=2, style=plot.style_line)

// Alerts for when price enters the zones
alertcondition(close >= resistanceZoneBottom and close <= resistanceZoneTop, title="Resistance Zone Alert", message="Price entered Resistance Zone")
alertcondition(close >= supportZoneBottom and close <= supportZoneTop, title="Support Zone Alert", message="Price entered Support Zone")
Candlestick analysisTrend AnalysisWave Analysis

Skrip open-source

Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menerbitkannya sebagai sumber terbuka, sehingga para trader dapat memahami dan memverifikasinya. Hormat untuk penulisnya! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Inggin menggunakan skrip ini pada chart?

Pernyataan Penyangkalan