#percent_chg_after_upper
#https://usethinkscript.com/threads/15-change-for-pre-market-and-after-hour-trading.20881/
#15% change for Pre Market and after hour trading
input percent_min = 15.0;
def chartagg = GetAggregationPeriod();
def chartmin = chartagg / (1000 * 60);
def aggok = chartmin < 1440;
def start = 0930;
def end = 1600;
def daytime = if SecondsFromTime(start) >= 0 and SecondsTillTime(end) > 0 then 1 else 0;
def cls = if daytime then close else cls[1];
def after_per = if daytime then 0 else Round(100 * (close - cls) / cls, 2);
def isper = if after_per >= percent_min then 1
else if after_per <= -percent_min then -1
else 0;
Alert(after_per == 1, "crossed up" , Alert.BAR, Sound.Ding);
Alert(after_per == -1, "crossed down" , Alert.BAR, Sound.Bell);
#---------------------------
input test_bubble = no;
addchartbubble(test_bubble and aggok, low*0.992,
# chartmin + "\n" +
after_per + "%"
, (if isper then color.yellow else color.gray), no);
#