HULLTSIBOT For ThinkOrSwim

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

Link to original Tradingview code: https://www.tradingview.com/script/gf21APTn-HULLTSIBOT/

Code:

Code:
//@version=4
strategy(title="TSIHULLBOT", shorttitle="TSICCIHULL", default_qty_type=strategy.percent_of_equity, default_qty_value=100)
long = input(title="Long Length", type=input.integer, defval=50)
short = input(title="Short Length", type=input.integer, defval=50)
signal = input(title="Signal Length", type=input.integer, defval=7)
price = input(title="Source",type=input.source,defval=open)
lineupper = input(title="Upper Line", type=input.integer, defval=250)
linelower = input(title="Lower Line", type=input.integer, defval=-250)
double_smooth(price, long, short) =>
    fist_smooth = hma(price, long)
    hma(fist_smooth, short)
pc = change(price)
double_smoothed_pc = double_smooth(pc, long, short)
double_smoothed_abs_pc = double_smooth(abs(pc), long, short)
tsi_value = (100 * (double_smoothed_pc / double_smoothed_abs_pc))*5
tsihmaline=(hma(tsi_value,signal))*5
clr = tsihmaline < tsi_value ? color.red : color.lime
clr2 = tsi_value < tsi_value[1] ? color.red : color.lime
i1=plot(lineupper+3, color=color.black, linewidth=3)
i2=plot(linelower+3, color=color.black, linewidth=3)
i3=plot(lineupper, color=clr)
i4=plot(linelower, color=clr)
trendv=tsihmaline/5.6
plot(trendv, linewidth=7,  color=color.black)
plot(trendv, linewidth=4,  color=color.yellow)
j1=plot(tsi_value, linewidth=5, color=color.black)
j2=plot(tsi_value[1], linewidth=5, color=color.black)
j3=plot(tsi_value, color=clr2)
j4=plot(tsi_value[1], color=clr2)
fill(i3,i4,color=clr,transp=90)
fill(j3,j4,color=clr2,transp=15)
longCondition = tsihmaline>tsihmaline[1] and price>price[1]
if (longCondition)
    strategy.entry("Buy ⤴️", strategy.long)
shortCondition = tsihmaline<tsihmaline[1] and price<price[1]
if (shortCondition)
    strategy.entry("Sell ⤵️", strategy.short)
check the below.

CSS:
# https://www.tradingview.com/v/gf21APTn/
#//@SeaSide420
#strategy(title="TSIHULLBOT", shorttitle="TSICCIHULL", default_qty_type=strategy.percent_of_equity, default_qty_value=100)
# converted by Sam4Cok@Samer800        - 03/2023
declare lower;
input long = 50;#(title="Long Length", type=input.integer, defval=50)
input short = 50;#(title="Short Length", type=input.integer, defval=50)
input signal = 7;#(title="Signal Length", type=input.integer, defval=7)
input price = open;#(title="Source",type=input.source,defval=open)
input lineupper = 250;#(title="Upper Line", type=input.integer, defval=250)
input linelower = -250;#(title="Lower Line", type=input.integer, defval=-250)

def na = Double.NaN;
def last = isNaN(close);
#double_smooth(price, long, short) =>
Script double_smooth {
input price = close;
input long = 50;
input short = 20;
    def fist_smooth = HullMovingAvg(price, long);
    def hma = HullMovingAvg(fist_smooth, short);
    plot out = hma;
}
def pc = price-price[1];
def double_smoothed_pc = double_smooth(pc, long, short);
def double_smoothed_abs_pc = double_smooth(AbsValue(pc), long, short);
def tsi_value = (100 * (double_smoothed_pc / double_smoothed_abs_pc))*5;
def tsihmaline=(HullMovingAvg(tsi_value,signal))*5;
def clr = tsihmaline < tsi_value;
def clr2 = tsi_value < tsi_value[1];
def trendv = tsihmaline / 5.6;

plot Trend = trendv;
Trend.SetLineWeight(3);
Trend.SetDefaultColor(Color.WHITE);

plot j3 = if last then na else tsi_value;
plot j4 = if last then na else tsi_value[1];
j3.AssignValueColor(if clr2 then Color.RED else Color.GREEN);
j4.AssignValueColor(if clr2 then Color.RED else Color.GREEN);

AddCloud(j3, j4, Color.DARK_GREEN, Color.DARK_RED);

plot i3 = if last then na else lineupper;
plot i4 = if last then na else linelower;
i3.AssignValueColor(if clr then Color.DARK_RED else Color.DARK_GREEN);
i4.AssignValueColor(if clr then Color.DARK_RED else Color.DARK_GREEN);

AddCloud(if clr then i3 else i4,if clr then i4 else i3, Color.DARK_RED, Color.DARK_GREEN);

def longCondition = tsihmaline>tsihmaline[1] and price>price[1];
def shortCondition = tsihmaline<tsihmaline[1] and price<price[1];

plot buy = if longCondition then 0 else na;
plot sell = if shortCondition then 0 else na;
buy.SetPaintingStrategy(PaintingStrategy.POINTS);
sell.SetPaintingStrategy(PaintingStrategy.POINTS);
buy.SetDefaultColor(Color.GREEN);
sell.SetDefaultColor(Color.RED);


#--- EMD of Code
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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