SSL Indicator For ThinkorSwim

blackbeard12

New member
Hey guys, found this cool indicator on tradingview called the SSL indicator, very useful for trend trading. Is anyone well enough versed or have any ideas on how to convert this code to thinkscript? Thank you.
 
Last edited by a moderator:
I actually made one . its kinda good visualisation tool for fast moving averages.
https://tos.mx/4Xvv2j
Ruby:
#also gannhilow
#https://www.tradingview.com/script/xzIoaIJC-SSL-channel/
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v =  if isnan(close[1]) then 0 
        else if close > avghigh then 1
        else if close<avgLow then -1   
        else H1v[1];


plot sslDown= if h1v<0 then avghigh else avglow;
ssldown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avghigh;
sslUP.setDefaultColor(color.green);
addcloud(sslup,ssldown,color.dark_green,color.red);
 
Last edited by a moderator:
Hello, I've been around from time to time and this community has helped me with prior requests, so thank you very much. I think I got this SSL indicator I use from here a long time ago, and I'm getting ready to start day trading using it. Here it is:

--------------------------

#also gannhilow
#https://www.tradingview.com/script/xzIoaIJC-SSL-channel/
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v = if isnan(close[1]) then 0
else if close > avghigh then 1
else if close<avgLow then -1
else H1v[1];


plot sslDown= if h1v<0 then avghigh else avglow;
ssldown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avghigh;
sslUP.setDefaultColor(color.green);
addcloud(sslup,ssldown,color.dark_green,color.red);

-------------------------------
I want to add an audible alert every time the SSL changes to either green or red.
 
Hello, I've been around from time to time and this community has helped me with prior requests, so thank you very much. I think I got this SSL indicator I use from here a long time ago, and I'm getting ready to start day trading using it. Here it is:

--------------------------

#also gannhilow
#https://www.tradingview.com/script/xzIoaIJC-SSL-channel/
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v = if isnan(close[1]) then 0
else if close > avghigh then 1
else if close<avgLow then -1
else H1v[1];


plot sslDown= if h1v<0 then avghigh else avglow;
ssldown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avghigh;
sslUP.setDefaultColor(color.green);
addcloud(sslup,ssldown,color.dark_green,color.red);

-------------------------------
I want to add an audible alert every time the SSL changes to either green or red.


add this to the bottom of your script:
Ruby:
Alert(sslUp crosses above sslDown, "Trending Up", Alert.Bar, Sound.Bell);
Alert(sslUp crosses below sslDown, "Trending Down", Alert.Bar, Sound.Bell);
https://usethinkscript.com/resources/how-to-add-alert-script-to-thinkorswim-indicators.9/
 
Hello, I like this indicator, can anyone script an up arrow on the upper chart when the clouds turn green and a down arrow when the clouds turn red.

Thank You !
 
Hello, I like this indicator, can anyone script an up arrow on the upper chart when the clouds turn green and a down arrow when the clouds turn red.

Thank You !
I modded with arrows , alert and color bar. Give it a try, use at your own risk.

#also gannhilow
#https://www.tradingview.com/script/xzIoaIJC-SSL-channel/
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v = if isnan(close[1]) then 0
else if close > avghigh then 1
else if close<avgLow then -1
else H1v[1];


plot sslDown= if h1v<0 then avghigh else avglow;
ssldown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avghigh;
sslUP.setDefaultColor(color.green);
addcloud(sslup,ssldown,color.dark_green,color.red);

plot UpSigna = if sslUp crosses above sslDown then sslDown else Double.NaN;
UpSigna.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSigna.SetLineWeight(1);
UpSigna.SetDefaultColor(Color.GREEN);


plot DownSigna = if sslUp crosses below sslDown then sslDown else Double.NaN;
DownSigna.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSigna.SetLineWeight(1);
DownSigna.SetDefaultColor(Color.RED);

Alert(sslUp crosses above sslDown, "Trending Up", Alert.Bar, Sound.Bell);
Alert(sslUp crosses below sslDown, "Trending Down", Alert.Bar, Sound.Ring);

input colorbars = no;
assignpricecolor(if colorbars and sslUP > ssldown then color.Green else if colorbars and ssldown > sslUP then color.Red else color.current);

# End
 
I modded with arrows , alert and color bar. Give it a try, use at your own risk.

#also gannhilow
#https://www.tradingview.com/script/xzIoaIJC-SSL-channel/
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v = if isnan(close[1]) then 0
else if close > avghigh then 1
else if close<avgLow then -1
else H1v[1];


plot sslDown= if h1v<0 then avghigh else avglow;
ssldown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avghigh;
sslUP.setDefaultColor(color.green);
addcloud(sslup,ssldown,color.dark_green,color.red);

plot UpSigna = if sslUp crosses above sslDown then sslDown else Double.NaN;
UpSigna.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSigna.SetLineWeight(1);
UpSigna.SetDefaultColor(Color.GREEN);


plot DownSigna = if sslUp crosses below sslDown then sslDown else Double.NaN;
DownSigna.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSigna.SetLineWeight(1);
DownSigna.SetDefaultColor(Color.RED);

Alert(sslUp crosses above sslDown, "Trending Up", Alert.Bar, Sound.Bell);
Alert(sslUp crosses below sslDown, "Trending Down", Alert.Bar, Sound.Ring);

input colorbars = no;
assignpricecolor(if colorbars and sslUP > ssldown then color.Green else if colorbars and ssldown > sslUP then color.Red else color.current);

# End
Thank you for taking time out of your day to complete my request. I appreciate it.
 
I'm likely not searching correctly, but I am unable to track down how to change a watchlist column background color. If someone could point me to a post that addresses this or answer my question directly... that would be super helpful.

I have an indicator that has a "signal" that provides a true-false outcome. I want to add a column that is either green when true or left black when false. I have figured out how to make a custom quote to add the indicator as a column and I have done that correctly. The column now displays either nothing or a "1.0" when true, which is helpful and getting the job done... but I'd like it to be more easily recognizable by just showing the color green if true or black if not.

If there's anyone that can provide some quick help, I would appreciate it. Thanks!
 
For no text to appear:
Addlabel(yes, if _____ is true then “ “ else if _____ is false “ “ else “ “);

AssignBackgroundColor(if _____ is true then color.green else if _____ is false color.red else color.gray);
 
For no text to appear:
Addlabel(yes, if _____ is true then “ “ else if _____ is false “ “ else “ “);

AssignBackgroundColor(if _____ is true then color.green else if _____ is false color.red else color.gray);
Thanks a bunch... I'm a TOS noob, so would this be the entirety of the Custom Quote... substituting the Study name where the underscores are... and nothing else needed?
 
Thanks a bunch... I'm a TOS noob, so would this be the entirety of the Custom Quote... substituting the Study name where the underscores are... and nothing else needed?
No problem… no you would copy and paste the code for the study into a custom quote using the Thinkscript editor the. Copy and past the code above and where the underscore is put the plot name for which you would like the cell to turn green then the plot name you want the cell to turn red. The plot names are in the code for the study. I can help if you link to the study or copy past the code here.
 
No problem… no you would copy and paste the code for the study into a custom quote using the Thinkscript editor the. Copy and past the code above and where the underscore is put the plot name for which you would like the cell to turn green then the plot name you want the cell to turn red. The plot names are in the code for the study. I can help if you link to the study or copy past the code here.
Ok... do appreciate the help.

It's the SSL study converted from a tradingview indicator... I would like to color the column green on an upsignal, red on a downsignal and black otherwise. Here's the code:

Code:
#also gannhilow
#[URL]https://www.tradingview.com/script/xzIoaIJC-SSL-channel/[/URL]
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v = if isnan(close[1]) then 0
else if close > avghigh then 1
else if close<avgLow then -1
else H1v[1];


plot sslDown= if h1v<0 then avghigh else avglow;
ssldown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avghigh;
sslUP.setDefaultColor(color.green);
#addcloud(sslup,ssldown,color.dark_green,color.red);

plot UpSigna = if sslUp crosses above sslDown then sslDown else Double.NaN;
UpSigna.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSigna.SetLineWeight(1);
UpSigna.SetDefaultColor(Color.GREEN);


plot DownSigna = if sslUp crosses below sslDown then sslDown else Double.NaN;
DownSigna.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSigna.SetLineWeight(1);
DownSigna.SetDefaultColor(Color.RED);

Alert(sslUp crosses above sslDown, "Trending Up", Alert.Bar, Sound.Bell);
Alert(sslUp crosses below sslDown, "Trending Down", Alert.Bar, Sound.Ring);

input colorbars = no;
assignpricecolor(if colorbars and sslUP > ssldown then color.Green else if colorbars and ssldown > sslUP then color.Red else color.current);

# End
 
Ok... do appreciate the help.

It's the SSL study converted from a tradingview indicator... I would like to color the column green on an upsignal, red on a downsignal and black otherwise. Here's the code:

Code:
#also gannhilow
#[URL]https://www.tradingview.com/script/xzIoaIJC-SSL-channel/[/URL]
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v = if isnan(close[1]) then 0
else if close > avghigh then 1
else if close<avgLow then -1
else H1v[1];


plot sslDown= if h1v<0 then avghigh else avglow;
ssldown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avghigh;
sslUP.setDefaultColor(color.green);
#addcloud(sslup,ssldown,color.dark_green,color.red);

plot UpSigna = if sslUp crosses above sslDown then sslDown else Double.NaN;
UpSigna.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSigna.SetLineWeight(1);
UpSigna.SetDefaultColor(Color.GREEN);


plot DownSigna = if sslUp crosses below sslDown then sslDown else Double.NaN;
DownSigna.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSigna.SetLineWeight(1);
DownSigna.SetDefaultColor(Color.RED);

Alert(sslUp crosses above sslDown, "Trending Up", Alert.Bar, Sound.Bell);
Alert(sslUp crosses below sslDown, "Trending Down", Alert.Bar, Sound.Ring);

input colorbars = no;
assignpricecolor(if colorbars and sslUP > ssldown then color.Green else if colorbars and ssldown > sslUP then color.Red else color.current);

# End
Addlabel(yes, if Upsigna is true then “ “ else if downsigna is true “ “ else “ “);

AssignBackgroundColor(if upsigna is true then color.green else if downsigna is true color.red else color.gray);

Copy and paste that at the bottom of your code and you should be good to go.
 
Hmmm... here's what I have and it is indicating "Invalid Statement: Addlabel at 38:1" and "Invalid Statement: AssignBackgroundColor at 40:1"

Any clues??

#also gannhilow
#https://www.tradingview.com/script/xzIoaIJC-SSL-channel/
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v = if isnan(close[1]) then 0
else if close > avghigh then 1
else if close<avgLow then -1
else H1v[1];


plot sslDown= if h1v<0 then avghigh else avglow;
ssldown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avghigh;
sslUP.setDefaultColor(color.green);
#addcloud(sslup,ssldown,color.dark_green,color.red);

plot UpSigna = if sslUp crosses above sslDown then sslDown else Double.NaN;
UpSigna.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSigna.SetLineWeight(1);
UpSigna.SetDefaultColor(Color.GREEN);


plot DownSigna = if sslUp crosses below sslDown then sslDown else Double.NaN;
DownSigna.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSigna.SetLineWeight(1);
DownSigna.SetDefaultColor(Color.RED);

Alert(sslUp crosses above sslDown, "Trending Up", Alert.Bar, Sound.Bell);
Alert(sslUp crosses below sslDown, "Trending Down", Alert.Bar, Sound.Ring);

input colorbars = no;
assignpricecolor(if colorbars and sslUP > ssldown then color.Green else if colorbars and ssldown > sslUP then color.Red else color.current);

Addlabel(yes, if Upsigna is true then “ “ else if downsigna is true “ “ else “ “);

AssignBackgroundColor(if upsigna is true then color.green else if downsigna is true color.red else color.gray);

# End
 
Just for fun I input this code into ChatGPT to see if it could correct the errors. It took 2 tries (got a few more error messages which I asked it to fix). Here's the code it came up with. I don't know if this is correct, you'll have to try it, but it did come back with no errors. Good luck.


Code:
#also gannhilow
#https://www.tradingview.com/script/xzIoaIJC-SSL-channel/
declare upper;
input period=8;
input avgType=averageType.simple;
def avgHigh=movingAverage(avgType,high, period);
def avgLow=movingAverage(avgType,low, period);;

def H1v = if isnan(close[1]) then 0
else if close > avghigh then 1
else if close<avgLow then -1
else H1v[1];

plot sslDown= if h1v<0 then avgHigh else avgLow;
sslDown.setDefaultColor(color.red);
plot sslUp= if h1v<0 then avgLow else avgHigh;
sslUP.setDefaultColor(color.green);
#addcloud(sslup,ssldown,color.dark_green,color.red);

plot UpSigna = if sslUp crosses above sslDown then sslDown else Double.NaN;
UpSigna.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSigna.SetLineWeight(1);
UpSigna.SetDefaultColor(Color.GREEN);

plot DownSigna = if sslUp crosses below sslDown then sslDown else Double.NaN;
DownSigna.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSigna.SetLineWeight(1);
DownSigna.SetDefaultColor(Color.RED);

Alert(sslUp crosses above sslDown, "Trending Up", Alert.Bar, Sound.Bell);
Alert(sslUp crosses below sslDown, "Trending Down", Alert.Bar, Sound.Ring);

input colorbars = no;
assignpricecolor(if colorbars and sslUP > sslDown then color.Green else if colorbars and sslDown > sslUP then color.Red else color.current);

AddLabel(yes, if UpSigna is true then " " else if DownSigna is true then " " else " ");

AssignBackgroundColor(if UpSigna is true then color.green else if DownSigna is true then color.red else color.gray);

# End
 
Addlabel(yes, if Upsigna is true then “ “ else if downsigna is true “ “ else “ “);

AssignBackgroundColor(if upsigna is true then color.green else if downsigna is true color.red else color.gray);

Copy and paste that at the bottom of your code and you should be good to go.
I think I got it sorted with the Invalid Statements thing... figured out there was a "then" missing in there. All good now, except now its saying "Exactly one plot expected" and won't allow me to save it. Any ideas??
 

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
494 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