Code:
input ShowTodayOnly = no;
input start = {default rth, premarket};
input onexpansion = no;
def ORActive = if start == start.premarket
then if ORActive[1] == 0 and
GetYYYYMMDD() != GetYYYYMMDD()[1]
then 1
else if ORActive[1] == 1 and
GetTime() <= RegularTradingEnd(GetYYYYMMDD())
then 1
else 0
else if start == start.rth and
GetTime() >= RegularTradingStart(GetYYYYMMDD()) and
GetTime() <= RegularTradingEnd(GetYYYYMMDD())
then 1
else 0;
def ORHigh = if ORHigh[1] == 0 or
ORActive[1] == 0 and
ORActive == 1
then high
else if ORActive and
high > ORHigh[1]
then high
else ORHigh[1];
def ORLow = if ORLow[1] == 0 or
ORActive[1] == 0 and
ORActive == 1
then low
else if ORActive and
low < ORLow[1]
then low
else ORLow[1];
def ORHexp = if IsNaN(close)
then ORHexp[1]
else ORHigh;
def ORLexp = if IsNaN(close)
then ORLexp[1]
else ORLow;
plot ORH = if (ShowTodayOnly and
GetDay() != GetLastDay()) or
!ORActive
then Double.NaN
else if onexpansion and IsNaN(close)
then ORHexp
else if !onexpansion
then ORHigh
else Double.NaN;
plot ORL = if (ShowTodayOnly and
GetDay() != GetLastDay()) or
!ORActive
then Double.NaN
else if onexpansion and IsNaN(close)
then ORLexp
else if !onexpansion
then ORLow
else Double.NaN;
plot MID = if (ShowTodayOnly and
GetDay() != GetLastDay()) or
!ORActive
then Double.NaN
else (ORH - ORL)*.382 +orl;
ORH.SetDefaultColor(Color.GREEN);
ORH.SetStyle(Curve.MEDIUM_DASH);
ORH.SetLineWeight(2);
ORL.SetDefaultColor(Color.RED);
ORL.SetStyle(Curve.MEDIUM_DASH);
ORL.SetLineWeight(2);
MID.SetDefaultColor(Color.LIGHT_ORANGE);
MID.SetStyle(Curve.MEDIUM_DASH);
MID.SetLineWeight(2);
Attachments
Last edited by a moderator: