# pre_compare_hilo_0
# https://usethinkscript.com/threads/watchlist-column-current-price-wicking-premarket-high-low.12213/
# Watchlist Column - Current price wicking premarket high/low?
# phil48 8/12 #1
# Hi there! I've made watchlists to indicate price wicking the high/low of previous days, but I can't seem to make it work for premarket data. I'm looking to see something like this
#on a 15-minute time frame
# plot x= open>premarkethigh and low<premarkethigh and close>premarkethigh
# I'm also looking for a specific time range premarket that I can't seem to define properly between 8am and 9:29am ET.
# use just > when checking the end time
input prestart = 0800;
input preend = 0930;
def preperiod = (SecondsFromTime(prestart) >= 0 and SecondsTillTime(preend) > 0);
# find high low of a time period
def hi;
def lo;
if (!preperiod[1] and preperiod)
then {
hi = high;
lo = low;
} else if preperiod
then {
hi = if high > hi[1] then high else hi[1];
lo = if low < lo[1] then low else lo[1];
} else {
hi = hi[1];
lo = lo[1];
}
input start = 0930;
input end = 1600;
def rth = (SecondsFromTime(start) >= 0 and SecondsTillTime(end) > 0);
def hiz = if rth and high crosses above hi then 1 else 0;
def loz = if rth and low crosses below lo then 1 else 0;
# display a count since a crossing
def hix = if BarNumber() == 1 then 0
else if hiz then 0
else hix[1] + 1;
def lox = if BarNumber() == 1 then 0
else if loz then 0
else lox[1] - 1;
#def xmin = Min(hix, AbsValue(lox));
def xmin = if AbsValue(lox) < hix then lox else hix;
plot z = xmin;
# z.setdefaultcolor(color.black);
# AssignBackgroundColor(if xmin == hix then Color.GREEN else if AbsValue(lox) < hix then Color.RED else Color.GRAY);
#--------------
# test data
addchartbubble(hiz, high, high, color.green, yes);
addchartbubble(loz, low, low, color.red, no);
AddChartBubble(preperiod, low,
hi + "\n" +
lo
, Color.YELLOW, no);
#