First Two Bars of the Day

_GreenSmile_

New member
Hello,

I was wondering if it was possible to create a label that shows the range of the first bar of the day and the range of the second bar of the day. It would also show the percentage of the 2nd bar compared to the 1st bar. So for example, if the range of the 1st bar is one dollar and the range of the 2nd bar is fifty cents it would show a percentage of 50.

GreenSmile
 
Solution
Hello,

I was wondering if it was possible to create a label that shows the range of the first bar of the day and the range of the second bar of the day. It would also show the percentage of the 2nd bar compared to the 1st bar. So for example, if the range of the 1st bar is one dollar and the range of the 2nd bar is fifty cents it would show a percentage of 50.

GreenSmile


this finds the first 2 bars on the current day,
displays labels with the height of those 2 bars,
and the ratio of bar1/bar2


Code:
# days_first_2bars_00

#https://usethinkscript.com/threads/first-two-bars-of-the-day.14048/
#First Two Bars of the Day

def bn = barnumber();

input start = 0930;
input end = 1600;
def daytime = if secondsfromTime(start) >=...

halcyonguy

Well-known member
VIP
Lifetime
Hello,

I was wondering if it was possible to create a label that shows the range of the first bar of the day and the range of the second bar of the day. It would also show the percentage of the 2nd bar compared to the 1st bar. So for example, if the range of the 1st bar is one dollar and the range of the 2nd bar is fifty cents it would show a percentage of 50.

GreenSmile


this finds the first 2 bars on the current day,
displays labels with the height of those 2 bars,
and the ratio of bar1/bar2


Code:
# days_first_2bars_00

#https://usethinkscript.com/threads/first-two-bars-of-the-day.14048/
#First Two Bars of the Day

def bn = barnumber();

input start = 0930;
input end = 1600;
def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0;
def period = daytime;

def first =  secondsfromTime(start) == 0 ;
def second = first[1];

def bar1ht = if bn == 1 then 0
 else if first then high - low
 else bar1ht[1];

def bar2ht = if bn == 1 then 0
 else if second then high - low
 else bar2ht[1];

def bar2per = if bn == 1 or first then 0
 else if second then Round(100 * bar2ht / bar1ht, 0)
 else bar2per[1];

AddLabel(1, "bar 1 ht: " + bar1ht, Color.YELLOW);
AddLabel(1, "bar 2 ht: " + bar2ht, Color.YELLOW);
AddLabel(1, "bar 2/bar 1:  " + bar2per + "%", Color.CYAN);
#

GV9dIID.jpg
 
Solution

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.
Top