AddVerticalLine on Specific Date


Category:
0
0

I’m hoping to add a vertical line on a specific date. To get started, let’s say that date is 03/09/2021. And then, over time, I’ll add more specific dates to the script… possibly as many as 100+.

Many, many thanks.

Dana

RESOLVED
Marked as spam
Posted by (Questions: 2, Answers: 0)
Asked on May 14, 2021 8:56 pm
806 views
1
Private answer

Everything you need to know about plotting vertical lines on a chart is located here:

https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddVerticalLine

The following section of code will plot a vertical line on a daily chart. The vertical line will appear on the candle that is stamped with the date of 5/10/21. There is a user input that allows the date to be adjusted through the Edit Studies window. Any date you input must be a date the markets were open for regular trade.

input targetDate = 20210510;
def targetBar = DaysTillDate(targetDate) == 0;
AddVerticalLine(targetBar, "Target Bar", Color.GRAY);

If you wanted to plot 100 vertical lines on the chart the chart study would need to contain these three lines of code for each and every line you want to display on the chart. This would require 300 lines of code to accomplish the goal you stated in your question. There is no other way to do this on Thinkorswim.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 15, 2021 9:54 am