OPEN-SOURCE SCRIPT

SuperTrend BUY SELL Color

43
//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)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.