TonXas
New member
Any way to make an indicator that draws out the highs and lows from the first two 4hr bars on Sunday for the week?
As of right now I just draw them by hand but it would be cool if the computer just did it for me
As of right now I just draw them by hand but it would be cool if the computer just did it for me
Code:
# inputs
input orStartTime = 1800;
input orEndTime = 0100;
input period = AggregationPeriod.four_hours;
input showOnlyToday = no;
input showCloud = yes;
input showMidpoint = yes;
# constants
def na = Double.NaN;
def hi = high(period = period);
def lo = low(period = period);
DefineGlobalColor("Cloud", Color.GRAY);
# opening range time logic
def overnight = orStartTime > orEndTime;
def pastORstart = SecondsFromTime(orStartTime) >= 0;
def beforeORend = SecondsTillTime(orEndTime) > 0;
def isOR =
(overnight and (pastORstart or beforeORend)) or (!overnight and (pastORstart and beforeORend));
#def isOr = SecondsTillTime(orEndTime) > 0 and SecondsFromTime(orStartTime) >= 0;
def today = (!showOnlyToday or GetDay() == GetLastDay()) and !IsNaN(close);
# opening range levels logic
def orhi =
if orhi[1] == 0
or !isOr[1]
and isOr
then hi
else if isOr
and hi > orhi[1]
then hi
else orhi[1];
def orlo =
if orlo[1] == 0
or !isOr[1]
and isOr
then lo
else if isOr
and lo < orlo[1]
then lo
else orlo[1];
# plots
plot orh = if today < 1 then na else orhi;
plot orl = if today < 1 then na else orlo;
plot orm = if !isOr then (orh + orl) / 2 else na;
orm.SetHiding(!showMidpoint);
def range = orhi - orlo;
AddCloud(if showCloud and isOR then orh else na, if showCloud and isOR then orl else na, GlobalColor("cloud"), GlobalColor("cloud"));
# look and feel
orh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orm.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orh.SetDefaultColor(Color.White);
orl.SetDefaultColor(Color.White);
orm.SetDefaultColor(Color.gray);
AddLabel(close > 0, Concat( "WT: ", (orhi - orlo)*10000), Color.cyan);
#AddChartBubble(close > 0, Concat( "WT: ", (orhi - orlo)*10000), Color.cyan);