# PM high low on watchlist

#### Khahuy12

##### Member
VIP
hi, can someone create a premarket high low on watchlist? if current price greater then PM high then color greeen else red on watchlist? thank you!

Solution
EDIT 2022/01 --- changed the label color , from black to white
sorry for that mistake

i think this will do it

Ruby:
``````# prehighlow_col_01

# -------------------
# halcyonguy
# 21-06-15
# column study. find highest and lowest in premarket, and compare to daytime highs/lows
# -------------------

#khahuy12
#can someone create a premarket high low on watchlist? if current price greater then PM high then color green else red on watchlist?

input start = 0930;
input end = 1600;
# is current bar during normal trading hours?
def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0;

def prehi =
# starting pre, reset
if  daytime[1] and...``````
EDIT 2022/01 --- changed the label color , from black to white
sorry for that mistake

i think this will do it

Ruby:
``````# prehighlow_col_01

# -------------------
# halcyonguy
# 21-06-15
# column study. find highest and lowest in premarket, and compare to daytime highs/lows
# -------------------

#khahuy12
#can someone create a premarket high low on watchlist? if current price greater then PM high then color green else red on watchlist?

input start = 0930;
input end = 1600;
# is current bar during normal trading hours?
def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0;

def prehi =
# starting pre, reset
if  daytime[1] and !daytime then high
# if a higher high, set it to var
else if !daytime and high > prehi[1] then high
# else keep previous value
else prehi[1];

def prelo =
# starting pre, reset
if  daytime[1] and !daytime then low
# if a lower low, set it to var
else if !daytime and low < prelo[1] then low
# else keep previous value
else prelo[1];

def dayhigher = ( high > prehi );
def daylower = ( low < prelo );

addlabel(1, (if close > prehi then ((close - prehi) + " above pre hi")
else if close < prelo then ((prelo - close) + " below pre low") else "in pre rng"), color.white);

assignbackgroundcolor( if dayhigher then color.green else if daylower then color.red else color.current );

# -----------------
# test data for upper study
#input show_test_data = no;
#addlabel( show_test_data , "pre high= " + prehi, color.yellow);
#addlabel( show_test_data , "pre low= " + prelo, color.yellow);
#``````

Last edited:
thank you! will try tmrw

Hi @halcyonguy is there a way to show this on chart without enabling "Extended hours" on chart ?

Hi @halcyonguy is there a way to show this on chart without enabling "Extended hours" on chart ?
i don't think so. a chart study can only read data from visible bars.

87k+ Posts
178 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?