weekly vertical line

Amarante

Member
VIP
Last edited by a moderator:
Solution
Could this code:
https://usethinkscript.com/threads/vertical-dashed-line-shown-where-date-change.15421/
be adjusted so that it will make a weekly vertical dashed line that has the date near the bottom of the line written vertically along the line?

or could this code:
https://usethinkscript.com/threads/line-at-a-certain-date.12759/
so that I get this same line for each week with the weekly Monday date on it? I'd also like to adjust the color to a grey so that it's not too intrusive.

This will automatically plot a vertical line at the first day of each week with an optional bubble to display the day/date on the vertical line.

Code:
#weekly vertical line
#Move this to upper panel

declare upper;

input...
Could this code:
https://usethinkscript.com/threads/vertical-dashed-line-shown-where-date-change.15421/
be adjusted so that it will make a weekly vertical dashed line that has the date near the bottom of the line written vertically along the line?

or could this code:
https://usethinkscript.com/threads/line-at-a-certain-date.12759/
so that I get this same line for each week with the weekly Monday date on it? I'd also like to adjust the color to a grey so that it's not too intrusive.

This will automatically plot a vertical line at the first day of each week with an optional bubble to display the day/date on the vertical line.

Code:
#weekly vertical line
#Move this to upper panel

declare upper;

input vertical_date = yes;
def wk = GetWeek() != GetWeek()[1];
AddVerticalLine(wk,
if vertical_date then
(if GetDayOfWeek(GetYYYYMMDD()) == 1 then "Monday"
else if GetDayOfWeek(GetYYYYMMDD()) == 2 then "Tuesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 3 then "Wednesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 4 then "Thursday"
else if GetDayOfWeek(GetYYYYMMDD()) == 5 then "Friday"
else if GetDayOfWeek(GetYYYYMMDD()) == 7 then "Sunday"
else "")  + "\n   " + AsPrice(GetYYYYMMDD())
else "", Color.GRAY);

You can also choose to display the day/date on the vertical line or on a bubble at the line. Make your choices at the input screen. If you want this option, then use the following code.

This code is set to declare lower. To get the bubble to display properly, just move the script to the upper panel. A question mark will appear in the upper left corner notifying you of this move. Just ignore it.

Screenshot 2023-07-11 150452.png
Code:
#weekly vertical line
#Move this to upper panel

declare lower;

input vertial_date = no;
def wk = GetWeek() != GetWeek()[1];
AddVerticalLine(wk,
if vertial_date then
(if GetDayOfWeek(GetYYYYMMDD()) == 1 then "Monday"
else if GetDayOfWeek(GetYYYYMMDD()) == 2 then "Tuesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 3 then "Wednesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 4 then "Thursday"
else if GetDayOfWeek(GetYYYYMMDD()) == 5 then "Friday"
else if GetDayOfWeek(GetYYYYMMDD()) == 7 then "Sunday"
else "")  + "\n   " + AsPrice(GetYYYYMMDD())
else "", Color.GRAY);

#Location for for bubbles
plot x100 = if wk then 100 else Double.NaN;
plot x0   = if wk then 0 else Double.NaN;

input bubble = yes;
input bubble_location = {default bottom, top};
AddChartBubble(bubble and wk,
(if bubble_location == bubble_location.top then x100 else x0),
(if GetDayOfWeek(GetYYYYMMDD()) == 1 then "Monday"
else if GetDayOfWeek(GetYYYYMMDD()) == 2 then "Tuesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 3 then "Wednesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 4 then "Thursday"
else if GetDayOfWeek(GetYYYYMMDD()) == 5 then "Friday"
else if GetDayOfWeek(GetYYYYMMDD()) == 7 then "Sunday"
else "")  + "\n" + AsPrice(GetYYYYMMDD()),
Color.GRAY,
(if bubble_location == bubble_location.top then no else yes));

#
 
Last edited:
Solution
This will automatically plot a vertical line at the first day of each week with an optional bubble to display the day/date on the vertical line.



You can also choose to display the day/date on the vertical line or on a bubble at the line. Make your choices at the input screen. If you want this option, then use the following code.

This code is set to declare lower. To get the bubble to display properly, just move the script to the upper panel. A question mark will appear in the upper left corner notifying you of this move. Just ignore it.
I've tried it for a few weeks and would like to change the date set up to ddmmyyyy instead of having the year first and having to look for the small number of the month after the year. Thanks for all you do.
 
I've tried it for a few weeks and would like to change the date set up to ddmmyyyy instead of having the year first and having to look for the small number of the month after the year. Thanks for all you do.

This will display the date as dd/mm/yyyy

Please also make sure that the circled area is not checked in chart settings


Code:
#weekly vertical line
#Move this to upper panel

declare lower;

input vertical_date = no;
def wk   = GetWeek() != GetWeek()[1];
def year = (Round(GetYYYYMMDD() / 10000, 0));
def Month = GetMonth();
def Day = GetDayOfMonth(GetYYYYMMDD());
AddVerticalLine(wk,
if vertical_date then
(if GetDayOfWeek(GetYYYYMMDD()) == 1 then "Monday"
else if GetDayOfWeek(GetYYYYMMDD()) == 2 then "Tuesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 3 then "Wednesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 4 then "Thursday"
else if GetDayOfWeek(GetYYYYMMDD()) == 5 then "Friday"
else if GetDayOfWeek(GetYYYYMMDD()) == 7 then "Sunday"
else "") + "   " + Month + "/" + Day + "/" + AsPrice(year)
else ""
, Color.GRAY);

#Location for for bubbles
plot x100 = if wk then 100 else Double.NaN;
plot x0   = if wk then 0 else Double.NaN;

input bubble = yes;
input bubble_location = {default bottom, top};
AddChartBubble(bubble and wk,
(if bubble_location == bubble_location.top then x100 else x0),
(if GetDayOfWeek(GetYYYYMMDD()) == 1 then "Monday"
else if GetDayOfWeek(GetYYYYMMDD()) == 2 then "Tuesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 3 then "Wednesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 4 then "Thursday"
else if GetDayOfWeek(GetYYYYMMDD()) == 5 then "Friday"
else if GetDayOfWeek(GetYYYYMMDD()) == 7 then "Sunday"
else "")  + "\n" + Month + "/" + Day + "/" + AsPrice(year) ,
Color.GRAY,
(if bubble_location == bubble_location.top then no else yes));

#
 
This will display the date as dd/mm/yyyy

Please also make sure that the circled area is not checked in chart settings




Code:
#weekly vertical line
#Move this to upper panel

declare lower;

input vertical_date = no;
def wk   = GetWeek() != GetWeek()[1];
def year = (Round(GetYYYYMMDD() / 10000, 0));
def Month = GetMonth();
def Day = GetDayOfMonth(GetYYYYMMDD());
AddVerticalLine(wk,
if vertical_date then
(if GetDayOfWeek(GetYYYYMMDD()) == 1 then "Monday"
else if GetDayOfWeek(GetYYYYMMDD()) == 2 then "Tuesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 3 then "Wednesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 4 then "Thursday"
else if GetDayOfWeek(GetYYYYMMDD()) == 5 then "Friday"
else if GetDayOfWeek(GetYYYYMMDD()) == 7 then "Sunday"
else "") + "   " + Month + "/" + Day + "/" + AsPrice(year)
else ""
, Color.GRAY);

#Location for for bubbles
plot x100 = if wk then 100 else Double.NaN;
plot x0   = if wk then 0 else Double.NaN;

input bubble = yes;
input bubble_location = {default bottom, top};
AddChartBubble(bubble and wk,
(if bubble_location == bubble_location.top then x100 else x0),
(if GetDayOfWeek(GetYYYYMMDD()) == 1 then "Monday"
else if GetDayOfWeek(GetYYYYMMDD()) == 2 then "Tuesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 3 then "Wednesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 4 then "Thursday"
else if GetDayOfWeek(GetYYYYMMDD()) == 5 then "Friday"
else if GetDayOfWeek(GetYYYYMMDD()) == 7 then "Sunday"
else "")  + "\n" + Month + "/" + Day + "/" + AsPrice(year) ,
Color.GRAY,
(if bubble_location == bubble_location.top then no else yes));

#
In an effort to clean up the chart, Is it possible to put a counter in the code so that only the first line of every four appear so that I only see the first line of each month? Thank you for your continued help.
 
In an effort to clean up the chart, Is it possible to put a counter in the code so that only the first line of every four appear so that I only see the first line of each month? Thank you for your continued help.

See if this is what you want.

It now has an option to limit the display to: input number_to_display = 2;

Also, to then display the first day of the month or first day of the beginning of the week: input basis = {default month, week};

Screenshot 2023-08-08 144427.png
Code:
#weekly vertical line
#Move this to upper panel

declare lower;
input basis = {default month, week};
input vertical_date = no;
input number_to_display = 2;

def wk   = if basis == basis.month
           then GetMonth() != GetMonth()[1]
           else GetWeek() != GetWeek()[1];
def wkcount = if wk then wkcount[1]+1 else wkcount[1];
def year = (Round(GetYYYYMMDD() / 10000, 0));
def Month = GetMonth();
def Day = GetDayOfMonth(GetYYYYMMDD());
AddVerticalLine(if highestall(wkcount) - wkcount < number_to_display then wk else double.nan,
if vertical_date then
(if GetDayOfWeek(GetYYYYMMDD()) == 1 then "Monday"
else if GetDayOfWeek(GetYYYYMMDD()) == 2 then "Tuesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 3 then "Wednesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 4 then "Thursday"
else if GetDayOfWeek(GetYYYYMMDD()) == 5 then "Friday"
else if GetDayOfWeek(GetYYYYMMDD()) == 7 then "Sunday"
else "") + "   " + Month + "/" + Day + "/" + AsPrice(year)
else ""
, Color.GRAY);

#Location for for bubbles
plot x100 = if wk then 100 else Double.NaN;
plot x0   = if wk then 0 else Double.NaN;

input bubble = yes;
input bubble_location = {default bottom, top};
AddChartBubble(bubble and if highestall(wkcount) - wkcount < number_to_display then wk else double.nan,
(if bubble_location == bubble_location.top then x100 else x0),
(if GetDayOfWeek(GetYYYYMMDD()) == 1 then "Monday"
else if GetDayOfWeek(GetYYYYMMDD()) == 2 then "Tuesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 3 then "Wednesday"
else if GetDayOfWeek(GetYYYYMMDD()) == 4 then "Thursday"
else if GetDayOfWeek(GetYYYYMMDD()) == 5 then "Friday"
else if GetDayOfWeek(GetYYYYMMDD()) == 7 then "Sunday"
else "")  + "\n" + Month + "/" + Day + "/" + AsPrice(year) ,
Color.GRAY,
(if bubble_location == bubble_location.top then no else yes));

#
 

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