Previous High/Low Range extended to current day

quijanoj44

Member
VIP
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 @useThinkScript @BenTen @SleepyZ @halcyonguy @Joshua @mashume
1746655399387.png

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:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
294 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top