Line of code that adjusts translucent level?

khpro59

Expert Trader
VIP
Hey fellow code/trade enthusiasts,
Been a VIP for a couple of years and usually just benefit (greatly) from the tremendously awesome and helpful community we have here. @BenTen and @MerryDay are absolute legends you ask me.

Anyway I was wondering if anyone had a good line of code I could insert into an auto-trend line study that will adjust its translucence/hue/saturation (??). Essentially I would like it to be more see-through so it blends with the background a little better, hopefully a code snippet I could apply to a bunch of different studys that create horizontal lines S/R, etc.

If this is asking for a lot, tell me so. I am no coder, but I love to fiddle with stuff and every once and a while I can figure stuff out or get resourceful within this forum, but wasnt finding a lot on this topic. FWIW here is the code I have been using for auto-trend lines. Its suprisingly accurate, but really, I would just like the snippet to apply to a few of them.

Thanks in advance


Code:
###############################
#### Trend Line Plot       ####
################################
input TrendLineLength1 = 50;
input TrendLineLength2 = 30;
input TrendLineLength3 = 10;

def Inertia1 = InertiaAll(close, TrendLineLength1);
def Inertia2 = InertiaAll(close, TrendLineLength2);
def Inertia3 = InertiaAll(close, TrendLineLength3);

def TL_Bull1 = Inertia1 - (HighestAll(AbsValue(Inertia1 - close)) * 0.8);
def TL_Bear1 = Inertia1 + (HighestAll(AbsValue(Inertia1 - close)) * 0.8);
def slope1a = TL_Bull1 > TL_Bull1[1];
def slope1b = TL_Bear1 > TL_Bear1[1];

def TL_Bull2 = Inertia2 - (HighestAll(AbsValue(Inertia2 - close)) * 0.8);
def TL_Bear2 = Inertia2 + (HighestAll(AbsValue(Inertia2 - close)) * 0.8);
def slope2a = TL_Bull2 > TL_Bull2[1];
def slope2b = TL_Bear2 > TL_Bear2[1];

def TL_Bull3 = Inertia3 - (HighestAll(AbsValue(Inertia3 - close)) * 0.8);
def TL_Bear3 = Inertia3 + (HighestAll(AbsValue(Inertia3 - close)) * 0.8);
def slope3a = TL_Bull3 > TL_Bull3[1];
def slope3b = TL_Bear3 > TL_Bear3[1];

#### Long length ####
plot TrendLine1a = if slope1a > 0 then TL_Bull1 else TL_Bear1;
TrendLine1a.SetStyle(curve.long_dash);
TrendLine1a.SetLineWeight(1);
TrendLine1a.assignvaluecolor(if slope1a and IsAscending(close, 10) then color.WHITE else if slope1a then color.white else if !IsAscending(close, 10)then color.white else color.WHITE);

plot TrendLine1b = if slope1b > 0 then TL_Bear1 else TL_Bull1;
TrendLine1b.SetStyle(curve.long_dash);
TrendLine1b.SetLineWeight(1);
TrendLine1b.assignvaluecolor(if slope1b and IsAscending(close, 10) then color.white else if slope1b then color.white else if !IsAscending(close, 10)then color.white else color.white);

#### Medium length ####
plot TrendLine2a = if slope2a > 0 then TL_Bull2 else TL_Bear2;
TrendLine2a.SetStyle(curve.medium_dash);
TrendLine2a.SetLineWeight(2);
TrendLine2a.assignvaluecolor(if slope2a and IsAscending(close, 10) then color.yellow else if slope2a then color.yellow else if !IsAscending(close, 10)then color.light_RED else color.light_RED);

plot TrendLine2b = if slope2b > 0 then TL_Bear2 else TL_Bull2;
TrendLine2b.SetStyle(curve.medium_dash);
TrendLine2b.SetLineWeight(2);
TrendLine2b.assignvaluecolor(if slope2b and IsAscending(close, 10) then color.yellow else if slope2b then color.yellow else if !IsAscending(close, 10)then color.light_RED else color.light_RED);

#### Short length ####
plot TrendLine3a = if slope3a > 0 then TL_Bull3 else TL_Bear3;
TrendLine3a.SetStyle(curve.short_dash);
TrendLine3a.SetLineWeight(3);
TrendLine3a.assignvaluecolor(if slope3a and IsAscending(close, 10) then color.yellow else if slope3a then color.yellow else if !IsAscending(close, 10)then color.light_RED else color.light_RED);

plot TrendLine3b = if slope3b > 0 then TL_Bear3 else TL_Bull3;
TrendLine3b.SetStyle(curve.short_dash);
TrendLine3b.SetLineWeight(3);
TrendLine3b.assignvaluecolor(if slope3b and IsAscending(close, 10) then color.yellow else if slope3b then color.yellow else if !IsAscending(close, 10)then color.light_RED else color.light_RED);
 
Hey fellow code/trade enthusiasts,
Been a VIP for a couple of years and usually just benefit (greatly) from the tremendously awesome and helpful community we have here. @BenTen and @MerryDay are absolute legends you ask me.

Anyway I was wondering if anyone had a good line of code I could insert into an auto-trend line study that will adjust its translucence/hue/saturation (??). Essentially I would like it to be more see-through so it blends with the background a little better, hopefully a code snippet I could apply to a bunch of different studys that create horizontal lines S/R, etc.

If this is asking for a lot, tell me so. I am no coder, but I love to fiddle with stuff and every once and a while I can figure stuff out or get resourceful within this forum, but wasnt finding a lot on this topic. FWIW here is the code I have been using for auto-trend lines. Its suprisingly accurate, but really, I would just like the snippet to apply to a few of them.

Thanks in advance

https://usethinkscript.com/threads/how-to-modify-thinkscript-transparent-opacity-color.2625/
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-68021
https://usethinkscript.com/threads/change-opacity-of-cloud.5721/
https://usethinkscript.com/threads/candlestick-in-front-of-studies.4383/
 

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