Indicator · Pine Script v5 · On the chart

Zen OOH OOL v3

by Zen-Tim

This indicator identifies whether the opening bar of a new trading day opens at its high (Open = High) or low (Open = Low) within a customizable tick tolerance.

View on GitHub

GitHub stars29on the repository
Pine versionv5runs as is
Lines of code110
Settings10inputs
LicenceMIT
Last update2 weeks ago14 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

110 lines of Pine Script v5 from indicators/Zen-OOH-OOL/zen-ooh-ool-v3.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

zen-ooh-ool-v3.txt
//@version=5
indicator("Zen OOH OOL v3", overlay=true, max_labels_count=500)

// ============================================================
// INPUTS
// ============================================================
grpLogic    = "Logic"
tolTicks    = input.int(0, "Tolerance (ticks)", minval=0, group=grpLogic,
     tooltip="0 = exact match. Increase to allow open within N ticks of HOD/LOD.")

grpDisplay  = "Display"
showArrows  = input.bool(true,  "Show arrows",            group=grpDisplay)
showLabels  = input.bool(true,  "Show arrow labels",      group=grpDisplay)
showBg      = input.bool(true,  "Highlight opening bar",  group=grpDisplay)
bgTransp    = input.int(85, "Background transparency", minval=50, maxval=99, group=grpDisplay,
     tooltip="Higher = more translucent. 85 is a good scroll-friendly default.")
showTable   = input.bool(true,  "Show stats table",       group=grpDisplay)

grpColors   = "Colors"
colOL       = input.color(color.new(#26a69a, 0), "Open = Low  (bullish)", group=grpColors)
colOH       = input.color(color.new(#ef5350, 0), "Open = High (bearish)", group=grpColors)

grpAlerts   = "Alerts"
alertOL     = input.bool(true, "Alert on Open = Low",  group=grpAlerts)
alertOH     = input.bool(true, "Alert on Open = High", group=grpAlerts)

// ============================================================
// SESSION DETECTION — first bar of new day
// ============================================================
isNewDay = dayofweek != dayofweek[1]

// ============================================================
// LOGIC
// ============================================================
tol         = tolTicks * syminfo.mintick
opensOnLow  = isNewDay and math.abs(open - low)  <= tol
opensOnHigh = isNewDay and math.abs(open - high) <= tol

// ============================================================
// BAR HIGHLIGHT (translucent, one-bar vertical band)
// ============================================================
bgcolor(showBg and opensOnLow  ? color.new(colOL, bgTransp) : na, title="O=L highlight")
bgcolor(showBg and opensOnHigh ? color.new(colOH, bgTransp) : na, title="O=H highlight")

// ============================================================
// PLOTS
// ============================================================
plotshape(showArrows and showLabels and opensOnLow,
     title="Open = Low (labeled)",  style=shape.arrowup,   location=location.belowbar,
     color=colOL, size=size.normal, text="O=L")

plotshape(showArrows and not showLabels and opensOnLow,
     title="Open = Low",            style=shape.arrowup,   location=location.belowbar,
     color=colOL, size=size.normal)

plotshape(showArrows and showLabels and opensOnHigh,
     title="Open = High (labeled)", style=shape.arrowdown, location=location.abovebar,
     color=colOH, size=size.normal, text="O=H")

plotshape(showArrows and not showLabels and opensOnHigh,
     title="Open = High",           style=shape.arrowdown, location=location.abovebar,
     color=colOH, size=size.normal)

// ============================================================
// STATS TABLE (top right)
// ============================================================
var int countDays = 0
var int countOL   = 0
var int countOH   = 0

if isNewDay
    countDays += 1
    if opensOnLow
        countOL += 1
    if opensOnHigh
        countOH += 1

var table stats = table.new(position.top_right, 2, 5,
     bgcolor=color.new(color.white, 0), border_color=color.new(color.gray, 70), border_width=1)

f_pct(x, n) => n == 0 ? "–" : str.tostring(100.0 * x / n, "#.0") + "%"

if showTable and barstate.islast
    table.clear(stats, 0, 0, 1, 4)
    table.cell(stats, 0, 0, "Zen O=HOD/LOD", text_color=color.black, bgcolor=color.new(color.gray, 85), text_size=size.small)
    table.cell(stats, 1, 0, syminfo.ticker,  text_color=color.black, bgcolor=color.new(color.gray, 85), text_size=size.small)

    table.cell(stats, 0, 1, "Days",    text_color=color.black, text_size=size.small)
    table.cell(stats, 1, 1, str.tostring(countDays), text_color=color.black, text_size=size.small)

    table.cell(stats, 0, 2, "Open=Low",  text_color=color.black, text_size=size.small)
    table.cell(stats, 1, 2, str.tostring(countOL) + "  (" + f_pct(countOL, countDays) + ")",
         text_color=color.black, text_size=size.small)

    table.cell(stats, 0, 3, "Open=High", text_color=color.black, text_size=size.small)
    table.cell(stats, 1, 3, str.tostring(countOH) + "  (" + f_pct(countOH, countDays) + ")",
         text_color=color.black, text_size=size.small)

    table.cell(stats, 0, 4, "Either",    text_color=color.black, text_size=size.small)
    table.cell(stats, 1, 4, str.tostring(countOL + countOH) + "  (" + f_pct(countOL + countOH, countDays) + ")",
         text_color=color.black, text_size=size.small)

// ============================================================
// ALERTS
// ============================================================
if alertOL and opensOnLow
    alert("Open = LOW on " + syminfo.ticker + " — bullish shave, fade down toward open", alert.freq_once_per_bar_close)

if alertOH and opensOnHigh
    alert("Open = HIGH on " + syminfo.ticker + " — bearish shave, fade up toward open", alert.freq_once_per_bar_close)

Overview

Zen OOH OOL v3 marks matching sessions directly on the price chart using directional arrows, text labels, and translucent background highlights. It also compiles historical occurrence counts into an on-chart statistics table in the top-right corner and provides alert triggers for both conditions.

Details

Published by

Zen-Tim on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Sessions & time, Candlestick patterns, Screeners & dashboards

Markets

Any symbol

Timeframes

M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Tolerance (ticks)int0tolTicks
Show arrowsbooltrueshowArrows
Show arrow labelsbooltrueshowLabels
Highlight opening barbooltrueshowBg
Background transparencyint85bgTransp
Show stats tablebooltrueshowTable
Open = Low (bullish)colorcolor.new(#26a69a, 0)colOL
Open = High (bearish)colorcolor.new(#ef5350, 0)colOH
Alert on Open = LowbooltruealertOL
Alert on Open = HighbooltruealertOH
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

575 stars

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator
257 stars

This indicator plots a 200-period weighted moving average (WMA) on the main chart and monitors price deviations across multiple timeframes. It retrieves daily, 15-minute, 5-minute, and 2-minute price data to track distance from the 200 WMA relative to key sess

Indicator v5 Moving averagesSessions & time Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald SPX - Options Trading

Golden Bullet Strategy

by TradersPost
218 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy
92 stars

This indicator classifies the market into gamma regime types (negative gamma trend, positive gamma mean-reversion, or transition) by calculating a composite score based on daily ATR ratios, session VWAP crossover frequencies, and opening range displacement. It

Indicator v5 Volatility & bandsTrend
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev GEX Regime & Trap

Session Edge Probabilities

by TraderOracle
61 stars

Session Edge Probabilities tracks eight session-based trading rules using statistical probabilities evaluated on historical chart data. It utilizes a fixed calculation timeframe to evaluate opening ranges, midnight levels, afternoon reversal windows, and price

Indicator v6 Sessions & timeScreeners & dashboards
Updated 9 days ago · None stated GitHub repository of Session Edge Probabilities
56 stars

This overlay indicator highlights candles with a body smaller than 50% of their total range by coloring them white on the price chart. Simultaneously, it calculates and plots horizontal lines for open prices across multiple higher timeframes, such as daily, we

Indicator v6 Support & resistanceCandlestick patterns Repaints
Updated 2 months ago · None stated GitHub repository of Daily Weekly Monthly Yearly Opens

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers