line at a certain date?

Stockleed

New member
I have searched the web everywhere, and I'm just not smart enough to figure it out. But is there a way to write a script that will show a line at a certain date?

I just need help with the beginning code of the script to display a line on the chart with a label for a specific date.

For example here is the drawing I created in thinkorswim
Screenshot-2022-09-22-084341.png


I just would like to turn that into a script, I have sent countless hours on this and can't figure it out

Any help would be greatly appreciated
 
Last edited by a moderator:
Solution
I have searched the web everywhere, and I'm just not smart enough to figure it out. But is there a way to write a script that will show a line at a certain date?

I just need help with the beginning code of the script to display a line on the chart with a label for a specific date.
For example here is the drawing I created in thinkorswim
I just would like to turn that into a script, I have sent countless hours on this and can't figure it out

here is an example that draws,
. a cloud during the date,
. a couple variations of the vertical lines


Code:
def na = double.nan;

input show_cloud = yes;
input show_2_same_lines = no;
input show_2_different_lines = yes;


input date12 = 20221118;
def u12 = (GetYYYYMMDD() == date12);


#...
I have searched the web everywhere, and I'm just not smart enough to figure it out. But is there a way to write a script that will show a line at a certain date?

I just need help with the beginning code of the script to display a line on the chart with a label for a specific date.
For example here is the drawing I created in thinkorswim
I just would like to turn that into a script, I have sent countless hours on this and can't figure it out

here is an example that draws,
. a cloud during the date,
. a couple variations of the vertical lines


Code:
def na = double.nan;

input show_cloud = yes;
input show_2_same_lines = no;
input show_2_different_lines = yes;


input date12 = 20221118;
def u12 = (GetYYYYMMDD() == date12);


# draw shading during the daye, on intraday charts
def cldtop = if (show_cloud and u12) then double.positive_infinity else na;
addcloud( cldtop, double.negative_infinity, color.gray, color.gray);


# draw 2 same vertical lines , at start and stop of date bars
def v12 = (show_2_same_lines and ((!u12[1] and u12) or (u12 and !u12[-1])));
addverticalline(v12, "date 12", color.orange, curve.MEDIUM_DASH);


# draw 2 different vertical lines , at start and stop of date bars
addverticalline((show_2_different_lines and (!u12[1] and u12)), "date 12", color.orange, curve.MEDIUM_DASH);
addverticalline((show_2_different_lines and (u12 and !u12[-1])), "----- 12", color.magenta, curve.points);
#

30 min chart
f8P1rHK.jpg
 
Solution
here is an example that draws,
. a cloud during the date,
. a couple variations of the vertical lines


Code:
def na = double.nan;

input show_cloud = yes;
input show_2_same_lines = no;
input show_2_different_lines = yes;


input date12 = 20221118;
def u12 = (GetYYYYMMDD() == date12);


# draw shading during the daye, on intraday charts
def cldtop = if (show_cloud and u12) then double.positive_infinity else na;
addcloud( cldtop, double.negative_infinity, color.gray, color.gray);


# draw 2 same vertical lines , at start and stop of date bars
def v12 = (show_2_same_lines and ((!u12[1] and u12) or (u12 and !u12[-1])));
addverticalline(v12, "date 12", color.orange, curve.MEDIUM_DASH);


# draw 2 different vertical lines , at start and stop of date bars
addverticalline((show_2_different_lines and (!u12[1] and u12)), "date 12", color.orange, curve.MEDIUM_DASH);
addverticalline((show_2_different_lines and (u12 and !u12[-1])), "----- 12", color.magenta, curve.points);
#

30 min chart
View attachment 16433
Thank you for your response I was just wondering is there a way to make this a solid line instead of dotted?
 
halcyonguy thank you so much. Quick question how would you add to the code you provided SetLineWeight(3); ? I've tried everything and I cannot get it to work without getting an error. I am just trying to make the line width thicker

Any help would be greatly appreciated

def na = double.nan;

input show_cloud = yes;
input show_2_same_lines = no;
input show_2_different_lines = yes;


input date12 = 20221118;
def u12 = (GetYYYYMMDD() == date12);


# draw shading during the daye, on intraday charts
def cldtop = if (show_cloud and u12) then double.positive_infinity else na;
addcloud( cldtop, double.negative_infinity, color.gray, color.gray);


# draw 2 same vertical lines , at start and stop of date bars
def v12 = (show_2_same_lines and ((!u12[1] and u12) or (u12 and !u12[-1])));
addverticalline(v12, "date 12", color.orange, Curve.FIRM);


# draw 2 different vertical lines , at start and stop of date bars
addverticalline((show_2_different_lines and (!u12[1] and u12)), "date 12", color.orange, Curve.FIRM);
addverticalline((show_2_different_lines and (u12 and !u12[-1])), "----- 12", color.magenta, curve.points);
#
 
Thank you for your response I was just wondering is there a way to make this a solid line instead of dotted?

yes, you look up the function and see what parameters are acceptable.
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddVerticalLine
The third parameter defines what type of line is drawn.
i tend to leave Off the third parameter as usually I don't care if it's dashed or not.
it accepts curve
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/Curve
so would be
curve.firm for a solid line

there are no paremeters for thickness
 
clean up Looking for some expertise on how to modify this code so that it gives me the option to change the Line Color and Size from the Inputs and Options Menu. Below is my current coding it's function is to add a vertical line at a certain date on the chart.

Code:
def na = double.nan;

input show_cloud = yes;
input show_2_same_lines = no;
input show_2_different_lines = yes;


input date12 = 20221118;
def u12 = (GetYYYYMMDD() == date12);


# draw shading during the daye, on intraday charts
def cldtop = if (show_cloud and u12) then double.positive_infinity else na;
addcloud( cldtop, double.negative_infinity, color.gray, color.gray);


# draw 2 same vertical lines , at start and stop of date bars
def v12 = (show_2_same_lines and ((!u12[1] and u12) or (u12 and !u12[-1])));
addverticalline(v12, "date 12", color.orange, Curve.FIRM);


# draw 2 different vertical lines , at start and stop of date bars
addverticalline((show_2_different_lines and (!u12[1] and u12)), "date 12", color.orange, Curve.FIRM);
addverticalline((show_2_different_lines and (u12 and !u12[-1])), "----- 12", color.magenta, curve.points);
#

View attachment 19381
Any help would be greatly appreciated

yes, you look up the function and see what parameters are acceptable.
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddVerticalLine
The third parameter defines what type of line is drawn.
i tend to leave Off the third parameter as usually I don't care if it's dashed or not.
it accepts curve
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/Curve
so would be
curve.firm for a solid line

there are no paremeters for thickness

halcyonguy thank you for your reply. I'm not sure I completely understand what you're saying? My question was, is there a way to make the line thicker using .SetLineWeight(3)

If so, how would you implement it into the existing code?


Thanks again
 
Last edited by a moderator:
halcyonguy thank you for your reply. I'm not sure I completely understand what you're saying? My question was, is there a way to make the line thicker using .SetLineWeight(3)

If so, how would you implement it into the existing code?


Thanks again

No, you can't.
The ToS platform does not provide the ability to "make vertical lines thicker".
The SetLineWeigh() function ONLY applies to horizontal lines.
 

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