Supertrend V1.0 - Buy or Sell Signal

Supertrend Indicator with Buy and Sell Indicators. Supertrend is quite a popular indicator. To know more about it check out the article below.

10 Things to know about Supertrend
Remove from Favorite Scripts Add to Favorite Scripts
//Author - Rajandran R
study("Supertrend V1.0 - Buy or Sell Signal", overlay = true)

Factor=input(3, minval=1,maxval = 100)
Pd=input(7, minval=1,maxval = 100)


TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn

Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown

linecolor = Trend == 1 ? green : red

plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "SuperTrend")

plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow", shape.triangleup,location.belowbar,green,0,0)
plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown , location.abovebar, red,0,0)
//plot(Trend==1 and Trend[1]==-1,color = linecolor, style = circles, linewidth = 3,title="Trend")

plotarrow(Trend == 1 and Trend[1] == -1 ? Trend : na, title="Up Entry Arrow", colorup=lime, maxheight=60, minheight=50, transp=0)
plotarrow(Trend == -1 and Trend[1] == 1 ? Trend : na, title="Down Entry Arrow", colordown=red, maxheight=60, minheight=50, transp=0)


Hi Rajandran,
I love this indicator. Is there a way to add an offset function? it seems the indicator correctly indicates market changes but is 6 bars late. An offset function could allow a more precise read on the market trend.
+40 Reply
But dont u think applying offset will give the signal and after the appearence of the 6th bar.. so in that case how would offset help?
+2 Reply
davieovermeer MONEYMENOW
I completely agree. I found a strategy that looked perfect, which it was as it was set to offset -5, it was such a facepalm moment
+5 Reply
alisson.cruz davieovermeer
Hi davieovermeer! I'm quite new to tradingview. I was wondering: What strategy did you use? Have you changed the source code or simply tuned the inputs? For me it also appears that that the indicator is 5-6 bars too late.
+4 Reply
BipinBihariPatra davieovermeer

can you share the strategy for offst -5 or any code that you change to reflect this.
+6 Reply
Hi Rajendran, Fan of your's site Grt job buddy. But plz guide me how could I add this indicator to tradingview chart as I am quite new to this site I don't know where to add this code.
+23 Reply
Delman ashishtimes
@ashishtimes, Hmm... weird, err should know, I know this a bit late, likely know now, can google it, but should be at the top... it's ~ symbol on mine, click on that, opens a box then in search top left, that magnifier looking thing, type in supertrend then it's mejialucas one I choose, but same as one here i believe, then settings and alter the factor rate lower and PD 1
Guys, does anyone know how to set up the alerts for this indicator here on Tradingview? There are more options and it still doesnt work... Thank you!!!
+18 Reply
What expiry time do you use with this incator? If using 1 minute chart is expiry 5minutes? Or what is best timeframes to use?

+17 Reply
vipink1963 NicoEsterhuyse
Dear Sir


warm regards
+5 Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out