• The price of VIP membership is increasing to $199 beginning June 1. Click here to lock in the current rate of $149.

Supertrend Indicator by Mobius for ThinkorSwim

BenTen

Administrative
Staff
VIP
This is a Supertrend indicator for ThinkorSwim created by Mobius.

What's new in V03.10.2015
  • Added Bubbles to mark entry and exit prices. Doesn't give much time to follow into trade, but better than guessing.
  • Altered default settings for values that made more sense on Intraday Futures. Added Color and ColorBars.

Supertrend Indicator: shows trend direction and gives buy or sell signals according to that. It is based on a combination of the average price rate in the current period along with a volatility indicator. The ATR indicator is most commonly used as volatility indicator. The values are calculated as follows:

Up = (HIGH + LOW) / 2 + Multiplier * ATR
Down = (HIGH + LOW) / 2 – Multiplier * ATR
When the change of trend occurs, the indicator flips

N3y7JFY.png


thinkScript Code for Supertrend

Code:
# Mobius
# SuperTrend
# Chat Room Request
input AtrMult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
plot SuperTrend = ST;
SuperTrend.AssignValueColor(if close < ST then Color.RED else Color.GREEN);
AssignPriceColor(if PaintBars and close < ST

                 then Color.RED

                 else if PaintBars and close > ST

                      then Color.GREEN

                      else Color.CURRENT);

AddChartBubble(close crosses below ST, low[1], low[1], color.Dark_Gray);
AddChartBubble(close crosses above ST, high[1], high[1], color.Dark_Gray, no);
# End Code SuperTrend

SuperTrend Scanner for ThinkorSwim

Code:
# SuperTrend Scan
# Mobius
# V01.10.2015
# Comment out (#) the direction NOT to use for a scan

input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;
def h = high;
def l = low;
def c = close;
def v = volume;
def ATR = MovingAverage(AvgType, TrueRange(h, c, l), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if c < ST[1]
         then Round(UP / tickSize(), 0) * tickSize()
         else Round(DN / tickSize(), 0) * tickSize();
#plot SuperTrendUP = if ST crosses below close then 1 else 0;
plot SuperTrendDN = if ST crosses above close then 1 else 0;
# End Code SuperTrend

Shareable Link

https://tos.mx/mK9Vgg

For anyone looking for the mobile version of this indicator, here is the link to that.

Video Tutorial

 
Last edited:

Chenthy73

New member
This does not work in TOS IOS app appropriately - mainly bubbles with prices do not appear.

Do you have any idea how to fix it? Thanks

 
Last edited:

MasterSteve

Well-known member
VIP
I've been working with it for a while but haven't found anything that works. Sorry!

 
Last edited:

Chenthy73

New member
I am ok with just the line from supertrend. Just need to see when the candles closes on which side of the line relative to other indicators and key support /resistance. It has some good purpose so far.

Thanks to all.

 
Last edited:

BenTen

Administrative
Staff
VIP
@San If you want to remove the bubble, delete the following lines from the code:

Rich (BB code):
AddChartBubble(close crosses below ST, low[1], low[1], color.Dark_Gray); 
AddChartBubble(close crosses above ST, high[1], high[1], color.Dark_Gray, no);
 
Last edited:

San

Member
2019 Donor
Its working great.. U always rocking...

"Paris: Here's SuperTrend MTF for those interested, from my archives - complete with notes posted at the time the study was released"

Code:
# SuperTrend Multiple Time Frames
# Mobius
# V03.01.2016

# I pulled this study down from MyTrade for a reason. It wasn't
# plotting correctly with the multiple aggregations. And like
# all studies with secondary aggregations it tends to replot the
# higher ones. I decided to think about it some more and this is
# where I am with the ST MTF study now.
#
# It's still squirrely and blinks a lot. Using declare Once_Per_Bar
# does some bad things to it. I was considering making intra
# aggregation higher time frames. A pain to do but it gives more
# control over how it plots.
#
# Row 6 is supposed to be the output for all aggregations and the
# signal line. After hours when data isn't moving it's steady and
# has good signals. But since it's after hours, totally useless
# for any intraday trading.

declare lower;

input agg1 = AggregationPeriod.Five_Min;
input agg2 = AggregationPeriod.Ten_Min;
input agg3 = AggregationPeriod.Fifteen_Min;
input agg4 = AggregationPeriod.Thirty_Min;
input agg5 = AggregationPeriod.Hour;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;

script ST{
input agg = AggregationPeriod.Five_Min;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;
def Fh = FundamentalType.High;
def Fl = FundamentalType.Low;
def Fc = FundamentalType.Close;
def Fhl2 = FundamentalType.HL2;
def h = Fundamental(Fh, period = agg);
def l = Fundamental(Fl, period = agg);
def c = Fundamental(Fc, period = agg);
def hl = Fundamental(Fhl2, period = agg);
def ATR = MovingAverage(AvgType, TrueRange(h, c, l), nATR);
def UP = hl + (AtrMult * ATR);
def DN = hl + (-AtrMult * ATR);
def S = if c < S[1]
        then Round(UP / tickSize(), 0) * tickSize()
        else Round(DN / tickSize(), 0) * tickSize();
plot ST = if c > S then 1 else 0;
}
def cl = close;
def x = isNaN(cl[2]) and !isNaN(cl[3]);
def FirstAgg = ST(agg = agg1, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot FirstAggPlot = if isNaN(cl)
                    then double.nan
                    else 1;
FirstAggPlot.SetStyle(Curve.Points);
FirstAggPlot.SetLineWeight(3);
FirstAggPlot.AssignValueColor(if FirstAgg == 1
                              then color.green
                              else color.red);
AddChartBubble(x, 1, (agg1/1000/60) + " min", color.white, yes);
def SecondAgg = ST(agg = agg2, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot SecondAggPlot = if isNaN(cl)
                     then double.nan
                     else 2;
SecondAggPlot.SetStyle(Curve.Points);
SecondAggPlot.SetLineWeight(3);
SecondAggPlot.AssignValueColor(if SecondAgg == 1
                               then color.green
                               else color.red);
AddChartBubble(x, 2, (agg2/1000/60) + " min", color.white, yes);
def ThirdAgg = ST(agg = agg3, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot ThirdAggPlot = if isNaN(cl)
                    then double.nan
                    else 3;
ThirdAggPlot.SetStyle(Curve.Points);
ThirdAggPlot.SetLineWeight(3);
ThirdAggPlot.AssignValueColor(if ThirdAgg == 1
                              then color.green
                              else color.red);
AddChartBubble(x, 3, (agg3/1000/60) + " min", color.white, yes);
def FourthAgg = ST(agg = agg4, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot FourthAggPlot = if isNaN(cl)
                     then double.nan
                     else 4;
FourthAggPlot.SetStyle(Curve.Points);
FourthAggPlot.SetLineWeight(3);
FourthAggPlot.AssignValueColor(if FourthAgg == 1
                               then color.green
                               else color.red);
AddChartBubble(x, 4, (agg4/1000/60) + " min", color.white, yes);
def FifthAgg = ST(agg = agg5, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot FifthAggPlot = if isNaN(cl)
                    then double.nan
                    else 5;
FifthAggPlot.SetStyle(Curve.Points);
FifthAggPlot.SetLineWeight(3);
FifthAggPlot.AssignValueColor(if FifthAgg == 1
                              then color.green
                              else color.red);
AddChartBubble(x, 5, (agg5/1000/60)+ " min", color.white, yes);
plot Six = if isNaN(cl)
           then double.nan
           else 6;
Six.SetStyle(Curve.Points);
Six.SetLineWeight(3);
Six.AssignValueColor(if FirstAgg and
                        SecondAgg and
                        ThirdAgg and
                        FourthAgg and
                        FifthAgg
                     then color.green
                     else if !FirstAgg and
                             !SecondAgg and
                             !ThirdAgg and
                             !FourthAgg and
                             !FifthAgg
                          then color.red
                     else color.black);
# End Code ST MTF
 
Last edited:

full_of_options

New member
Thank you for sharing. You say the values are ideal for futures but which values would you recommend for intraday equities and options trading? Thanks again.

 
Last edited:

BenTen

Administrative
Staff
VIP
@full_of_options That was the note from the original author. I'm not sure what he was referring to.

 
Last edited:

full_of_options

New member
@BenTen no worries then, appreciate the time and quick responses. btw you've got lots of great content and knowledge on here, very noble of you to share the wealth and offer support. kudos to you.

 
Last edited:

BenTen

Administrative
Staff
VIP
@netarchitech Haha, I saw that and not surprised at all. If you noticed, some other indicators like ORB and Auto Fibs are being sold online as well. Crazy!
 
Last edited:

BenTen

Administrative
Staff
VIP
@wombat711 Pay attention to the following lines:

Rich (BB code):
plot SuperTrendUP = if ST crosses below close then 1 else 0;
plot SuperTrendDN = if ST crosses above close then 1 else 0;
  • Include the first one if you're looking for bullish trend.
  • Include the second one if you're looking for bearish trend.
Never have both on the same scanner.
 
Last edited:

danl

New member
Hey guys - just found this forum. Looked awesome so I signed up. I've got the supertrend indicator and love it. The scanner - I cannot get it to return anything. Has anyone successfully run this scanner? I've had it search for values = 1.0, >1.0, > or =1.0, and all the same options but for 0. What am I missing?!

 
Last edited:

mc01439

Well-known member
2019 Donor
VIP
I use the scanner each trading day. The code is written to show new signals

#plot SuperTrendUP = if ST crosses below close then 1 else 0;

plot SuperTrendDN = if ST crosses above close then 1 else 0;

If you want to show active signals use the following;

plot SuperTrendUP = if ST < close then 1 else 0;

plot SuperTrendDN = if ST >close then 1 else 0;

 
Last edited:

netarchitech

Well-known member
VIP
@BenTen posted, when it comes to scanning, you can use as many inputs and defs as you need, but you can only run one plot:

Given the following last two lines of the SuperTrend scan:

Rich (BB code):
#plot SuperTrendUP = if ST crosses below close then 1 else 0;
plot SuperTrendDN = if ST crosses above close then 1 else 0;

You'll notice the hashtag character (#) in the beginning of the first line. That comments out that plot statement so the compiler skips over it and runs the second plot statement. When you want to run the first plot statement, you just delete the hashtag and type another hashtag in front of the first plot statement.

Hope this helps...

Good Luck and Good Trading :)
 
Last edited by a moderator:

danl

New member
@mc01439

Guys thanks so much for the quick responses. I found my problem. This probably should have been understood by me - but I've never scanned this way. You have to use the "thinkscript editor" in the scan - no the "condition wizard". I've always used the wizard. See below. Thanks again!

Cnaoht5.png


 
Last edited:

Similar threads

Top