So I have this High Low Range Indicator, that basically plots the High and Low levels from the desired Opening Range Start and end time.
And I would like to bring the previous day or previous period High / Low range to plot into the current trading day session. If someone can help me would be great!
Thank you
@samer800 @rad14733 @MerryDay
And I would like to bring the previous day or previous period High / Low range to plot into the current trading day session. If someone can help me would be great!
Thank you
@samer800 @rad14733 @MerryDay
Ruby:
declare upper;
input openingRangeStart = 0930;
input openingRangeEnd = 1000;
input periodsBack = 0;
# Definitions and Logic
def na = Double.NaN;
input showLastPeriodOnly = no;
# IS LAST PERIOD
def timeframe = GetAggregationPeriod();
def isToday = GetDay() == GetLastDay();
def isWeek = GetWeek() == GetLastWeek();
def isMonth = GetMonth() == GetLastMonth();
def isYear = GetYear() == GetLastYear();
def dontshow = (showLastPeriodOnly
and ((timeframe <= AggregationPeriod.DAY and !isToday)
or (timeframe == AggregationPeriod.WEEK and !isWeek)
or (timeframe == AggregationPeriod.MONTH and !isMonth)
or (timeframe == AggregationPeriod.YEAR and !isYear)));
# opening range logic
def sec1 = SecondsFromTime(openingRangeStart);
def sec2 = SecondsFromTime(openingRangeEnd);
def pastORstart = (sec1 >= 0 and sec1[1] <= 0) or (sec1 < sec1[1] and sec1 > 0);
def beforeORend = (sec2 > 0 and sec2[1] <= 0) or (sec2 < sec2[1] and sec2 > 0) or (if TickValue() <= .01 and (sec2 <= 0) then GetYYYYMMDD() != GetYYYYMMDD()[-1] else 0);
def ORActive = CompoundValue(1, if pastORstart[1] == 0 and pastORstart == 1 then 1 else if beforeORend then 0 else ORActive[1], 0);
#Def ORActive = if secondstilltime(openingRangeEnd)>0 AND secondsfromtime(openingRangeStart)>=0 then 1 else 0;
def bars = 100000;
def bnOR = BarNumber();
def period = bnOR - 1;
def count = CompoundValue(1,
if ORActive and period != period[1]
then (count[1] + period - period[1]) % bars
else count[1], 0);
def cond = count < count[1] + period - period[1];
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = bars, "pricePerRow" = PricePerRow.TICKSIZE , "value area percent" = 0);
def ORHigh = if ORActive and IsNaN(vol.GetHighest())
then ORHigh[1]
else if period != period[1]
then vol.GetHighest()
else ORHigh[1];
def ORLow = if ORActive and IsNaN(vol.GetLowest())
then ORLow[1]
else if period != period[1]
then vol.GetLowest()
else ORLow[1];
def ORPrHigh = if !ORActive then ORPrHigh[1] else if ORActive then ORHigh else na;
#def ORPrHigh = ORHigh[1];
def ORPrLow = if !ORActive then ORPrLow[1] else if ORActive then ORLow else na;
# choose which low and high
def rh= ORPrHigh[periodsBack];
def rl= ORPrlow[periodsBack];
def h = if dontshow then na else rh;
def l = if dontshow then na else rl;
# plots
plot lo = l;
plot hi = h;
# look and feel
lo.SetDefaultColor(Color.RED);
hi.SetDefaultColor(Color.GREEN);
lo.SetStyle(Curve.SHORT_DASH);
hi.SetStyle(Curve.SHORT_DASH);
lo.SetLineWeight(2);
hi.SetLineWeight(2);
Last edited by a moderator: