Opening Range Breakout Indicator — Free Pine Script v6 for TradingView
- opening-range-breakout-indicator.pine — the complete Pine Script v6 source
- README-FIRST.md — what it does and how to install it
- FREE-LICENSE.md — the free-edition license terms
About this product
Opening Range Breakout Indicator is a free Pine Script v6 indicator by Script Master Labs. It marks the opening range and flags the first closes beyond it. The complete source is printed in full on this page and in the free download — paste it into TradingView's Pine Editor and it runs on TradingView's free plan. No payment, no account, no subscription.
What it computes, in its own terms: it the opening range: it marks the high and low of a user-defined opening session window and flags the first closes beyond them. A breakout flag records that price crossed a level; it does not predict follow-through, and false breakouts are common. The breakout flags never repaint.
How to use it
Open TradingView's Pine Editor, create a new blank indicator, paste the source, save, and click Add to chart. Adjust the inputs from the gear icon. The full source is printed on this page below, and the free download carries the same source file with an install README and the free-edition license.
Free edition vs paid edition
The script file is the complete indicator — the same Pine Script v6 source sold in the paid edition (https://dual.scriptmasterlabs.com/product/opening-range-breakout-indicator, $19 one-time). The paid edition adds the full written user guide, the evidence receipt, and the licensing and security reviews. Nothing in the script is held back from the free edition.
More free tools — five free Pine Script v6 indicators and a free x402 pre-payment trust check — are collected on the Free Tools hub. Educational software, not financial advice: it measures and draws a stated rule; it does not predict price and shows no win rate.
The complete Pine Script v6 source — free, on this page
Opening Range Breakout Indicator is a free Pine Script v6 indicator by Script Master Labs. It marks the opening range and flags the first closes beyond it. The complete source is printed in full on this page and in the free download — paste it into TradingView's Pine Editor and it runs on TradingView's free plan. No payment, no account, no subscription.
// © 2026 Script Master Labs LLC — Opening Range Breakout Indicator
// Research-based, original SML engineering. This indicator MARKS the high
// and low of a user-defined opening session window and flags the first
// closes beyond them. A breakout flag records that price crossed a level;
// it does not predict follow-through, and false breakouts are common.
//@version=6
indicator("SML Opening Range Breakout", shorttitle = "SML ORB", overlay = true, max_lines_count = 500, max_boxes_count = 500, max_labels_count = 500)
// ── Inputs ──────────────────────────────────────────────────────────────────
rangeSession = input.session("0930-1000", "Opening range session")
sessionTz = input.string("America/New_York", "Session timezone", options = ["America/New_York", "America/Chicago", "America/Denver", "America/Los_Angeles", "Europe/London", "Europe/Berlin", "Asia/Tokyo", "GMT"])
extendRight = input.int(200, "Extend range lines this many bars after the range ends", minval = 10, maxval = 500)
shadeRange = input.bool(true, "Shade the opening range box")
onlyToday = input.bool(false, "Show only the most recent day (delete prior days)")
rangeColor = input.color(color.new(color.orange, 88), "Range box fill")
highColor = input.color(color.new(color.teal, 0), "Range high line")
lowColor = input.color(color.new(color.red, 0), "Range low line")
// ── Session state ───────────────────────────────────────────────────────────
inRange = not na(time(timeframe.period, rangeSession, sessionTz))
newRange = inRange and not inRange[1]
var float orHigh = na
var float orLow = na
var int rangeStartBar = na
var box rangeBox = na
var line highLine = na
var line lowLine = na
var bool brokeUp = false
var bool brokeDown = false
if newRange
if onlyToday
box.delete(rangeBox)
line.delete(highLine)
line.delete(lowLine)
orHigh := high
orLow := low
rangeStartBar := bar_index
brokeUp := false
brokeDown := false
if shadeRange
rangeBox := box.new(bar_index, high, bar_index, low, border_color = color.new(color.orange, 40), bgcolor = rangeColor)
highLine := line.new(bar_index, high, bar_index, high, color = highColor, style = line.style_dashed)
lowLine := line.new(bar_index, low, bar_index, low, color = lowColor, style = line.style_dashed)
if inRange and not newRange
orHigh := math.max(orHigh, high)
orLow := math.min(orLow, low)
if shadeRange and not na(rangeBox)
box.set_right(rangeBox, bar_index)
box.set_top(rangeBox, orHigh)
box.set_bottom(rangeBox, orLow)
if not na(highLine)
line.set_xy2(highLine, bar_index, orHigh)
line.set_xy1(highLine, rangeStartBar, orHigh)
if not na(lowLine)
line.set_xy2(lowLine, bar_index, orLow)
line.set_xy1(lowLine, rangeStartBar, orLow)
// After the range ends, stretch the frozen lines to the right.
rangeEnded = not inRange and inRange[1]
if rangeEnded and not na(highLine)
line.set_x2(highLine, bar_index + extendRight)
line.set_x2(lowLine, bar_index + extendRight)
// ── Breakout flags (first confirmed close beyond the frozen range) ─────────
afterRange = not inRange and not na(orHigh)
var bool upNow = false
var bool downNow = false
upNow := false
downNow := false
if afterRange and barstate.isconfirmed
if not brokeUp and close > orHigh
brokeUp := true
upNow := true
label.new(bar_index, orHigh, "ORB ↑", style = label.style_label_up, color = color.new(color.teal, 10), textcolor = color.white, size = size.small)
if not brokeDown and close < orLow
brokeDown := true
downNow := true
label.new(bar_index, orLow, "ORB ↓", style = label.style_label_down, color = color.new(color.red, 10), textcolor = color.white, size = size.small)
plot(orHigh, "Opening range high", color = color.new(color.teal, 100), display = display.data_window)
plot(orLow, "Opening range low", color = color.new(color.red, 100), display = display.data_window)
alertcondition(upNow, title = "ORB breakout up (first close above range high)", message = "First close above the opening range high on {{exchange}}:{{ticker}} ({{interval}}). A crossing record, not a prediction.")
alertcondition(downNow, title = "ORB breakdown down (first close below range low)", message = "First close below the opening range low on {{exchange}}:{{ticker}} ({{interval}}). A crossing record, not a prediction.")
Questions about this product
Is there a free Pine Script for opening range breakout (ORB) on TradingView?
Yes. Script Master Labs publishes this Opening Range Breakout Indicator as a free Pine Script v6 download on SML Dual Market (https://dual.scriptmasterlabs.com/product/free-opening-range-breakout-indicator). The complete source is printed in full on the product page and in the free download — no payment, no account, no subscription.
How do I use the Opening Range Breakout Indicator?
Open TradingView's Pine Editor, create a new blank indicator, paste the source, click Save, then Add to chart. Adjust the inputs from the gear icon. TradingView's first-steps page shows where the editor opens: https://tradingview.com/pine-script-docs/primer/first-steps
Does it work on TradingView's free plan?
Yes. Paste the source into TradingView's Pine Editor and add it to your chart; the free plan runs custom indicators.
Is the free edition the complete script?
Yes — the same Pine Script v6 source file sold in the paid edition ($19 one-time). The paid edition adds the full written user guide, the evidence receipt, and the licensing and security reviews; nothing in the script itself is held back.
Does it repaint?
No. Its events are computed on confirmed bars only; a marker, once printed, does not move or disappear.