Daily lines separators

Enzo

New member
VIP
hi I would like to ask if anyone knows how to put a daily lines separator (Monday-Tuesday-Wednesday- Thursday-Friday-Sunday) for futures Es and Gold
I don't know any think about coding appreciate if some one can point me out if there is one all ready done than you
Enzo
 
Solution
hi I would like to ask if anyone knows how to put a daily lines separator (Monday-Tuesday-Wednesday- Thursday-Friday-Sunday) for futures Es and Gold
I don't know any think about coding appreciate if some one can point me out if there is one all ready done than you
Enzo

This is adaption of something I did for another request that should work for most symbols.

It is a lower study and must be moved to the upper panel to appear as in the image below. The date for Sunday shows the same as Monday as TOS treats both as one trading day.

Screenshot-2022-11-17-133329.png
Code:
declare lower;

def     d = GetDayOfWeek(GetYYYYMMDD());
def year  = GetYear() - (Round(GetYYYYMMDD() / 1000000, 0) * 100);
def Month = GetMonth();
def Day   =...
hi I would like to ask if anyone knows how to put a daily lines separator (Monday-Tuesday-Wednesday- Thursday-Friday-Sunday) for futures Es and Gold
I don't know any think about coding appreciate if some one can point me out if there is one all ready done than you
Enzo

This is adaption of something I did for another request that should work for most symbols.

It is a lower study and must be moved to the upper panel to appear as in the image below. The date for Sunday shows the same as Monday as TOS treats both as one trading day.

Screenshot-2022-11-17-133329.png
Code:
declare lower;

def     d = GetDayOfWeek(GetYYYYMMDD());
def year  = GetYear() - (Round(GetYYYYMMDD() / 1000000, 0) * 100);
def Month = GetMonth();
def Day   = GetDayOfMonth(GetYYYYMMDD());
input openingTime = 0000;
def sec   = SecondsFromTime(openingTime);
def range = if sec == 0 then range[1] + 1 else range[1];
addverticalLine(sec==0,"Midnight",color.cyan, stroke = Curve.FIRM);
input showdayofweek = yes;
def rthstart = if d[1] == 5 and d == 1 then GetYYYYMMDD() != GetYYYYMMDD()[1] else sec==0 ;#GetTime() crosses above RegularTradingStart(GetYYYYMMDD());
def bubble   = if rthstart then BarNumber() else bubble[1];
AddVerticalLine(BarNumber() == bubble, " ", Color.WHITE, stroke = Curve.FIRM);
AddChartBubble(BarNumber() == bubble, 100,
if showdayofweek
then (if d[1] == 5 and d == 1 then "Sunday"
      else if d == 1 then "Monday"
      else if d == 2 then "Tuesday"
      else if d == 3 then "Wednesday"
      else if d == 4 then "Thursday"
      else if d == 5 then "Friday"     
      else if d == 6 then "Saturday"
      else if d == 7 then "Sunday"
      else "")
      + "\n" + (if Month < 10 then "0" else "") + Month + "" + (if Day < 10 then "0" else "") + Day + "" + year
      
else (if Month < 10 then "0" else "") + Month + "" + (if Day < 10 then "0" else "") + Day + "" + year,
if close(period = AggregationPeriod.DAY) > open(period = AggregationPeriod.DAY)
then Color.GREEN
else Color.RED);

plot line105 = 105;
plot line100 = 100;
plot line0 = 0;
line105.SetDefaultColor(Color.BLACK);
line100.SetDefaultColor(Color.BLACK);
line0.SetDefaultColor(Color.BLACK);
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

thank you very much for this exactly what i was looking for is there a way to change the color line separator instead of white to black i use a white background thanks again
ciao Enzo
 
i have one more question to ask if you would know how to create an horizontal line to show YC (Yesterday close ) for futures Gold and ES they close at 5pm thank you
 
i have one more question to ask if you would know how to create an horizontal line to show YC (Yesterday close ) for futures Gold and ES they close at 5pm thank you

This should do that

Ruby:
def yclose  = if secondsfromTime(1600) == 0
              then close
              else yclose[1];
plot pclose = yclose;
pclose.setpaintingStrategy(paintingStrategy.HORIZONTAL);
 
great thank you i try to add this line but is not working and i don't know yet to post picture can you tell me what is wrong wit this line trying to show only last period thanks for your help
Code:
def yclose  = if secondsfromTime(1600) == 0
              then close
              else yclose[1];
input showOnlyLastPeriod = no;
plot pclose = yclose;
pclose.setpaintingStrategy(paintingStrategy.HORIZONTAL);
 
great thank you i try to add this line but is not working and i don't know yet to post picture can you tell me what is wrong wit this line trying to show only last period thanks for your help
Code:
def yclose  = if secondsfromTime(1600) == 0
              then close
              else yclose[1];
input showOnlyLastPeriod = no;
plot pclose = yclose;
pclose.setpaintingStrategy(paintingStrategy.HORIZONTAL);

This should do that through defining the last barnumber (ybar) when yclose was true. Then find the last ybar as highestall(ybar) and hiding pclose when showonlylastperiod and barnumbers()) are less than highestall(ybar).

Screenshot-2022-11-18-135326.png
Ruby:
def yclose  = if secondsfromTime(1600) == 0
              then close
              else yclose[1];
def bn      = barnumber();
def ybar    = if secondsfromTime(1600) == 0
              then bn
              else double.nan;
input showOnlyLastPeriod = no;
plot pclose = if showonlylastPeriod and bn < highestall(ybar)
              then double.nan
              else yclose;
pclose.setpaintingStrategy(paintingStrategy.HORIZONTAL);
 
Any chance this
https://usethinkscript.com/threads/weekly-vertical-line.16045/
can be modified to show the day of the week everyday, and not just the first day of the week?

Would also really like it if I could change the time that the date appears. For instance, have it appear at the NY opening bell instead of at the turn of the new day.

This will modify the display of the above referenced code to appear at the open of NY opening bell each new day

Screenshot 2023-08-09 153835.png
Code:
#daily vertical line @ NY start time
#Move this to upper panel, turn off chart settings/price axis/ uncheck enable left axis

declare lower;

input x_number         = 2;
input display_x_number = {default x, all};
input vertical_date    = no;
input bubbles          = yes;
input bubble_location  = {default bottom, top};

def agg = GetAggregationPeriod() / 60000;
def  bn = BarNumber();

def starttime = if agg == 4 then 928
                else if agg == 20 then 920 
                else if agg == 60 then 900
                else if agg == 240 then 900
                else 930;

#Limit plot of vertical line and/or bubble to NY start time
def xstartbn  = if !IsNaN(close(period = AggregationPeriod.DAY)) then bn else 0;
def start     = if bn != xstartbn then Double.NaN else SecondsFromTime(starttime) == 0;

#Count of start to be used in limiting display_x_number of verticl line and/or bubble
def xnumber   = if start then xnumber[1] + 1 else xnumber[1];

def year = (Round(GetYYYYMMDD() / 10000, 0));
def Month = GetMonth();
def Day = GetDayOfMonth(GetYYYYMMDD());

AddVerticalLine(
if display_x_number == display_x_number.x then
   if HighestAll(xnumber) - x_number < xnumber then start
   else Double.NaN
else start,
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 start then 100 else Double.NaN;
plot x0   = if start then 0 else Double.NaN;


AddChartBubble(bubbles and
if display_x_number == display_x_number.x then
    if HighestAll(xnumber) - x_number < xnumber then start
    else Double.NaN
else start,
(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));

#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
290 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