Horizontal Lines per user input

IFRPilot541

New member
I am trying to create a script that will plot a few horizontal lines on the chart.
The idea would be to open a study and input each number / line weight / color
These would be support and resistance levels (strong / weak for each)
extending them full length is fine, but I would like to be able to use a different color and line weight for each.
not asking for full working code just some idea of how to start
I know plot will do the line but getting the input / line weight - ect I am at a total loss.
 
I am trying to create a script that will plot a few horizontal lines on the chart.
The idea would be to open a study and input each number / line weight / color
These would be support and resistance levels (strong / weak for each)
extending them full length is fine, but I would like to be able to use a different color and line weight for each.
not asking for full working code just some idea of how to start
I know plot will do the line but getting the input / line weight - ect I am at a total loss.


type in a symbol (in caps),
then pick stats for 4 lines
...color , 10 choices
...price
...line thickness

when the chart has the same symbol loaded, the lines will show up.

Code:
# horz_lines_colors

# https://usethinkscript.com/threads/horizontal-lines-per-user-input.16313/
# Horizontal Lines per user input
# test symbols  zig, zim, zt, zy, zw

def bn = BarNumber();
def na = Double.NaN;
#def diffday = if GetDay() != GetDay()[1] then 1 else 0;

#------------------
# symbol1
input Symbol1 = "zw";

#  this doesn't assign the color in quotes.
#  the location of the picked color in the series, is changed to a number
#   ex. pink is the 3rd number.  2 is saved in color1_choice ( count starts at 0)
input sym1_color1 = {default "magenta", "cyan", "pink", "gray", "orange", "red", "green", "dark_gray", "yellow", "white"};
input sym1_line1 = 0.0;
input sym1_line1_width = 1;

input sym1_color2 = {default "magenta", "cyan", "pink", "gray", "orange", "red", "green", "dark_gray", "yellow", "white"};
input sym1_line2 = 0.0;
input sym1_line2_width = 1;

input sym1_color3 = {default "magenta", "cyan", "pink", "gray", "orange", "red", "green", "dark_gray", "yellow", "white"};
input sym1_line3 = 0.0;
input sym1_line3_width = 1;

input sym1_color4 = {default "magenta", "cyan", "pink", "gray", "orange", "red", "green", "dark_gray", "yellow", "white"};
input sym1_line4 = 0.0;
input sym1_line4_width = 1;

#def s1 = close(Symbol1);

plot z1a = if getsymbol() == symbol1 and sym1_line1 > 0 then sym1_line1 else na;
plot z1b = if getsymbol() == symbol1 and sym1_line2 > 0 then sym1_line2 else na;
plot z1c = if getsymbol() == symbol1 and sym1_line3 > 0 then sym1_line3 else na;
plot z1d = if getsymbol() == symbol1 and sym1_line4 > 0 then sym1_line4 else na;

z1a.SetDefaultColor(getcolor(sym1_color1));
z1b.SetDefaultColor(getcolor(sym1_color2));
z1c.SetDefaultColor(getcolor(sym1_color3));
z1d.SetDefaultColor(getcolor(sym1_color4));

z1a.setlineweight(sym1_line1_width);
z1b.setlineweight(sym1_line2_width);
z1c.setlineweight(sym1_line3_width);
z1d.setlineweight(sym1_line4_width);

z1a.hidebubble();
z1b.hidebubble();
z1c.hidebubble();
z1d.hidebubble();
#

SQ 4 lines
lMNLtRA.jpg


vdGqJsN.jpg



colors 0-9
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/GetColor
 

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