OPEN-SOURCE SCRIPT
SuperTrend BUY SELL Color

//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)
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)
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.