#LABELS
#
#Current Price
AddLabel (1, "P: " + Round(close,2), Color.CYAN);
#Percent Change from yesterday close
def AP = AggregationPeriod.DAY;
def Priorclose = close(period = AP)[1];
def PctChange = (close - Priorclose) / Priorclose;
def PC1 = Round(PctChange, 3);
AddLabel(1, "Ch: " + AsPercent(PC1), if PctChange > 0 then CreateColor(238, 210, 238) else createcolor(255,153,153));
#Check if time is premarket
def pmopen = if secondsFromTime(0400)>=0 and secondstillTime(0930)>=0 then 1 else 0;
def pmclosed = if secondsFromTime(0400)>=0 and secondstillTime(0930)>=0 then 0 else 1;
def pastten = if secondsFromTime(0400)>=0 and secondstillTime(1000)>=0 then 1 else 0;
#Prior Close
AddLabel (1, "YC: " + Round(Priorclose, 2), Color.LIGHT_GREEN);
#Open price
def open1 = open(period = AP);
AddLabel (pmclosed, "O: " + Round(open1, 2), CreateColor(254, 216, 177));
#High of Day
def high1 = Highest(high(period = AP), 1);
AddLabel (pmclosed, "H: " + Round(high1, 2), Color.CYAN);
#Low of Day
def low1 = Lowest(low(period = AP), 1);
AddLabel (pmclosed, "L: " + Round(low1, 2), CreateColor(178, 255, 102));
#Volume Today
def today = volume(period = AP);
def L1 = RoundDown(Lg(today), 0);
AddLabel (L1 < 5, "V: " + today, CreateColor(206, 177, 128));
AddLabel (L1 between 4.5 and 5.5, "V: " + Round((today / 1000), 0) + "K", CreateColor(206, 177, 128));
AddLabel (L1 > 5, "V: " + Round((today / 1000000), 1) + "M", CreateColor(206, 177, 128));
#Change From Open
def CFO = (close / open1) - 1;
def CFO1 = Round(CFO, 3);
AddLabel(pmclosed, "C: " + AsPercent(CFO1), if CFO > 0 then CreateColor(0, 255, 128) else CreateColor(255, 153, 153));
#Relative Volume
def AV = AggregationPeriod.Day;
def x1 = Average(volume(period=AV)[1],60);
def v1 = volume(period=AV);
def z1 = v1/x1;
Addlabel(pmclosed, "R: "+ Round(z1,1), createcolor(208,209,238));
#Premarket Open
def newDay = GetDay() <> GetDay()[1];
def start = newDay or SecondsTillTime(400) == 0;
rec premarketOpen = if start then open else premarketOpen[1];
def x = premarketOpen;
Addlabel(pmopen, "PMO: " + Round(x,2), createcolor(110,160,208));
def h = high;
def bar = BarNumber();
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());
#Premarket High
def ONhigh = if GlobeX and !GlobeX[1] then h else if GlobeX and h > ONhigh[1] then h else ONhigh[1];
def ONhighBar = if GlobeX and h == ONhigh then bar else Double.NaN;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar) then ONhigh else OverNightHigh[1];
AddLabel(pastten, "PMH: " + Round(OverNightHigh,2), color.CYAN);
#Pct difference between price and premarket open
Def z=Round(100*((close/x)-1),1);
Addlabel(pmopen, "PMG: " + z + "%", if z <0 then createcolor(255,153,153) else createcolor(197,239,161));