Supertrend Indicator by Mobius for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
@JoshF We already shared the code for the alerts. Scroll up a bit and take a look at message #68
 
J

JoshF

New member
@JoshF We already shared the code for the alerts. Scroll up a bit and take a look at message #68
Hi Ben, These alerts do not work for pushing to a mobile device/email - unless I am mistaken and there is a way to include these SMS/email alerts within ThinkScript?. Neither does this solve the problem of being able to use this strategy in a conditional order or study alert (where mobile alerts are available) where the "rec usage" function is not permitted.
 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@JoshF The method I showed you will only work when you have the chart loaded on your screen (desktop). To setup something like a mobile alerts, you would have to create a watchlist scanner and enable the option there.
 
J

JoshF

New member
Yep correct, I've done that as well and I believe it has corrected the alerts concern. Ideally - like I mentioned I would like to set up a conditional order based on these indicators to have thinkorswim execute orders automatically once the signal conditions are met. This is possible with other indicators but not when recursive code is used. I am asking if there is anyway to modify this code so that it doesn't have recursive code but still accomplish what we want here.

Awesome site here by the way, great resource!
 
BenTen

BenTen

Administrative
Staff
VIP
@JoshF I hear ya. I don't have much knowledge on that. Hopefully someone can chime in. Someone asked about adding buy and sell (for backtesting purposes) into the script and you can find that code here.
 
M

Midlifetrader

New member
Im a new member of the this group and I thank you for sharing this script.

Is there a way to create a watchlist for this script and alerts us via text or via the TOS program if one of our stocks in our watchlist gets the buy or sell signal in a daily or intraday timeframe?
 
T

Talochka

Member
@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);
Hello, BenTen, can you please modify the code for Bubble to move it slightly lower or higher (depending on situation), otherwise its just sits on candle and is hard to read on some charts.
Thanks in advance
 
T

tomsk

Well-known member
VIP
@Talochka @BenTen I have adjusted the bubbles, fixed the coloring and added a buy/sell description on the bubble
Note that the bubbles can be further moved to your preference by changing the value of the variable "n"
You can do this either in the code directly or via the input selector in the user interface
Hope this would be aesthetically better visually.

EDIT: I have based my modifications based on @BenTen post #1 in this thread

Code:
# SuperTrend
# Mobius
# Chat Room Request
# 11.20.2019 tomsk Enhanced and adjusted bubbles with coloring and description tag

input AtrMult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
input n = 0;
def n1  = n + 1;
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[n] crosses below ST[n], low[n+1] + TickSize() * n, "Sell @ " + low[n1], color.Cyan, yes);
AddChartBubble(close[n] crosses above ST[n], high[n+1] - TickSize() * n, "Buy @ " + high[n1], color.Yellow, no);

# End Code SuperTrend
 
Last edited:
T

Talochka

Member


thanks a bunch!!!!!! @tomsk, it did not work for all of them.
I changed n to 4. Some are ok and some not.
Please help.
Thanks
 
B

BbenSD

New member
VIP
Hey guys, so I've been messing around with the scanner, trying to get the script to find a current bar crossing above supertrend line but I just can't seem to get this scanner to work for me. Basically i'm just looking for a scan that can show me when the bullish bubble populates on the chart. I've tried a bunch of variations and I've used the # to remove the bearish portion of the script but it doesn't work. Any help is appreciated.
 
BenTen

BenTen

Administrative
Staff
VIP
@BbenSD By doesn't work, what do you mean by that? No signal? Did you adjust the timeframe in the scanner to the timeframe that you want? By default, it will scan for signals on the daily chart.
 
H

HighBredCloud

Active member
VIP
@tomsk anyway to reverse the chart bubble to point left of the candlestick instead of the right? Or possibly even relocating the bubbles to top of the screen somewhere so its out of the way of the candlesticks?

Please refer to the pic...the one on the left shows the bubble on the left of the candlestick when you're scrolling back...while the one on the right appears when you're scrolling right or with the market. I think it would be more visible if the chart bubbles where facing the other way so they don't block the current candlesticks...


Also someone here mentioned I think it was @BenTen that this SuperTrend does not repaint...do you know of any other SuperTrends that do not repaint? I really liked what you did with the Magic Trend and the triangles and I was wondering if perhaps you'd be able to do something similar by combining 3 or so SuperTrends that don't repaint and make something like you did with the Magic Trend?
 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@HighBredCloud There are multiple versions of the SuperTrend indicator. I don't think none of them would repaint. A few have been posted on here before as well.
 
H

HighBredCloud

Active member
VIP
@HighBredCloud There are multiple versions of the SuperTrend indicator. I don't think none of them would repaint. A few have been posted on here before as well.
@BenTen yeah I am searching for them as we speak...I did notice that some use ATR and some are ATR and CCI...I just would like something that does not repaint. I have seen various version of the SuperTrend as well but some do repaint mid candle etc...More or less I wanted to see what people are using as their favorite SuperTrends and compile something that I mentioned to @tomsk above...
 
BenTen

BenTen

Administrative
Staff
VIP
@HighBredCloud "but some do repaint mid candle etc".

That's not repainting. It just means the current candle is still being developed and so you would have to wait for it to close in order to confirm if there is a signal or not. I have yet to check all the versions of SuperTrend on this site, so I can't confirm which one will repaint.
 
B

BbenSD

New member
VIP
@BbenSD By doesn't work, what do you mean by that? No signal? Did you adjust the timeframe in the scanner to the timeframe that you want? By default, it will scan for signals on the daily chart.
Yeah, I've got it on 5 minutes on the TOS side, I've altered nothing in the script except for adding the hashtag to exclude bearish scans.

By saying it doesn't work, I mean the scanner doesn't return results showing the current candle crossing up on the supertrend line, it just shows random conditions unrelated.

this is what I have for the script, and my TOS timeframe is on 5 minutes as well as the indicator + chart:

# 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;
# End Code SuperTrend
 
BenTen

BenTen

Administrative
Staff
VIP
@BbenSD Using the snippet you posted, I ran the scanner, and here are my results from the S&P 500 watchlist / 5min chart.

I checked some of these results, and they were showing correctly. I do not see any issue on my side.

 
B

BbenSD

New member
VIP
@BbenSD Using the snippet you posted, I ran the scanner, and here are my results from the S&P 500 watchlist / 5min chart.

I checked some of these results, and they were showing correctly. I do not see any issue on my side.

Alright, mine came up with the same results. But if you were to look at the stocks on a 5-minute chart, only 15 of the 50 on that page had within 1 bar, generated the Bullish Supertrend bubble, why? Have any idea to filter out the inaccuracies? And really, thanks for the help bro.
 
BenTen

BenTen

Administrative
Staff
VIP
@BbenSD Can you post an example or two of the misinformation or "wrong signal"? Preferably through screenshots, so I know what you're looking at on your 5m chart. If you don't know how to upload images, then take a look at this post.
 
Last edited:
B

BbenSD

New member
VIP
Yeah for example, here's adobe. The bubble isn't pertinent to either the close at 1PST or Afterhours, so what is it telling me?

 
Last edited by a moderator:

Top