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

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?

Clause de non-responsabilité