PreMarket High & Low Labels For ThinkOrSwim

@MiamiLifeStyl

New member
How do i create a label which displays on multi-time frame

a) Day's high and low price
b) Previous Day's high and low price
c) Premarket Day's high and low price
 
Last edited by a moderator:
How do i create a label which displays on multi-time frame

a) Day's high and low price
b) Previous Day's high and low price
c) Premarket Day's high and low price


here is one way.

Ruby:
input timeframe1 = aggregationPeriod.DAY;

def dayhi = Round(high(period = timeframe1), 2);
def daylo = Round(low(period = timeframe1), 2);
def prevdayhi = dayhi[1];
def prevdaylo = daylo[1];

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Previous Day :" + prevdayhi, Color.GREEN);
AddLabel(1, "Low of Previous Day :" + prevdaylo, Color.PINK);

# bars after close to next day open
input start = 0930;
input end = 1600;
def p1 = (secondsfromTime(end) >= 0 and secondstillTime(2359) > 0);
def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(start) > 0);
def pretime = p1 or p2;

def prehi = if !pretime[1] and pretime then high
  else if pretime and high > prehi[1] then high
  else prehi[1];

def prelo = if !pretime[1] and pretime then low
  else if pretime and low < prelo[1] then low
  else prelo[1];

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Pre-market :" + prehi, Color.cyan);
AddLabel(1, "Low of Pre-market :" + prelo, Color.yellow);

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Day :" + dayhi, Color.GREEN);
AddLabel(1, "Low of Day :" + daylo, Color.PINK);
AddLabel(1, " ", Color.black);

HmHOvNo.jpg
 
here is one way.

Ruby:
input timeframe1 = aggregationPeriod.DAY;

def dayhi = Round(high(period = timeframe1), 2);
def daylo = Round(low(period = timeframe1), 2);
def prevdayhi = dayhi[1];
def prevdaylo = daylo[1];

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Previous Day :" + prevdayhi, Color.GREEN);
AddLabel(1, "Low of Previous Day :" + prevdaylo, Color.PINK);

# bars after close to next day open
input start = 0930;
input end = 1600;
def p1 = (secondsfromTime(end) >= 0 and secondstillTime(2359) > 0);
def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(start) > 0);
def pretime = p1 or p2;

def prehi = if !pretime[1] and pretime then high
  else if pretime and high > prehi[1] then high
  else prehi[1];

def prelo = if !pretime[1] and pretime then low
  else if pretime and low < prelo[1] then low
  else prelo[1];

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Pre-market :" + prehi, Color.cyan);
AddLabel(1, "Low of Pre-market :" + prelo, Color.yellow);

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Day :" + dayhi, Color.GREEN);
AddLabel(1, "Low of Day :" + daylo, Color.PINK);
AddLabel(1, " ", Color.black);

HmHOvNo.jpg
just now seeing these lables and had to add them, very nice for the chart im working on! Appreciate it, i always enjoy your coding!
 
Last edited by a moderator:
here is one way.

Ruby:
input timeframe1 = aggregationPeriod.DAY;

def dayhi = Round(high(period = timeframe1), 2);
def daylo = Round(low(period = timeframe1), 2);
def prevdayhi = dayhi[1];
def prevdaylo = daylo[1];

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Previous Day :" + prevdayhi, Color.GREEN);
AddLabel(1, "Low of Previous Day :" + prevdaylo, Color.PINK);

# bars after close to next day open
input start = 0930;
input end = 1600;
def p1 = (secondsfromTime(end) >= 0 and secondstillTime(2359) > 0);
def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(start) > 0);
def pretime = p1 or p2;

def prehi = if !pretime[1] and pretime then high
  else if pretime and high > prehi[1] then high
  else prehi[1];

def prelo = if !pretime[1] and pretime then low
  else if pretime and low < prelo[1] then low
  else prelo[1];

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Pre-market :" + prehi, Color.cyan);
AddLabel(1, "Low of Pre-market :" + prelo, Color.yellow);

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Day :" + dayhi, Color.GREEN);
AddLabel(1, "Low of Day :" + daylo, Color.PINK);
AddLabel(1, " ", Color.black);

View attachment 15935
Hi @halcyonguy

I tried to make your code to plot today's HighestH (from preMarket + RTH), but I just can't make it work. Any advice will be truly appreciated

Code:
# bars after close to next day open
input start = 0930;
input end = 1600;
def p1 = (secondsfromTime(end) >= 0 and secondstillTime(2359) > 0);
# def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(start) > 0);
def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(end) > 0);

def pretime = p1 or p2;

def prehi = if !pretime[1] and pretime then high
  else if pretime and high > prehi[1] then high
  else prehi[1];

def prelo = if !pretime[1] and pretime then low
  else if pretime and low < prelo[1] then low
  else prelo[1];

plot graph_prehi = prehi;
plot graph_prelo = prelo;
 
Any way to have the lines plotted on the chart while still leaving the info bars above? can do it manually of course, this would just save a step.
 
here is one way.

Ruby:
input timeframe1 = aggregationPeriod.DAY;

def dayhi = Round(high(period = timeframe1), 2);
def daylo = Round(low(period = timeframe1), 2);
def prevdayhi = dayhi[1];
def prevdaylo = daylo[1];

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Previous Day :" + prevdayhi, Color.GREEN);
AddLabel(1, "Low of Previous Day :" + prevdaylo, Color.PINK);

# bars after close to next day open
input start = 0930;
input end = 1600;
def p1 = (secondsfromTime(end) >= 0 and secondstillTime(2359) > 0);
def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(start) > 0);
def pretime = p1 or p2;

def prehi = if !pretime[1] and pretime then high
  else if pretime and high > prehi[1] then high
  else prehi[1];

def prelo = if !pretime[1] and pretime then low
  else if pretime and low < prelo[1] then low
  else prelo[1];

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Pre-market :" + prehi, Color.cyan);
AddLabel(1, "Low of Pre-market :" + prelo, Color.yellow);

AddLabel(1, " ", Color.black);
AddLabel(1, "High of Day :" + dayhi, Color.GREEN);
AddLabel(1, "Low of Day :" + daylo, Color.PINK);
AddLabel(1, " ", Color.black);

View attachment 15935
@halcyonguy thanks for sharing,


I wanted to get them plotted on the chart, I had already made RTH H,L,C but I didn't have the overnight H,L

So I used your code and is working but I would like to plot the highest high of the overnight period only and the lowest low of the overnight period as a FLAT line on my current day, right know it is plotting every low of each bar, I only want the lowest low, check it out and if you have any recommendation I will appreciate it!, anyway thanks for the script!!!!!!!!!!!!!!!!!!!! it is useful already as it is.

Code:
input anchorDate = 20240117;

def prueba1 = if (GetYYYYMMDD() - anchorDate) == 0 then 1 else 0;



plot ycls =  (if prueba1 then close(period = AggregationPeriod.DAY)[1] else Double.NaN )  ;


ycls.SetDefaultColor(CreateColor(255, 255, 255));

ycls.SetLineWeight(3);






plot yHoD = (if prueba1 then high(period = AggregationPeriod.DAY)[1] else double.NaN);

yHoD.SetDefaultColor(CreateColor(255, 255, 255));

plot yLoD = if prueba1 then low(period = AggregationPeriod.DAY)[1] else double.NaN;

yLoD.SetDefaultColor(CreateColor(255, 255, 255));



# bars after close to next day open

input start = 0930;

input end = 1600;

def p1 = (secondsfromTime(end) >= 0 and secondstillTime(2359) > 0);

def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(start) > 0);

def pretime = p1 or p2;


def prehi = if !pretime[1] and pretime then high

  else if pretime and high > prehi[1] then high

  else prehi[1];


def prelo = if !pretime[1] and pretime then low

  else if pretime and low < prelo[1] then low

  else prelo[1];



def prueba2 = if (GetYYYYMMDD() - anchorDate) > -1 then 1 else 0;



plot x =( if prueba2 then prehi else double.NaN);


plot y =( if prueba2 then prelo else double.NaN);
 

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