How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Feature Request FAQ Help & Wiki Twitter

# Supertrend V1.0 - Buy or Sell Signal

83433 89
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
```//Author - Rajandran R
//www.marketcalls.in
study("Supertrend V1.0 - Buy or Sell Signal", overlay = true)

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

Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))

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)

```
Cant find the indicator
dilip_r
Then copy the script and Paste it in your Tradingview Pinescript Editor
rajandran.r
i am using zerodha pi software can i using this script
SarathLal
No Zerodha Pi doesnt support pinescript. It is based on Tradescript.
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.
VWAP McStinkypants
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?
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
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.
Thanks!
davieovermeer
Hi,

can you share the strategy for offst -5 or any code that you change to reflect this.
Thanks rajandran.r for coding this very useful indicator.

I find that by adjusting the Factor value this Super Trend Indicator can be fine tuned to follow the market either more closely or further away as you choose. I like using a Factor value of 1.38. However the value you use is really an individual thing based on your trading method and time frame.

Also, using a Moving Average along with this indicator, such as KAMA, is also very helpful in keeping you on the right side of the market. The choice of which moving average to use is also an individual choice based on your own testing and depending on your trading method and time frame.

Adding an oscillator, such as John Uhlers recent Universal Oscillaor or your favorite oscillator, can be used to further filter for the best entries.
stenor
I should note that in order to input Factor values having decimal places in them you need to alter one line of code:

Change:
Factor=input(3, minval=1,maxval = 100)

To:
Factor=input(1.38, type=float)
stenor
Factor and ATR value can be decided based on proper backtesting and optimization.
rajandran.r
and whether there is a version 2 for tradingview?
rajandran.r
Can you post the the strategy testing code for your supertrend script ?? thanks
Thank you Rajandran.R for this wonderful indicator!
Nice! How can I create an alert for this?
dingleberry
current price cross over
squattter
do you have any sample code for this ? alert mechanism would be nice
Kabiastro

Something like this - http://i.imgur.com/biCbQdf.png

But I prefer bouncing off supertrend rather than counting on breaking through. Send me a PM and I'll show you. Maybe I'll post an IDEA for the first time about it.
squattter
Dear Squattter,

Please guide me how can I set an alert that it will popup when the Up arrow or the down arrow is plotted.

Regards
Bipin
BipinBihariPatra
@BipinBihariPatra,
did you find your answer? I also want to know how can I set alert when arrow is poped up
dingleberry
Thanks! Looks great
Hello! A fine job done! Could you change it in multi-time frame supertrend, say, with timeframes D, W, M?
Thanks for this sharing. Very usefull, whatever the timefrime, especially with Heikin Ashi ...
very fine indicator, good work! did anyone manage to add an alert on buy/sell signal on this one, if yes, can you please share? Thanks!
ahsanq
I have the same question. Nice indicator work.
Seal
Same question as well. Very nice.
What expiry time do you use with this incator? If using 1 minute chart is expiry 5minutes? Or what is best timeframes to use?

Thanks
NicoEsterhuyse
Dear Sir

Kindly mail metaSTOCK EXPLORER ALGORITHM FOR SUPER TREND.( ID vipink1963@gmail.com))

warm regards
Hi Mr.Raj,
Thanks for this useful indicator. how can i install this indicator on meta-trader 4? any means? kindly advice.thanks.
Dethlefsen5EU
https://www.mql5.com/en/code/10851
tiosa1
thanks a lot tiosa1...got it..

alertcondition(Trend == 1 and Trend == -1 ? Trend : na, title='Up Entry Arrow', message='Up Entry Arrow!')
alertcondition(Trend == -1 and Trend == 1 ? Trend : na, title='Down Entry Arrow', message='Down Entry Arrow!')
santoshporwal
add it where exactly, on which lines?
santoshporwal
Hi Santosh,

Added these lines but unfortunately did not see any change. No popup alert generated. Is there anyway Pop up alert and a sound can be set when up arrow or down arrow appears.

Regards
Bipin
BipinBihariPatra
After adding this lines you have to actually go to alerts and create a alert for the condition on tool Super Trend.
santoshporwal
@santoshporwal, Thank you for the answer. Instead of "Super Trend", I selected "Up Entry Arrow" and "Down Entry Arrow" to distinguish for Down/Up. Somehow, it doesn't fire the alert when using "Up Entry Arrow"/"Down Entry Arrow". 1. How do I make the message this is Down or Up? Any idea? 2. I want to display the price (no matter open/close), and percentage when alerts. Do you think it's possible? Thank you.
daebak
@daebak,
Hi did you find a soution? can you explain if you can
Hello, thank you for the indicator.
What do the green and red lines represent? Are they smooth lines of some sort? or a mathematical reverse mirroring of the price action?
Thanks
Tradingview.com on Chrome, I can't see the bottom histogram indicator.... any clue?
Hi. How can i make this compatable with my Protrader platform?
Could you please provide easy language code for super trend. i have bugs in my code (given below) and can't compile it properly.

inputs:

AvgTrueRangeLength (9), AvgTrueRangeMult (1) , Strength (9);

variables:

strend (0),
st (0);

St = SuperTrend( AvgTrueRangeLength, AvgTrueRangeMult, Strength, strend);

Plot1 (st, "Up");
Plot2 (st, "Down");
Plot3 (st, "SuperTrend", IFF (strend = 1, GetPlotColor (1) , GetPlotColor (2)));
Hello Rajendran
When are you planning to publish the most effective SUPERTREND 5 code
http://www.marketcalls.in/amibroker/supertrend-v5-0-amibroker-afl-code.html
Hello Rajandran Have you got the code for sound and pop up alert,please?
1 Week
1 Min -> 43 Win 60 Lose
5 Min -> 39 Win 64 Lose
I don't like this indicator.
if you are using for forex then try
factor: 1.5
Period: 14

let me know
terrence7d
@terrence7d, seems to work OK, thank you for your advice! Are you using a 1min chart for trades here? What charts do you think would be the best for this signal? All the best
The below customized Super Trend gives more accurate results

MarxBabu
@MarxBabu, The three line strategy is here for the same

@RadonGroup, Wonder if opposite would be profitable.
how do I create a SuperTrend indicator financial chart for my website
amlanrashmi
HI
would like to like to try this as a stratergy in ig index automotive need help with writing it ?

regards andy#
Can somebdy please explain the strategy in plain english?
p699
Go thro the webinar here https://www.youtube.com/watch?v=arPnDXL17l4
rajandran.r
Dear Raj,

really good work. Is there anyway Pop up alert and a sound can be set when up arrow or down arrow appears.

Regards
Bipin
why dont you give pine code of supertrend 5.0.
It would be awesome.
sameer_patel18in
Dear Rajendar this is our request but you are avoiding the same
When can be see SuperTrend5.0 pls post the code
If we get SuperTrend5.0 that will be awesome

MarxBabu
@MarxBabu, Hello, can you share the pine script code on the SuperTrend 5.0?
MarxBabu
@MarxBabu, Share the pine script
how about EA this Indicator ? .
I just love this indicator. It works best. Thank you so much for building it.
I have one question, How do I scan for stocks that got up arrow ?
thank you :)
Isn't this just Parabolic SAR ?
Khaled-B
@Khaled-B, No, this is a Chandelier stop that adjusts itself to highest close since entry and the average true range.
hi is there anyone using supertrend
Thank you for sharing this. and I wonder if you can make it has alarm (beeping or send email) in the event of buy/sell signal?
daebak
Hi to all.
I publish a study to use with this Strategy for use TradingView Alert.

Thanks to Rajandran R for this Pine Script! :-)
I prefer 1.5 factor value.
Anyone have this in ThinkOrSwim script, ThinkScript?
My favorite indicator. Awesome!
amazing...but when to close the trade ? optimized option ?
Aqib00
@Aqib00, very interesting also but not very useful for trading cryptocurrencies. why not using bitcoin trading bot in the cloud. http://bit.ly/tradingbot perhaps someone could adapt the code for supertrend v.5 which can be found here http://www.marketcalls.in/amibroker/supertrend-v5-0-amibroker-afl-code.html
Alfrodox
@Alfrodox, Hi can you please let me know how to import it to trading view ..@ Rajendran r thank you for the great indicator.
thanks for share.
how I get yhis indicator?
how I get this indicator?
is min max write in above code OR do they need to be switched ?
Absolutely love this script. Helps confirm my decision to buy or sell. Thank you so much for creating.
WOW, worst indicator around here that is as useless gets 8400 views
cristian.d
@cristian.d, Why do you say that Cristian?
Hello.
Could you please explain me, this part of the script "TrendUp=close>TrendUp? max(Up,TrendUp) : Up" Isn't it a circular reference? As far as I understand, function "TrendUp" refer to itself. Actually I'm trying to make this indicator in Metastock and Metastock doesn’t allow to make circular references. Can somebody explain me am I wrong and example above isn’t a circular reference or I just misunderstand calculation of this functions (TrendUp in this example)?
Thank you))
Hi Rajandran,

This looks like a great indicator, thanks for sharing.

I noticed on your site you have version 5 of this indicator. Would you be able to update here, and also, could you create a scanner (based on this indicator) that can scan Russell 3000 stocks and forex pairs?

Thank you.
supertrend is so similar to EMA 50.
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia

한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter