OPEN-SOURCE SCRIPT

SuperTrend BUY SELL Color

16
//version=6
indicator("SuperTrend by Cell Color", overlay=true, precision=2)

// --- Parametreler ---
atrPeriod = input.int(10, "ATR Periyodu")
factor = input.float(3.0, "Çarpan")
showTrend = input.bool(true, "Trend Renkli Hücreleri Göster")

// --- ATR Hesaplama ---
atr = ta.atr(atrPeriod)

// --- SuperTrend Hesaplama ---
up = hl2 - factor * atr
dn = hl2 + factor * atr

var float trendUp = na
var float trendDown = na
var int trend = 1 // 1 = bullish, -1 = bearish

trendUp := (close[1] > trendUp[1] ? math.max(up, trendUp[1]) : up)
trendDown := (close[1] < trendDown[1] ? math.min(dn, trendDown[1]) : dn)

trend := close > trendDown[1] ? 1 : close < trendUp[1] ? -1 : trend[1]

// --- Renkli Hücreler ---
barcolor(showTrend ? (trend == 1 ? color.new(color.green, 0) : color.new(color.red, 0)) : na)

// --- SuperTrend Çizgileri ---
plot(trend == 1 ? trendUp : na, color=color.green, style=plot.style_line, linewidth=2)
plot(trend == -1 ? trendDown : na, color=color.red, style=plot.style_line, linewidth=2)

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.