Statistics: Posted by Curioso — Mon May 27, 2024 1:01 am — Replies 1559 — Views 177649
Statistics: Posted by JohnnyRy — Mon May 27, 2024 12:46 am — Replies 252 — Views 10197
Statistics: Posted by BeatlemaniaSA — Mon May 27, 2024 12:15 am — Replies 4155 — Views 1137696
Code: Select all
//@version=4study("Supertrend", overlay = true, format=format.price, precision=2, resolution="")Periods = input(title="ATR Period", type=input.integer, defval=10)src = input(hl2, title="Source")Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)atr2 = sma(tr, Periods)atr= changeATR ? atr(Periods) : atr2up=src-(Multiplier*atr)up1 = nz(up[1],up)up := close[1] > up1 ? max(up,up1) : updn=src+(Multiplier*atr)dn1 = nz(dn[1], dn)dn := close[1] < dn1 ? min(dn, dn1) : dntrend = 1trend := nz(trend[1], trend)trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trendupPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)buySignal = trend == 1 and trend[1] == -1plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)sellSignal = trend == -1 and trend[1] == 1plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.whiteshortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.whitefill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")changeCond = trend != trend[1]alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
Statistics: Posted by oskison — Sun May 26, 2024 10:36 pm — Replies 429 — Views 256806
Statistics: Posted by Curioso — Sun May 26, 2024 8:21 pm — Replies 69 — Views 2714
Statistics: Posted by Jimmy — Sun May 26, 2024 7:24 pm — Replies 1937 — Views 1682370
Statistics: Posted by ChuChu Rocket — Sun May 26, 2024 7:19 pm — Replies 1 — Views 1554
Statistics: Posted by Ogee — Sun May 26, 2024 5:50 pm — Replies 2878 — Views 178797
Statistics: Posted by Ogee — Sun May 26, 2024 5:18 pm — Replies 3309 — Views 382308
Statistics: Posted by Ogee — Sun May 26, 2024 5:17 pm — Replies 712 — Views 63152
Statistics: Posted by Mrs.Watanabe — Sun May 26, 2024 5:09 pm — Replies 3529 — Views 2053341
Statistics: Posted by ChuChu Rocket — Sun May 26, 2024 3:47 pm — Replies 37 — Views 1865
Statistics: Posted by JohnnyRy — Sun May 26, 2024 6:29 am — Replies 59 — Views 5555
Statistics: Posted by kvak — Sun May 26, 2024 5:51 am — Replies 20481 — Views 5743343
Statistics: Posted by JohnnyRy — Sun May 26, 2024 4:56 am — Replies 1 — Views 364