Archived: Supertrend Indicator by Mobius for ThinkorSwim

Status
Not open for further replies.
@BbenSD It shouldn't.


@BenTen You are absolutely right - the study does not repaint bars in the manner that a study like Zig Zag High Low does. Here the use of the variable "PaintBars" is meant to be a flag as to whether the bars/candles should be color coded or not. Perhaps this might be the reason why this issue was brought up. A closer examination of the code always gives one the answers!
 

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

Great Indicator, is there anyway I can add the Floating P/L Indicator with the SuperTrend Indicator here? That way I can quickly see if the indicator works well with each stock.
 
Code:
# SuperTrend - "Strategy"     A Very simple SuperTrend Strategy
# Chat Room Request
# V03.10.2015
#Hint:Supertrend Indicator: shows trend direction and gives buy or sell signals according to that. 

input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
input BubbleOn = yes;
input ShowLabel = yes;

def h = high;
def l = low;
def c = close;
def v = volume;
def bar = barNumber();
def EOD = if SecondsTillTime(1545) == 0 and
             SecondsFromTime(1545) == 0
          then 1
          else 0;
def NotActive = if SecondsFromTime(1545) > 0
                then 1
                else 0;
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 UP 
         else DN;
plot SuperTrend = ST;
SuperTrend.AssignValueColor(if c < ST then Color.RED else Color.GREEN);
SuperTrend.SetPaintingStrategy(PaintingStrategy.Line);
AssignPriceColor(if PaintBars and c < ST 
                 then Color.RED 
                 else if PaintBars and c > ST 
                      then Color.GREEN 
                      else Color.CURRENT);

AddOrder(OrderType.BUY_AUTO, HL2 crosses above ST, price = open[-1], tickcolor = Color.BLACK, arrowcolor = Color.BLACK, name = "");
AddOrder(OrderType.SELL_AUTO, HL2 crosses below ST, price = open[-1], tickcolor = Color.BLACK, arrowcolor = Color.BLACK, name = "");
 
Hi, does this indicator work best for small caps or large caps. When I review it with large caps I see a better flow of entries and exits but when I review them on small caps the bubbles are all close to each other not giving a chance for a trade.
 
@convertiblejay I think you just answered your own question. If you do not see any real potential from using Supertrend on small caps, then it's best to avoid that. :)
 
Having read through the pages on Mobius' Supertrend I did notice a image posted of watchlist columns for this study. There was a request for the script but I did not find that. Could someone please post the script for the watchlist column?

Thanks, Doug

P.S. Please provide the script rather than a shareable link. Thx!
 
@dougn As you requested, here is the very last version of the SuperTrend Watchlist that Mobius posted

Code:
# SuperTrend for WatchList
# Mobius
# 8.8.2017

input AtrMult = .7;
input nATR = 4;
input AvgType = AverageType.Hull;

def h = high;
def l = low;
def c = close;
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();
def count = if c crosses below ST
            then 1 
            else if c < ST
                 then count[1] + 1
                 else if c crosses above ST
                      then 1
                      else if c > ST[1]
                           then count[1] + 1
                           else count[1];
AddLabel(1, count, color.black);
AssignBackgroundColor(if c < ST 
                      then Color.Red 
                      else Color.Green);
 
@tomsk Why is it if I put the watchlist columns under the same watchlist, both color blocks can only be changed to one TF? For example, I put two of these on one watchlist, one on the hourly and one on the 15 min but when I change one, the other one changes. So both are either the one hour OR the 15 minute.
 
@MBF Not sure which watchlist column you used. I just tested Mobius watchlist column from post #150, using a daily aggregation in one column and 15 min aggregation in a second column. Both columns are showing very different results/colors as you'd expect. Just make sure that when you install the watchlist column that you remember to define the aggregation period of your choice at the top of the Custom Column you are configuring.
 
@MBF I looked into one of the stocks on your watchlist, NFLX. It plots a count of 7 on both watchlists in RED color.

At this point I loaded Mobius watchlist (post # 150), I see a count of 2 with GREEN color (DAILY Aggregation) while on the 15 min I see a count of 2 with RED color. Something is very wrong with what your watchlist is displaying. You must be using some wrong code or something else is up. There is no way you'll see a count of 7 for both your watchlists.

To confirm this, I loaded the following study on both a a daily chart and a 15 min chart of NFLX. They both show a count of 2 as evident from the last bar on that study. corresponding to the results I see on my watchliust

Time for you to run some diagnostics @MBF and cross check for yourself. I can't really do anything else on my end.
Here is the study I loaded on my charts - using both daily aggregation as well as 15 min aggregation.

Bear in mind that you should run these tests when the market is closed because once trading resumes RTH Monday the ST counts may be different due to market movement/volatility

Code:
# SuperTrend Lower (To Verify Count)
# Mobius, modified by tomsk, 1.5.2020
# 8.8.2017

# This is to be loaded on a chart to verify the ST count

declare lower;

input AtrMult = .7;
input nATR = 4;
input AvgType = AverageType.Hull;

def h = high;
def l = low;
def c = close;
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();
def count = if c crosses below ST
            then 1
            else if c < ST
                 then count[1] + 1
                 else if c crosses above ST
                      then 1
                      else if c > ST[1]
                           then count[1] + 1
                           else count[1];

plot x = count;

#AddLabel(1, count, color.black);
#AssignBackgroundColor(if c < ST
#                      then Color.Red
#                      else Color.Green);
# End SuperTrend Lower (To Verify Count)
 
@MBF I was afraid you might not know so let me get real specific here. In your post # 155 for NFLX, do you see the number being displayed on both your watchlist columns - Daily and 15 mins? Well to verify if this is indeed the right number, load the study in post # 156 on a chart. Then load the ticker NFLX and set that to daily aggregation. Now look at the Y axis next to the last candle. There is a number highlighted. This number should match whatever is displayed in the watchlist column. This is the test I was referring to. Just confirming that the number as reported in the watchlist is correct. Pretty ain't it?
 
Happy new year. so I've been reading this thread again and I noticed that script for the watchlist posted. I'm trying to determine what the numbers in the red or green boxes pertain to? Also, watching the Mobius super trend live on a 5-minute chart, I'd get the indication to short (the gray bubble with a price) and then look at the same area later and it seems that the entry price changes retrospectively. That's why I asked if it repaints. I'm like 99% sure this occurred. This obviously isn't helpful when backtesting. Why does that happen?
 
I have a question regarding this study, if you look at the chart below and the highlighted area, it`s in a uptrend from approx 3.60 up to 4 but the candles are red. Why does it paint the bars red when it`s currently uptrending?

I have seen this happen at a few occasions but it`s not very often. Just curious how to interpret when it paints bars like this.

WoeMrLH.png
 
Only way to determine this is to look at the code. Post the actual code you are using. Also indicator which ticker is loaded on the chart as well as the aggregation period used. Only then could we have a clue at what you're describing - I'd concur with you that it sure sounds odd.
 
Only way to determine this is to look at the code. Post the actual code you are using. Also indicator which ticker is loaded on the chart as well as the aggregation period used. Only then could we have a clue at what you're describing - I'd concur with you that it sure sounds odd.

Ticker SNCA using 1 min timeframe. The chart is from today.

# Mobius

# SuperTrend

# Chat Room Request

# 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.

#Hint: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



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);

# End Code SuperTrend
 
Status
Not open for further replies.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
335 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