SuperTrend Oscillator

Thanks to whomever's code or scraps of code were borrowed to make this (borrowed from LazyBear, blindfreddy, ChrisMoody and perhaps others).

Green/red is the SuperTrend trend.
The midline is the same except it flashes purple for extreme price moves and trend reversals.
Orange/blue is the current trend's slope so a strong uptrend slopes up and vis versa.

Can be used instead of an Average True Range indicator due to reacting quasi-identically to volatility with the added benefit of anticipating price spikes and having the appropriate technical guidance once these spikes have transpired.
Remove from Favorite Scripts Add to Favorite Scripts
//Thank you to whomever's code or scraps of code was borrowed to make this (borrowed from LazyBear, blindfreddy, ChrisMoody and perhaps others)
//Green/red is the supertrend trend
//The midline is the same except it flashes purple for extreme price moves
//Orange/blue is the current trend's slope so a strong uptrend slopes and vis versa
study(title="SuperTrend Oscillator", overlay = false)
length = input(12, minval=1, title="SuperTrend Length")
lengthema = input(12, minval=1, title="EMA Length")
mult = input(3, type="float",minval=1)
sb=input(true, title="Use BB")
lengthbb = input(12, minval=1, title="BB Length")
m = input(2, minval=1, maxval=50, title="BB Multiplier")
ebc=input(false, title="Extreme Bars")
useCurrentRes = input(true, title="Use Current Chart Resolution?")
resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="5")
res = useCurrentRes ? period : resCustom
avgTR = atr(length)
newshortband= hl2 + avgTR * mult
newlongband= hl2 - avgTR * mult
longband=close[1]>longband[1]? max(newlongband,longband[1]) : newlongband
shortband=close[1]<shortband[1]? min(newshortband,shortband[1]) : newshortband
trendres = close > shortband[1] ? 1: close< longband[1]? -1: nz(trendres[1],1)
trend = security(tickerid, res, trendres)
suptres = trend==1? longband: shortband
supt = security(tickerid, res, suptres)
sptres = (close - supt)
spt = security(tickerid, res, sptres)
sptemares = ema(spt, lengthema)
sptema = security(tickerid, res, sptemares)
basisres = sb?sma(spt, lengthbb):na
basis = security(tickerid, res, basisres)
devres = sb?m * stdev(spt, lengthbb):na
dev = security(tickerid, res, devres)
upper = sb ? (basis + dev) : na
lower = sb ? (basis - dev) : na
uptrendextreme = (spt>0) and (spt>upper)
downtrendextreme = (spt<0) and (spt<lower)
trendextreme = uptrendextreme or downtrendextreme
slope_spt_level_up1 = (spt) > (spt) [1]
slope_spt_level_down1 = (spt) < (spt) [1]
slope_spt_level_up2 = (spt) > (spt) [2]
slope_spt_level_down2 = (spt) < (spt) [2]
slope_spt_level_up3 = (spt) > (spt) [3]
slope_spt_level_down3 = (spt) < (spt) [3]
slope_spt_level_up4 = (spt) > (spt) [4]
slope_spt_level_down4 = (spt) < (spt) [4]
slope_spt_level_up5 = (spt) > (spt) [5]
slope_spt_level_down5 = (spt) < (spt) [5]
slope_spt_level_up6 = (spt) > (spt) [6]
slope_spt_level_down6 = (spt) < (spt) [6]
slope_spt_level_up7 = (spt) > (spt) [7]
slope_spt_level_down7 = (spt) < (spt) [7]
slope_spt_level_up8 = (spt) > (spt) [8]
slope_spt_level_down8 = (spt) < (spt) [8]
slope_spt_level_up9 = (spt) > (spt) [9]
slope_spt_level_down9 = (spt) < (spt) [9]
slope_spt_level_up10 = (spt) > (spt) [10]
slope_spt_level_down10 = (spt) < (spt) [10]
spt_color = slope_spt_level_down1?orange:slope_spt_level_up1?blue:slope_spt_level_down2?orange:slope_spt_level_up2?blue:slope_spt_level_down3?orange:slope_spt_level_up3?blue:slope_spt_level_down4?orange:slope_spt_level_up4?blue:slope_spt_level_down5?orange:slope_spt_level_up5?blue:slope_spt_level_down6?orange:slope_spt_level_up6?blue:slope_spt_level_down7?orange:slope_spt_level_up7?blue:slope_spt_level_down8?orange:slope_spt_level_up8?blue:slope_spt_level_down9?orange:slope_spt_level_up9?blue:slope_spt_level_down10?orange:slope_spt_level_up10?blue:white
histcolor = trend==1? green: red
midcolor = trendextreme?purple:trend==1? green: red
extremebarcolor = trendextreme?purple:na
plot(spt, color= histcolor , style=histogram, linewidth=4,title="Histogram")
plot(spt, color= spt_color , style=line, linewidth=3,title="SuperTrend")
plot(0, style=line, linewidth=3, color=midcolor)
now wht actually ur indicator saying...plz explain too....
Very nice - thanks for posting
EN English (UK)
EN English
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
HE עברית
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Get Help Feature Request Blog & News FAQ Wiki Twitter
Profile Profile Settings Account and Billing Get Help Ideas Published Followers Following Private Messages Chat Sign Out