Supertrend Indicator by Mobius for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
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


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


Video Tutorial

 
Last edited:
C

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:
M

MasterSteve

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

 
Last edited:
C

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

BenTen

Administrative
Staff
VIP
Warehouse
@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:
S

San

Member
VIP
Its working great.. U always rocking... &#128516;

 
Last edited:
F

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

BenTen

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

 
Last edited:
F

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:
netarchitech

netarchitech

Active member
Thanks again, BenTen, for providing a site helping fellow thinkorswimmers... Interestingly enough, Mobius' work was offered on another site for the low, low price of $129!

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@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:
W

wombat711

New member
nice work is there any way you can use Stock Hacker to scan for trend switches

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@wombat711 Use this scanner posted above.

 
Last edited:
W

wombat711

New member
@BenTen I'm using the scanner code but my scan does not return anything

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@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:
D

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

mc01439

Active member
VIP
Warehouse
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

netarchitech

Active member
@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:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@netarchitech @danl please see their comments above.

 
Last edited:
D

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!



 
Last edited:

Top