label orizontal line

Enzo

New member
hi would like to ask if any one knows how to add a label in orizontal line i have a code the show arizontal line at Midnigth open hoa can have label saying Midnigth ope

thank you

Code:
def yopen = if secondsfromTime(0000) == 0
              then open
              else yopen[1];
def bn      = barnumber();
def ybar    = if secondsfromTime(0000) == 0
              then bn
              else double.nan;
input showOnlyLastPeriod = no;
plot popen = if showonlylastPeriod and bn < highestall(ybar)
              then double.nan
              else yopen;
popen.setpaintingStrategy(paintingStrategy.HORIZONTAL);
 
Last edited by a moderator:
Solution
hi would like to ask if any one knows how to add a label in orizontal line i have a code the show arizontal line at Midnigth open hoa can have label saying Midnigth ope

thank you

Code:
def yopen = if secondsfromTime(0000) == 0
              then open
              else yopen[1];
def bn      = barnumber();
def ybar    = if secondsfromTime(0000) == 0
              then bn
              else double.nan;
input showOnlyLastPeriod = no;
plot popen = if showonlylastPeriod and bn < highestall(ybar)
              then double.nan
              else yopen;
popen.setpaintingStrategy(paintingStrategy.HORIZONTAL);


not all stocks will have trades on the first bar after midnight,
so if you use SecondsFromTime(0) == 0
there won't be...
hi would like to ask if any one knows how to add a label in orizontal line i have a code the show arizontal line at Midnigth open hoa can have label saying Midnigth ope

thank you

Code:
def yopen = if secondsfromTime(0000) == 0
              then open
              else yopen[1];
def bn      = barnumber();
def ybar    = if secondsfromTime(0000) == 0
              then bn
              else double.nan;
input showOnlyLastPeriod = no;
plot popen = if showonlylastPeriod and bn < highestall(ybar)
              then double.nan
              else yopen;
popen.setpaintingStrategy(paintingStrategy.HORIZONTAL);


not all stocks will have trades on the first bar after midnight,
so if you use SecondsFromTime(0) == 0
there won't be any data


this will find the nearest bar, when the exact time doesn't exist.
but doesnt work for start=0.
#def x = SecondsFromTime(start)[1] < 0 and SecondsFromTime(start) >= 0;


added a bubble to display
SecondsFromTime(start)
to verify what is happening.
in CST, '0' time happens at 11pm.
have to adjust data for time zones


added this to detect a new day
def d = getday();
def newday = d != d[1];


this draws a line from the open of the first bar of the day

Code:
#line_label_midnight

#https://usethinkscript.com/threads/label-orizontal-line.20701/
#label orizontal line
#Enzo  3/25

#1
#hi would like to ask if any one knows how to add a label in orizontal line i have a code the show arizontal line at Midnigth open hoa can have label saying Midnigth ope

def bn = barnumber();

def start = 0;
def t = SecondsFromTime(start);

# nearest bar , doesnt work for start=0
#def x = SecondsFromTime(start)[1] < 0 and SecondsFromTime(start) >= 0;

#def x = t[1] > t;
# for CST  if start = 0 , x  is true at 11pm

# this work for midnight or bar closest to it
def d = getday();
def newday = d != d[1];
def x = newday;

#addverticalline(x,"-");

input test = no;
addchartbubble(test, low,
SecondsFromTime(start)
, color.yellow, no);


#def yopen = if secondsfromTime(0000) == 0 then open else yopen[1];
def yopen = if x then open else yopen[1];

#def ybar = if secondsfromTime(0000) == 0 then bn else double.nan;
def ybar = if x then bn else double.nan;


input showOnlyLastPeriod = no;
plot popen = if showonlylastPeriod and bn < highestall(ybar) then double.nan else yopen;
popen.setpaintingStrategy(paintingStrategy.HORIZONTAL);
#
 
Solution

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