I ask Claude Ai to write this script. If all conditions are met by 10:00am, the indicator will be above 0 (1) and trigger the alert. You would need to have a chart open with the script installed. Cannot say how well it works yet, just got it working today (4/1/26)
Code:
# Opening Range Breakout (ORB) Study
# Conditions:
# 1. Price breaks above 30-min Opening Range High (9:30–10:00 AM EST)
# 2. Breakout bar volume >= 1.5x avg volume of opening range
# 3. Price is above VWAP
# 4. Time is within first 2 hours of session (before 11:30 AM EST)
# 5. (Refinement) Breakout bar closes in TOP 50% of its range
#
# Compatible with 1-min, 5-min, and 15-min charts
# ============================================================
# ─────────────────────────────────────────────
# INPUTS
# ─────────────────────────────────────────────
input showORHLine = yes; # Toggle OR High horizontal line
input showLabels = yes; # Toggle info labels
input volumeMultiplier = 1.5; # Volume threshold vs OR average
# ─────────────────────────────────────────────
# SESSION / TIME DEFINITIONS
# ─────────────────────────────────────────────
def marketOpen = 0930; # 9:30 AM EST
def orEnd = 1000; # 10:00 AM EST (end of opening range)
def sessionCutoff = 1600; # 11:30 AM EST (2-hour mark, alerts stop)
def isORWindow = SecondsFromTime(marketOpen) >= 0
and SecondsTillTime(orEnd) > 0;
def isAlertWindow = SecondsFromTime(marketOpen) >= 0
and SecondsTillTime(sessionCutoff) > 0;
# ─────────────────────────────────────────────
# OPENING RANGE HIGH & VOLUME
# ─────────────────────────────────────────────
# Track the high of the 9:30–10:00 AM range
def orHigh = HighestAll(if isORWindow then high else Double.NaN);
# Count how many bars are in the opening range window
def orBarCount = TotalSum(if isORWindow then 1 else 0);
# Sum volume during the OR window
def orVolSum = TotalSum(if isORWindow then volume else 0);
# Average volume per bar during OR
def orAvgVol = if orBarCount > 0 then orVolSum / orBarCount else 1;
# ─────────────────────────────────────────────
# VWAP
# ─────────────────────────────────────────────
def vwap = reference VWAP();
# ─────────────────────────────────────────────
# BREAKOUT CONDITIONS
# ─────────────────────────────────────────────
# 1. Price closes ABOVE the OR high (breakout confirmed on close)
def breakoutAboveOR = close > orHigh;
# 2. Current bar volume is >= 1.5x the OR average volume
def highVolume = volume >= volumeMultiplier * orAvgVol;
# 3. Price is above VWAP
def aboveVWAP = close > vwap;
# 4. Within the first 2 hours of the session (before 11:30 AM)
def withinWindow = isAlertWindow;
# 5. Refinement: Breakout bar closes in the TOP 50% of its range
# (confirms strong buying pressure — not just a poke above)
def barRange = high - low;
def midpoint = low + barRange * 0.5;
def topHalfClose = close >= midpoint;
# ─────────────────────────────────────────────
# ALL CONDITIONS MET
# ─────────────────────────────────────────────
def allConditions = breakoutAboveOR
and highVolume
and aboveVWAP
and withinWindow
and topHalfClose;
# Fire once per bar (not re-trigger mid-bar)
def alertTrigger = allConditions and !allConditions[1];
# ─────────────────────────────────────────────
# VISUALS — OR HIGH HORIZONTAL LINE
# ─────────────────────────────────────────────
plot ORHighLine = if showORHLine and orHigh > 0 then orHigh else Double.NaN;
ORHighLine.SetDefaultColor(Color.YELLOW);
ORHighLine.SetLineWeight(2);
ORHighLine.SetStyle(Curve.SHORT_DASH);
ORHighLine.HideBubble();
ORHighLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
# ─────────────────────────────────────────────
# VISUALS — BREAKOUT SIGNAL ARROW
# ─────────────────────────────────────────────
plot BreakoutSignal = if alertTrigger then low - TickSize() * 5 else Double.NaN;
plot AlertPlot = if alertTrigger then 1 else 0;
BreakoutSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BreakoutSignal.SetDefaultColor(Color.GREEN);
BreakoutSignal.SetLineWeight(3);
BreakoutSignal.HideBubble();
# ─────────────────────────────────────────────
# VISUALS — BACKGROUND HIGHLIGHT
# ─────────────────────────────────────────────
AssignBackgroundColor(if allConditions then Color.DARK_GREEN else Color.CURRENT);
# ─────────────────────────────────────────────
# LABELS
# ─────────────────────────────────────────────
AddLabel(showLabels and orHigh > 0,
"OR High: " + AsPrice(orHigh),
Color.YELLOW);
AddLabel(showLabels,
"Vol vs OR Avg: " + Round(volume / orAvgVol, 2) + "x",
if highVolume then Color.GREEN else Color.GRAY);
AddLabel(showLabels,
"VWAP: " + AsPrice(vwap),
if aboveVWAP then Color.GREEN else Color.RED);
AddLabel(showLabels,
if withinWindow then "IN Window (<11:30)" else "OUT of Window",
if withinWindow then Color.GREEN else Color.GRAY);
AddLabel(showLabels and allConditions,
"[B]* ORB SETUP ACTIVE *[/B]",
Color.GREEN);
# ─────────────────────────────────────────────
# ALERT
# ─────────────────────────────────────────────
# ─────────────────────────────────────────────
# ALERT
# ─────────────────────────────────────────────
Alert(alertTrigger,
"ORB BREAKOUT - Check Symbol, Price, and Volume",
Alert.BAR,
Sound.Ding);
Last edited by a moderator: