First two 4 hr bars on Sunday

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

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);
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
472 Online
Create Post

Similar threads

Similar threads

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