create high low label

om4

New member
Is it possible to have a label showing the high and low price along with the difference of the first bar within the timeframe that it is? i would want to add this on my chart on the upper left corner. i have the below script as an example, but this looks for the previous bar. I want something similar but to display first bar of the day regardless what time of the day.

# dummy label
AddLabel(1," ",color.black);
AddLabel(1," ",color.black);
AddLabel(1," ",color.black);

AddLabel(1,"High: " + High[1],color.white);
AddLabel(1,"Low: " + Low[1], color.white);
AddLabel(1,"High - Low: " + (High[1] - Low[1]),color.green);
 
@om4
1W7fUwx.png

Code:
input Start_Bar_Time = 0000;

def Var2 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then high[1] else Var2[1];
def Var3 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then low[1] else Var3[1];
def Var4 = AbsValue(Var2 - high);
def Var5 = AbsValue(Var3 - low);

AddLabel(yes,"Absolute Value of Difference Between Start Bar High ("+Var2+") and Current High ("+high+"): "+Var4,color.WHITE);
AddLabel(yes,"Absolute Value of Difference Between Start Bar Low ("+Var3+") and Current Low ("+low+"): "+Var5,color.WHITE);
 
Last edited:

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

@om4
1W7fUwx.png

Code:
input Start_Bar_Time = 0000;

def Var2 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then high[1] else Var2[1];
def Var3 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then low[1] else Var3[1];
def Var4 = AbsValue(Var2 - high);
def Var5 = AbsValue(Var3 - low);

AddLabel(yes,"Absolure Value of Difference Between Start Bar High ("+Var2+") and Current High ("+high+"): "+Var4,color.WHITE);
AddLabel(yes,"Absolure Value of Difference Between Start Bar Low ("+Var3+") and Current Low ("+low+"): "+Var5,color.WHITE);
thank you for the quick reply but i might have not explained myself correctly. the code i'm looking for is to only label the 1st bar. showing the high price, the low price, and the difference between the first bar high and low.
 
1xkMqVa.png

Code:
input Start_Bar_Time = 0000;

def Var2 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then high[1] else Var2[1];
def Var3 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then low[1] else Var3[1];
def Var4 = AbsValue(Var2 - Var3);

AddLabel(yes,"Absolute Value of Difference Between Start Bar High ("+Var2+") and Start Bar Low ("+Var3+"): "+Var4,color.WHITE);
 
Last edited:
1xkMqVa.png

Code:
input Start_Bar_Time = 0000;

def Var2 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then high[1] else Var2[1];
def Var3 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then low[1] else Var3[1];
def Var4 = AbsValue(Var2 - Var3);

AddLabel(yes,"Absolute Value of Difference Between Start Bar High ("+Var2+") and Start Bar Low ("+Var3+"): "+Var4,color.WHITE);
i combined your script with another script i have and wanted to see if you could add 1 more label to complete what i need.

below script looks for high and low of 1st bar and the difference...the 2nd portion of the script looks for the previous bar high and low along with the difference.

i need to add a label that does the following equation: (difference of previous bar / difference of 1st bar) * 100

input Start_Bar_Time = 0930;

def Var2 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then high[1] else Var2[1];
def Var3 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then low[1] else Var3[1];
def Var4 = AbsValue(Var2 - Var3);

AddLabel(yes,"First Bar High "+Var2+" Low "+Var3+": "+Var4,color.white);


# dummy label
AddLabel(1," ",color.black);


AddLabel(1,"High: " + High[1],color.white);
AddLabel(1,"Low: " + Low[1], color.white);
AddLabel(1,"High - Low: " + (High[1] - Low[1]),color.white);;
 
@om4
Code:
input Start_Bar_Time = 0930;

def Var2 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then high[1] else Var2[1];
def Var3 = If secondsFromTime(Start_Bar_Time)==(GetAggregationPeriod()/1000) then low[1] else Var3[1];
def Var4 = AbsValue(Var2 - Var3);

AddLabel(yes,"First Bar High "+Var2+" Low "+Var3+": "+Var4,color.white);

def Var5 = high[1]-low[1];
def Var6 = (Var5/Var4)*100;

# dummy label
AddLabel(1," ",color.black);


AddLabel(1,"High: " + High[1],color.white);
AddLabel(1,"Low: " + Low[1], color.white);
AddLabel(1,"High - Low: " + (High[1] - Low[1]),color.white);

AddLabel(yes,"(difference of previous bar / difference of 1st bar) * 100 =  "+Round(Var6,1)+"%",color.white);
 
  • Like
Reactions: om4

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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