Archived: Supertrend Indicator by Mobius for ThinkorSwim

Status
Not open for further replies.

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

this is a great indicator but i can't get it to work on the app because the candles in the TOS app (android) cant change colour. however, i got an idea, instead of showing bubble, is it possible to let it indicate an Up or Down arrow instead ? This way, it should work just fine on the app version. can anyone help me with that ?
 
@tutianlong Not possible in the mobile app. That’s why we have it as a lower study.
then is it possible i plot rmi in the same study n it only spike if the candle goes below/above the supertrend line n rmi hits oversold/overbought region ? just trying to see how to weave 2 indicators together
 
@tutianlong What's RMI? I don't have any experience with tweaking indicators so they can work with the mobile app.
 
relative momentum index. i tweaked a version of it so i can set the ob/os levels as the default rmi indicator do not allow you change it. it worked just fine on both mobile n desktop version.
 
@tutianlong Not possible in the mobile app. That’s why we have it as a lower study.

Hey @BenTen
I think that I have managed to create the study on top of the chart for the mobile app. Could you please have a look here?

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 SuperTrendUp = close crosses above ST;
plot SuperTrendDown = close crosses below ST;
#SuperTrend.AssignValueColor(if close < ST then Color.RED else Color.GREEN);
SuperTrendUp.SetDefaultColor(Color.YELLOW);
SuperTrendUp.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
SuperTrendDown.SetDefaultColor(Color.PINK);
SuperTrendDown.setPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
@mh786 Thank you for that. Just tested it :) Looks good on the ToS app. Also made a note in the original thread ;)
 
@BenTen I am having trouble with the scanner. I have read this thread and using the code from the first post. I am getting false positives or signals for ST that has been running for a few days. What I am looking for is a scan that will provide a new ST bullish signal. Below is what I am using for a scan.

Stock Hacker filters

Here is the study code.

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

This returns 57 results, with around half that are false signals. Here are a few examples:

False signal with ST showing existing Bearish Trend

Existing Bullish Trend

Please let me know if I am doing something wrong to get these false signals. Thank you for your time!
 
@BenTen I am having trouble with the scanner. I have read this thread and using the code from the first post. I am getting false positives or signals for ST that has been running for a few days. What I am looking for is a scan that will provide a new ST bullish signal. Below is what I am using for a scan.

Stock Hacker filters

Here is the study code.

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

This returns 57 results, with around half that are false signals. Here are a few examples:

False signal with ST showing existing Bearish Trend

Existing Bullish Trend

Please let me know if I am doing something wrong to get these false signals. Thank you for your time!

My suggestion is that you search for stocks using Average Daily Volume...not regular Volume as your setting now with the volume will not show results UNTIL 1,000,000 volume is hit for the given day...By then it could be way too late to even make any moves.
 
My suggestion is that you search for stocks using Average Daily Volume...not regular Volume as your setting now with the volume will not show results UNTIL 1,000,000 volume is hit for the given day...By then it could be way too late to even make any moves.

Thank you @HighBredCloud for the suggestion.

Is this the code you would use to accomplish that?

Code:
Average("data" = VOLUME, "length" = 10) is greater than 1000000

Also, I don't think that explains the false positives I am receiving with the scan. Any thoughts on that?
 
Thank you @HighBredCloud for the suggestion.

Is this the code you would use to accomplish that?

Code:
Average("data" = VOLUME, "length" = 10) is greater than 1000000

Also, I don't think that explains the false positives I am receiving with the scan. Any thoughts on that?
Add a study filter in the upper right...and its under volume. I normally set to greater than 500K
 
@corello Here is the code for that. It comes in 2 parts.

Step 1: Create a new Strategy (not a Study) > Copy and Paste the original code in the first page into it.

Step 2: Add the following code to the end of the script:

Code:
# The following code is for backtesting
def SuperTrendUP = if ST crosses below close then 1 else 0;
def SuperTrendDN = if ST crosses above close then 1 else 0;

Step 3a: If you want to test out bullish strategy then add this code after the code from Step 2:

Code:
# Bullish Orders
AddOrder(OrderType.BUY_TO_OPEN, condition = SuperTrendUp, price = close,100, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "BUY");
AddOrder(OrderType.SELL_TO_CLOSE, condition = SuperTrendDN, price = open,100, tickcolor = Color.RED, arrowcolor = Color.RED, name = "SELL");

Step 3b: If you want to test out bearish strategy then add this code after the code from Step 2:

Code:
# Bearish Orders
AddOrder(OrderType.SELL_TO_OPEN, condition = SuperTrendDN, price = open,100, tickcolor = Color.RED, arrowcolor = Color.RED, name = "SELL");
AddOrder(OrderType.BUY_TO_CLOSE, condition = SuperTrendUp, price = close,100, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "BUY");

Do not place both codes from 3a and 3b into the same script.


Any reason as to why both can not be used? Or would there be a way to add a mode for bullish or bearish? (I attempted but failed using the following)
def bull;
def bear;
switch (mode) {
case "Bull":
buy =SuperTrendUp;
sell =SuperTrendDN ;
case "Bear":
buy = SuperTrendDN;
sell = SuperTrendUp;
}
;

AddOrder(OrderType.SELL_TO_OPEN, condition = buy, price = open,1, tickcolor = Color.RED, arrowcolor = Color.RED, name = "SELL");
AddOrder(OrderType.BUY_TO_CLOSE, condition = sell, price = close,1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "BUY");

I think I can see the issue but am confused as to why it allows you to have both bullish and bearish orders even if it's only displaying (or sems like it is only displaying )1 of the 2 .....I hope that makes sense 😬 Thanks!!
 
@kshires4 - Please post the code.
@mc01439

Code:
# SuperTrend Yahoo Finance Replica - Modified from Modius SuperTrend
# Modified Modius ver. by RConner7
# BULL SCANNER #
# Works similar to how Yahoo Finance Supertrend works and displays. Holds supertrend value until cross.

input AtrMult = 1.00;
input nATR = 6;
input AvgType = AverageType.HULL;
input PaintBars = yes;

def ATR = ATR("length" = nATR, "average type" = AvgType);
def UP_Band_Basic = HL2 + (AtrMult * ATR);

def LW_Band_Basic = HL2 + (-AtrMult * ATR);

def UP_Band = if ((UP_Band_Basic < UP_Band[1]) or (close[1] > UP_Band[1])) then UP_Band_Basic else UP_Band[1];

def LW_Band = if ((LW_Band_Basic > LW_Band[1]) or (close[1] < LW_Band[1])) then LW_Band_Basic else LW_Band[1];

def ST = if ((ST[1] == UP_Band[1]) and (close < UP_Band)) then UP_Band
else if ((ST[1] == UP_Band[1]) and (close > Up_Band)) then LW_Band
else if ((ST[1] == LW_Band[1]) and (close > LW_Band)) then LW_Band
else if ((ST[1] == LW_Band) and (close < LW_Band)) then UP_Band
else LW_Band;

plot ST_Cross = if (ST crosses below close) within 2 bars then 1 else 0;
 
@kshires4, - try this

Code:
# SuperTrend Yahoo Finance Replica - Modified from Modius SuperTrend
# Modified Modius ver. by RConner7
# BULL SCANNER #
# Works similar to how Yahoo Finance Supertrend works and displays. Holds supertrend value until cross.

input AtrMult = 1.00;
input nATR = 6;
input AvgType = AverageType.HULL;
input PaintBars = yes;

def ATR = ATR("length" = nATR, "average type" = AvgType);
def UP_Band_Basic = HL2 + (AtrMult * ATR);

def LW_Band_Basic = HL2 + (-AtrMult * ATR);

def UP_Band = if ((UP_Band_Basic < UP_Band[1]) or (close[1] > UP_Band[1])) then UP_Band_Basic else UP_Band[1];

def LW_Band = if ((LW_Band_Basic > LW_Band[1]) or (close[1] < LW_Band[1])) then LW_Band_Basic else LW_Band[1];

def ST = if ((ST[1] == UP_Band[1]) and (close < UP_Band)) then UP_Band
else if ((ST[1] == UP_Band[1]) and (close > Up_Band)) then LW_Band
else if ((ST[1] == LW_Band[1]) and (close > LW_Band)) then LW_Band
else if ((ST[1] == LW_Band) and (close < LW_Band)) then UP_Band
else LW_Band;

plot ST_Cross = if (ST crosses below close) within 2 bars then 1 else 0;

AssignBackgroundColor(if close crosses below st
                      then Color.DARK_RED
                      else if close crosses above st
                      then Color.DARK_GREEN
                      else color.LIGHT_GRAY);
 
@mc01439 Works Perfect !!!! Thank you so much. Would you be able to help with a triple supertrend scanner? 7/3,10/3,11/2. Have had some good results with this but would like to be able to scan for opportunities
 
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
323 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