# prehighlow_col_01
# -------------------
# halcyonguy
# 21-06-15
# column study. find highest and lowest in premarket, and compare to daytime highs/lows
# -------------------
# https://usethinkscript.com/threads/pm-high-low-on-watchlist.6893/
#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);
#