Repaints Chewie's Super Trend, Hull Average, Donchian Trend Ribbon Trading System for ThinkorSwim

Repaints
Do you know where I can find this on TradingView by chance?
I’m not a frequent user of Trading View but if I remember it’s just called SuperTrend and is available in the indicators section. Couldn’t tell you where that’s at without getting on the computer but I believe it’s at the top left of the chart if I remember correctly
 
script, Reversal_Indicator
Condition Wizard
The complexity of the expression suggests that it may not be reliable with real-time data.

def price = close;
def superfast_length = 9;
def fast_length = 14;
def slow_length = 21;
def displace = 0;

def mov_avg9 = ExpAverage(price[-displace], superfast_length);
def mov_avg14 = ExpAverage(price[-displace], fast_length);
def mov_avg21 = ExpAverage(price[-displace], slow_length);

#moving averages
def Superfast = mov_avg9;
def Fast = mov_avg14;
def Slow = mov_avg21;

def buy = mov_avg9 > mov_avg14 and mov_avg14 > mov_avg21 and low > mov_avg9;
def stopbuy = mov_avg9 <= mov_avg14;
def buynow = !buy[1] and buy;
def buysignal = CompoundValue(1, if buynow and !stopbuy then 1 else if buysignal[1] == 1 and stopbuy then 0 else buysignal[1], 0);
 
Has anyone used this with success? If so, Please explain how you used it. Thanks in advance!
 
I am just starting to use this setup. Ill keep eveyone updated as well. Watching main market tickers for the most part on 4min chart.
 
@chaseimo Try this...

Ruby:
# filename: Hull_SuperTrend_System_SCAN

#Hull_SuperTrend_Trading_System
# assembled by Chewie 4/10/2022
# many thanks to all the other noted contributors to this system.

# SuperTrend Yahoo Finance Replica - Modified from Modius SuperTrend
# Modified Modius ver. by RConner7
# Modified by Barbaros to replicate look from TradingView version
# Modified by Barbaros to add EMA cross for bubbles and alerts
# Modified by Barbaros to update bar color painting
# v3.3

#input Target_Bubbles = yes;
#input Entry_SL_Bubbles = yes;
#input labels = yes;
#input alertON = no;
input Bands = no;
input EMA1 = 10;
input EMA2 = 20;
input AvgType = AverageType.HULL;
input STAtrMult = 2.75;
input nATR = 12;

def ATR = ATR("length" = nATR, "average type" = AvgType);
def UP_Band_Basic = HL2 + (STAtrMult * ATR);
def LW_Band_Basic = HL2 + (-STAtrMult * 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;

def EMA1Val = MovAvgExponential(close, EMA1);
def EMA2Val = MovAvgExponential(close, EMA2);
def EMADirection = if EMA1Val > EMA2Val then 1 else if EMA1Val < EMA2Val then -1 else 0;

def Long = if close > ST then ST else Double.NaN;
def Short = if close < ST then ST else Double.NaN;

def LongTrigger = IsNaN(Long[1]) and !IsNaN(Long);
def ShortTrigger = IsNaN(Short[1]) and !IsNaN(Short);

def LongDot = if LongTrigger then ST else Double.NaN;
def ShortDot = if ShortTrigger then ST else Double.NaN;

#
# Hull Moving Average Concavity and Turning Points
#
# Author: Seth Urion (Mahsume)
# Version: 2020-05-01 V4
#
# Now with support for ToS Mobile - disabled
#

declare upper;

input HMA_Length = 60;
input lookback = 3;
input arrows = no;

def price = HL2;
def HMA = HullMovingAvg(price = price, length = HMA_Length);
def delta = HMA[1] - HMA[lookback + 1];
def delta_per_bar = delta / lookback;
def next_bar = HMA[1] + delta_per_bar;
def concavity = if HMA > next_bar then 1 else -1;

def turning_point = if concavity[1] != concavity then HMA else Double.NaN;

def MA_Max = if HMA[-1] < HMA and HMA > HMA[1] then HMA else Double.NaN;
def MA_Min = if HMA[-1] > HMA and HMA < HMA[1] then HMA else Double.NaN;

#def BuySetup = HMA > HMA[1] and HMA[1] < HMA[2];
#def SellSetup =  HMA < HMA[1] and HMA[1] > HMA[2];

#plot sell = if arrows and turning_point and concavity == -1 then high else Double.NaN;
#sell.SetDefaultColor(Color.DARK_ORANGE);
#sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#sell.SetLineWeight(3);
#sell.hide();

#plot buy = if arrows and turning_point and concavity == 1 then low else Double.NaN;
#buy.SetDefaultColor(Color.CYAN);
#buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#buy.SetLineWeight(3);
#buy.hide();

def divergence = HMA - next_bar;


###################
#
# 2020-05-01
#
# MOBILE TOS SUPPORT
#
# Each color of the HMA needs to be a separate plot as ToS Mobile
# lacks the ability to assign colors the way ToS Desktop does.
# I recommend a plain colored HMA behind the line
# Set the line color of the HMA above to gray or some neutral
#
# CCD_D -> ConCave Down and Decreasing
# CCD_I -> ConCave Down and Increasing
# CCU_D -> ConCave Up and Decreasing
# CCU_I -> ConCave Up and Increasing
#
###################
#plot CCD_D = if concavity == -1 and HMA < HMA[1] then HMA else Double.NaN;
#CCD_D.SetDefaultColor(Color.RED);
#CCD_D.SetLineWeight(1);
#CCD_D.hide();

#plot CCD_I = if concavity == -1 and HMA >= HMA[1] then HMA else Double.NaN;
#CCD_I.SetDefaultColor(Color.DARK_ORANGE);
#CCD_I.SetLineWeight(1);
#CCD_I.hide();

#plot CCU_D = if concavity == 1 and HMA <= HMA[1] then HMA else Double.NaN;
#CCU_D.SetDefaultColor(Color.DARK_GREEN);
#CCU_D.SetLineWeight(1);
#CCU_D.hide();

#plot CCU_I = if concavity == 1 and HMA > HMA[1] then HMA else Double.NaN;
#CCU_I.SetDefaultColor(Color.GREEN);
#CCU_I.SetLineWeight(1);
#CCU_I.hide();

#Hull Label

#AddLabel(yes and labels and CCD_D, "HULL:SELL", color.RED);
#AddLabel(yes and labels and CCU_I, "HULL:BUY", color.green);
#AddLabel(yes and labels and CCU_D, "HULL:WEAK SELL", color.dark_green);
#AddLabel(yes and labels and CCD_I, "HULL:WEAK BUY", color.DARK_ORANGE);

#Target lines
# created by chewie

rec line = if IsNaN(MA_Min) then line[1] else MA_Min[0];
def L_stoploss = if IsNaN(MA_Min) then line else Double.NaN;
def LSL = (if IsNaN(L_stoploss[1]) then L_stoploss else Double.NaN);

rec line2 = if IsNaN(MA_Max) then line2[1] else MA_Max[0];
def S_stoploss = if IsNaN(MA_Max) then line2 else Double.NaN;
def SSL = (if IsNaN(S_stoploss[1]) then S_stoploss else Double.NaN);

#Short Entry
rec line3 = if IsNaN(Long) then line3[1] else Long[0];
def S_Entry = if IsNaN(Long) then line3 else Double.NaN;
def SE = (if IsNaN(S_Entry[1]) then S_Entry else Double.NaN);

#Long Entry
rec line4 = if IsNaN(Short) then line4[1] else Short[0];
def L_Entry = if IsNaN(Short) then line4 else Double.NaN;
def LE = (if IsNaN(L_Entry[1]) then L_Entry else Double.NaN);


#HalfX Long
def x1a_Long =  (L_Entry + (L_Entry - L_stoploss) / 2) ;

#OneX Long
def x1_Long = if x1a_Long > line4 then (L_Entry + (L_Entry - L_stoploss)) else Double.NaN;

#TwoX Long
def x2_Long = x1_Long + (L_Entry - L_stoploss) ;
def X2L = (if IsNaN(x2_Long[1]) then x2_Long else Double.NaN);

#ThreeX Long
def x3_Long = x2_Long + (L_Entry - L_stoploss) ;
def X3L = (if IsNaN(x3_Long[1]) then x3_Long else Double.NaN);

#FourX Long
def x4_Long = x3_Long + (L_Entry - L_stoploss) ;
def X4L = (if IsNaN(x4_Long[1]) then x4_Long else Double.NaN);


#HalfX Short
def x1a_Short = (S_Entry - (S_stoploss - S_Entry) / 2);

#OneX Short
def x1_Short = if x1a_Short < line3 then (S_Entry - (S_stoploss - S_Entry)) else Double.NaN;

#TwoX Short
def x2_Short = x1_Short - (S_stoploss - S_Entry);
def X2S = (if IsNaN(x2_Short[1]) then x2_Short else Double.NaN);

#ThreeX Short
def x3_Short = x2_Short - (S_stoploss - S_Entry);
def X3S = (if IsNaN(x3_Short[1]) then x3_Short else Double.NaN);

#FourX Short
def x4_Short = x3_Short - (S_stoploss - S_Entry);
def X4S = (if IsNaN(x4_Short[1]) then x4_Short else Double.NaN);

#LinearRegCh100 RegressionDivergence - Trigger Lines - Trend Cross
# From Lizard Indicators Link: https://www.lizardindicators.com/trigger-lines-cross-vs-thrust/
# Line #1 - Fast = LinReg (80)
# Line #2 - Slow = EXPEMA[LinReg (80)]

input LinRegLength = 80;
input EMAlength = 20;
input ColorOn = yes;

#Definitions
def price1 = close;
def displace = 0;
def LinReg = Inertia(price1[-displace], LinRegLength);
def EMA_LR = ExpAverage(LinReg[-displace], EMAlength);
def Body = (open + close) / 2;

# Defining Long/Short Filters (these instructions determine entries / exits)
# Entry Requirements
def Long_Entry = close > LinReg and close > EMA_LR and Body > LinReg and Body > EMA_LR and close > high[1] and Body > Body[1];
# LinReg > LinReg[1] and
def Long_Stay_In = close > LinReg and close > EMA_LR;
def Long_Exit = (close < LinReg or close < EMA_LR) or Long_Stay_In == 0;
def Long_State = if Long_Entry then 1 else if Long_Exit then 0 else Long_State[1];
def Long1 = Long_State;

# Exit Requirements
def Short_Entry = close < LinReg and close < EMA_LR and Body < LinReg and Body < EMA_LR and close < low[1] and Body < Body[1];
# LinReg < LinReg[1] and
def Short_Stay_In = close < LinReg and close < EMA_LR;
def Short_Exit = (close > LinReg or close > EMA_LR) or Short_Stay_In == 0;
def Short_State = if Short_Entry then 1 else if Short_Exit then 0 else Short_State[1];
def Short1 = Short_State;

#Adding Linear Regression averages
def LR = LinReg;
def EMA_LinReg = EMA_LR;

#Regression Bands

input deviations = 1.618;  #set your deviation units here.
input length = 500; #set your channel lookback period here.

def stdDeviation = StDevAll(price, length);
def HighBand = if Bands then EMA_LinReg + deviations * stdDeviation else Double.NaN;
def LowBand = if Bands then EMA_LinReg - deviations * stdDeviation else Double.NaN;

#200 DAY MOVING AVERAGE

def price2 = close;
def displace2 = 0;
input lengthAvgEXP = 200;

def AvgExp = ExpAverage(price2[-displace2], lengthAvgEXP);

plot Triangle  = if HMA[-1] < HMA and HMA > HMA[1] then HMA else Double.NaN;
#plot Square = if HMA[-1] > HMA and HMA < HMA[1] then HMA else Double.NaN;

Hope this helps...

Good Luck and Good Trading :cool:
this does not work for me - i've tried multiple times - can you confirm it works to scan for the triangle or square?
 
Line : 355
I changed the code slightly to shut off and on coloring bars.
I found it useful to change it as follows.
# Coloring Bars
AssignPriceColor(
if ColorOn and Long_State then Color.GREEN else
if ColorOn and Short_State then Color.RED else
if ColorOn then Color.WHITE else Color.CURRENT );
 
Can you explain what "1600T chart" means?
On the chart:
  1. click on timeframe
  2. change it from Time to Tick
  3. in the Aggregation Period to 1600 ticks
https://tlc.thinkorswim.com/center/...Chart-Aggregation/Setting-up-Chart-Time-Frame
iBwpagF.png
 
@chewie76 Have been following this thread. Your indicator/system looks great!

Curious to find out if anyone is still using the TOS strategy or the base system. I know we saw a good 30 day result when the thread was started. Also, what are the optimal HMA/ATR/timeframe settings people are seeing?
 
@chewie76 Have been following this thread. Your indicator/system looks great!

Curious to find out if anyone is still using the TOS strategy or the base system. I know we saw a good 30 day result when the thread was started. Also, what are the optimal HMA/ATR/timeframe settings people are seeing?
I'm using the same timeframes in the code. I'm using the base system.
 
Hey chewie would you happen to offer a 1-1 training on this strategy? I'm new and looking to deposit some money to try this strategy out.
 
Hey chewie would you happen to offer a 1-1 training on this strategy? I'm new and looking to deposit some money to try this strategy out.
I don't. I suggest you spend a few weeks using paper trading account to test it out for yourself before you put money into it.
 
  • Like
Reactions: rfb
Anyone tried using the this system on ToS mobile? I was able to get most of it up on my 4 min chart. But I don't see the square/triangle signal. I would appreciate any help.
 
Anyone tried using the this system on ToS mobile? I was able to get most of it up on my 4 min chart. But I don't see the square/triangle signal. I would appreciate any help.
You have to go into the settings on mobile of the indicator and make those plots a square and a triangle manually. Then you will see them.
 
You have to go into the settings on mobile of the indicator and make those plots a square and a triangle manually. Then you will see them.
Thanks for getting back to me. Would you mind being a little more specific at to what to change? I'm new with scripting.
 
@chewie76 there a way to only allow the strategy to trade during RTH or is there a way to make it to where it only trades in after hours?? I want to do some back testing with only certain hours. TIA
 
Last edited by a moderator:
I'm using the same timeframes in the code. I'm using the base system.
Chewie76 Very cool I love it but Could you help me to just get one Green VerticalLine for long and one Red VerticalLine for short once we have all confirmations ? and not plot everything else or have option to hide it. I do not script;{
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
289 Online
Create Post

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