#-----------SR Lines----------#
def AP = AggregationPeriod.DAY;
def show_GBXH = yes;
def Show_GBXL = yes;
def na = Double.NaN;
#----- Premarket High/Low -----#
# Some code based on code by Mobius
# Created by Wiinii
def bn = BarNumber();
def h = high;
def l = low;
def o = open;
def c = close;
def yc = close(period = AP)[1];
def GlobeX = GetTime() < RegularTradingStart(GetYYYYMMDD());
def ONhigh = if GlobeX and !GlobeX[1] then h else if GlobeX and h > ONhigh[1] then h else ONhigh[1];
def ONhighBar = if show_GBXH and GlobeX and h == ONhigh then bn else na;
def ONlow = if GlobeX and !GlobeX[1] then l else if GlobeX and l < ONlow[1] then l else ONlow[1];
def ONlowBar = if Show_GBXL and GlobeX and l == ONlow then bn else na;
def OverNightHigh = if BarNumber() == HighestAll(ONhighBar) then ONhigh else OverNightHigh[1];
def OverNightLow = if BarNumber() == HighestAll(ONlowBar) then ONlow else OverNightLow[1];
plot PM_High;
plot PM_Low;
def PM_H = if IsNaN(close) then PM_H[1] else if OverNightHigh > 0 then OverNightHigh else na;
def PM_L = if IsNaN(close) then PM_L[1] else if OverNightLow > 0 then OverNightLow else na;
if !IsNaN(close(period = AP)[-1]) {
PM_High = na;
PM_Low = na;
} else {
PM_High = PM_H;
PM_Low = PM_L;
}
PM_High.SetLineWeight(2);
PM_High.SetDefaultColor(Color.GREEN);
PM_High.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
PM_High.HideBubble();
PM_High.HideTitle();
PM_Low.SetLineWeight(2);
PM_Low.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
PM_Low.SetDefaultColor(Color.RED);
PM_Low.HideBubble();
PM_Low.HideTitle();
#------After_Market_HL_TimeRange_using_ProfileHL----#
#Complements @Sleepyz
def showtodayonly = no;
def afterbegin = 1600;
def afterend = 2359;
input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE};
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
}
def afterrth = if IsNaN(close) then afterrth[1] else SecondsFromTime(afterbegin) >= 0 and SecondsTillTime(afterend) > 0;
def aftercond = afterrth != afterrth[1];
profile aftervol = VolumeProfile("startNewProfile" = aftercond and SecondsTillTime(afterend) >= 0, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);
profile aftervol1 = VolumeProfile("startNewProfile" = aftercond, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);
def afterhProfile = if IsNaN(aftervol.GetHighest()) then afterhProfile[1] else aftervol1.GetHighest();
def afterlProfile = if IsNaN(aftervol.GetLowest()) then afterlProfile[1] else aftervol1.GetLowest();
def afteruprof = if !afterrth or IsNaN(close) then afteruprof[1] else afterhProfile;
def afterlprof = if !afterrth or IsNaN(close) then afterlprof[1] else afterlProfile;
plot AM_High = if showtodayonly and GetDay() != GetLastDay() then Double.NaN else afteruprof;
plot AM_Low = if showtodayonly and GetDay() != GetLastDay() then Double.NaN else afterlprof;
AM_High.SetDefaultColor(Color.LIGHT_GREEN);
AM_High.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
AM_High.SetlineWeight(2);
AM_Low.SetDefaultColor(Color.LIGHT_RED);
AM_Low.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
AM_Low.SetlineWeight(2);
#--------------First Half Hour Bar-----------------#
def OBH_ = if SecondsFromTime(930) == 0 and SecondsTillTime(930) == 0 then h else OBH_ [1];
plot OBH = if OBH_ > 0 then OBH_ else Double.NaN;
OBH.SetPaintingStrategy(PaintingStrategy.DASHES);
OBH.SetDefaultColor(Color.GREEN);
OBH.SetLineWeight(2);
def OBL_ = if SecondsFromTime(930) == 0 and SecondsTillTime(930) == 0 then l else OBL_ [1];
plot OBL = if OBL_ > 0 then OBL_ else Double.NaN;
OBL.SetPaintingStrategy(PaintingStrategy.DASHES);
OBL.SetDefaultColor(Color.RED);
OBL.SetLineWeight(2);
#------------Day Lines--------------#
def after_open = if SecondsFromTime(935) >= 0 then 1 else 0;
plot D_Open = if after_open then open(period = AP) else na;
D_Open.SetDefaultColor(Color.YELLOW);
D_Open.SetPaintingStrategy(PaintingStrategy.POINTS);
D_Open.SetLineWeight(1);
D_Open.HideTitle();
D_Open.HideBubble();
def DOX_ = if !IsNaN(D_Open) and IsNaN(D_Open[-1]) then D_Open else DOX_[1];
plot DOX = if IsNaN(D_Open[-1]) then DOX_[-1] else Double.NaN;
DOX.SetDefaultColor(Color.YELLOW);
DOX.SetPaintingStrategy(PaintingStrategy.POINTS);
DOX.SetLineWeight(1);
plot D_High = if after_open then high(period = AP) else na;
D_High.SetDefaultColor(Color.GREEN);
D_High.SetPaintingStrategy(PaintingStrategy.POINTS);
D_High.SetLineWeight(1);
D_High.HideTitle();
D_High.HideBubble();
def DHX_ = if !IsNaN(D_High) and IsNaN(D_High[-1]) then D_High else DHX_[1];
plot DHX = if IsNaN(D_High[-1]) then DHX_[-1] else Double.NaN;
DHX.SetDefaultColor(Color.GREEN);
DHX.SetPaintingStrategy(PaintingStrategy.POINTS);
DHX.SetLineWeight(1);
plot D_Low = if after_open then low(period = AP) else na;
D_Low.SetDefaultColor(Color.RED);
D_Low.SetPaintingStrategy(PaintingStrategy.POINTS);
D_Low.SetLineWeight(1);
D_Low.HideTitle();
D_Low.HideBubble();
def DLX_ = if !IsNaN(D_Low) and IsNaN(D_Low[-1]) then D_Low else DLX_[1];
plot DLX = if IsNaN(D_Low[-1]) then DLX_[-1] else Double.NaN;
DLX.SetDefaultColor(Color.RED);
DLX.SetPaintingStrategy(PaintingStrategy.POINTS);
DLX.SetLineWeight(1);
plot Y_Close = if after_open then close(period = AP)[1] else na;
Y_Close.SetPaintingStrategy(PaintingStrategy.SQUARES);
Y_Close.SetDefaultColor(Color.DARK_ORANGE);
Y_Close.SetLineWeight(1);
Y_Close.HideTitle();
Y_Close.HideBubble();
def YCX_ = if !IsNaN(Y_Close) and IsNaN(Y_Close[-1]) then Y_Close else YCX_[1];
plot YCX = if IsNaN(Y_Close[-1]) then YCX_[-1] else Double.NaN;
YCX.SetDefaultColor(Color.DARK_ORANGE);
YCX.SetPaintingStrategy(PaintingStrategy.SQUARES);
YCX.SetLineWeight(1);
plot Y_High = if after_open then high(period = AP)[1] else na;
Y_High.SetDefaultColor(Color.GREEN);
Y_High.SetPaintingStrategy(PaintingStrategy.SQUARES);
Y_High.SetLineWeight(1);
Y_High.HideTitle();
Y_High.HideBubble();
def YHX_ = if !IsNaN(Y_High) and IsNaN(Y_High[-1]) then Y_High else YHX_[1];
plot YHX = if IsNaN(Y_High[-1]) then YHX_[-1] else Double.NaN;
YHX.SetDefaultColor(Color.GREEN);
YHX.SetPaintingStrategy(PaintingStrategy.SQUARES);
YHX.SetLineWeight(1);
plot Y_Low = if after_open then low(period = AP)[1] else na;
Y_Low.SetDefaultColor(Color.RED);
Y_Low.SetPaintingStrategy(PaintingStrategy.SQUARES);
Y_Low.SetLineWeight(1);
Y_Low.HideTitle();
Y_Low.HideBubble();
def YLX_ = if !IsNaN(Y_Low) and IsNaN(Y_Low[-1]) then Y_Low else YLX_[1];
plot YLX = if IsNaN(Y_Low[-1]) then YLX_[-1] else Double.NaN;
YLX.SetDefaultColor(Color.RED);
YLX.SetPaintingStrategy(PaintingStrategy.SQUARES);
YLX.SetLineWeight(1);
#Vol Sig
def v = volume;
input volx = 1.03;
def VC = v > v[1] * volx;
plot VoLSig = if VC then close else Double.NaN;
VoLSig.SetPaintingStrategy(PaintingStrategy.SQUARES);
VoLSig.SetDefaultColor(Color.WHITE);
VoLSig.SetLineWeight(3);
#ADR Label#################################
input AdrAvgLength = 21;
def dr = high(period = AP)[1] - low(period = AP)[1];
def tdr = high(period = AP) - low(period = AP);
def ADR = Round(ExpAverage( dr, AdrAvgLength), 2);
input Addlabel = yes;
def drp = Round((tdr / ADR) * 100, 0);
AddLabel(yes, "ADR" + AdrAvgLength + "|$" + ADR + " DR|$" + Round(tdr, 2) + "/" + drp + "%", Color.YELLOW);