Archived: Supertrend Indicator by Mobius for ThinkorSwim

Status
Not open for further replies.
Hi Ben,

Just an update and a favour. I have my chart set up on the ES over Globex as well as during cash market. I have the ORB as well as the supertrend indicator on and guided by Squeeze indicator and the MACD on a 15 min . Tried a few live trades guided by these indicators -seem to work well.

But find myself in front of the screen waiting for the colour change on the candlesticks. Is it possible to have an audio alert when the color changes or when the price numbers appear? What do you think? If you could help to have write a code on it.
 
@Jenny Here is the code for that. Just add it to the bottom of your Supertrend script.

Code:
def bullish = close crosses below ST;
def bearish = close crosses above ST;

# Alerts
Alert(bullish, " ", Alert.Bar, Sound.Chimes);
Alert(bearish, " ", Alert.Bar, Sound.Bell);
 
what does natr represent?
This is a Supertrend indicator for ThinkorSwim created by Mobius.



N3y7JFY.png


thinkScript Code for Supertrend

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

Video Tutorial

What does nATR represent? Some kind of bar value?
 
what does natr represent?

What does nATR represent? Some kind of bar value?
Hi Yung,
ATR is important. Go to investopedia.com and look up things you don't really know anything about. They explain things clearly and it's easy to understand. You will probably need further study after that by looking at charts at the same time you're learning so you can see what they are talking about. Easiest way.
 
Has anyone tried to play around with the ATR MULT? I have changed the settings from 1.0 to .5 on a 5 min chart and .4 on 15 min+...these settings closely resemble Heikin Ashi candles sticks for such time frames...
 
@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.
 
@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.
 
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!
 
@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.
 
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?
 
@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
 
@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
 
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.
 
@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.
 
@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?
 
@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.
 
@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...
 
@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.
 
Status
Not open for further replies.

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
368 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top