Premarket ORB with Targets For ThinkOrSwim

chewie76

Well-known member
VIP
VIP Enthusiast

Premarket Opening Range Breakout (ORB) with Targets​


Before the market opens, this indicator generates daily targets for the upside and downside. It calculates the "In the Zone" shaded area between 8-8:15am EST. Price will typically move away from this zone and hit at least one of the target levels every day. Sometimes price will breach far beyond the third target as shown in the second day of the below picture.

1771532183870.png



Code:
# ==============================================
# STUDY: PREMARKET_ORB  15-Min Range (08:00-08:15 EST) Visualizer
# ==============================================

input startTime = 0800;
input endTime   = 0815;

def aggregationPeriod = AggregationPeriod.MIN;
Assert(getAggregationPeriod() <= AggregationPeriod.fifteen_min, "Less than 15M");

# --- 1. DEFINE THE RANGE WINDOW ---
# We are "In the Zone" if time is between 08:00 and 08:15
def inRange = SecondsFromTime(startTime) >= 0 and SecondsFromTime(endTime) < 0;
def isPostRange = SecondsFromTime(endTime) >= 0;

# --- 2. CAPTURE THE AGGREGATE HIGH / LOW ---
# Recursive variables to track the Max/Min during the window.
# Once the window closes (isPostRange), we lock the value.

rec rHigh =
    if SecondsFromTime(startTime) == 0 then high
    else if inRange and high > rHigh[1] then high
    else if inRange then rHigh[1]
    else rHigh[1]; # Lock the value after 08:15

rec rLow =
    if SecondsFromTime(startTime) == 0 then low
    else if inRange and low < rLow[1] then low
    else if inRange then rLow[1]
    else rLow[1]; # Lock the value after 08:15

def rMid = (rHigh + rLow) / 2;

# --- 3. PLOT THE LEVELS ---
# We only plot these lines starting at 08:15 so the chart stays clean.

plot Midpoint = if isPostRange then rMid else Double.NaN;
Midpoint.SetDefaultColor(Color.YELLOW);
#Midpoint.SetStyle(Curve.SHORT_DASH);
Midpoint.SetLineWeight(2);

plot RangeHigh = if isPostRange then rHigh else Double.NaN;
RangeHigh.SetDefaultColor(Color.GREEN);
RangeHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RangeHigh.SetLineWeight(2);

plot RangeLow = if isPostRange then rLow else Double.NaN;
RangeLow.SetDefaultColor(Color.RED);
RangeLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
RangeLow.SetLineWeight(2);

# --- 4. FILL THE RANGE  ---
# Shades the zone between High and Low
AddCloud(RangeHigh, RangeLow, Color.GRAY, Color.GRAY);

# --- 5. TARGETS
# First target is gray line, second target is red line and third target is white line.

plot F_HT = RANGELOW -(RANGELOW-RANGEHIGH) * 4.68;
F_HT.setdefaultcolor(color.red);
F_HT.setlineweight(3);

plot F_LT = RANGEHIGH -(RANGELOW-RANGEHIGH) * -4.68;
F_LT.setdefaultcolor(color.red);
F_LT.setlineweight(3);

plot F_HT1 = RANGELOW -(RANGELOW-RANGEHIGH) * 7.58;
F_HT1.setdefaultcolor(color.WHITE);
F_HT1.setlineweight(3);

plot F_LT1 = RANGEHIGH -(RANGELOW-RANGEHIGH) * -7.58;
F_LT1.setdefaultcolor(color.WHITE);
F_LT1.setlineweight(3);

plot UM = (F_HT - Rangehigh)/2 + rangehigh;
UM.setdefaultColor(color.gray);

plot LM = rangelow - (F_HT - Rangehigh)/2;
LM.setdefaultColor(color.gray);
 
Last edited:

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
796 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