PulseHub
OPEN-SOURCE SCRIPT

jrhFirst5

168
jrhFirst5 — Documentation

Pine Script version: v6 Type: Overlay indicator Purpose: Plots the high/low of the first 5 minutes after the New York cash market open (9:30–9:35 AM ET) as horizontal lines and labels — today's range in green/red, and yesterday's range carried over in fuchsia/purple.

1. Overview

"jrhFirst5" captures the price range of the opening 5 minutes of the NY session (9:30:00–9:35:00 AM Eastern by default) and draws it as two horizontal reference lines:

F5H / F5L — today's First5 high/low (green/red by default), extending live from the open bar to the current bar
PF5H / PF5L — yesterday's First5 high/low (fuchsia/purple by default), carried over at the start of each new day

The range is captured from a fixed 1-minute window (via request.security) rather than from whatever bar happens to land on 9:30 on the chart's own timeframe — this makes the plotted range identical whether you're viewing a 1-minute, 3-minute, 5-minute, or any other chart resolution.

2. Inputs
General
Input Default Description
Show Labels true Toggles the F5H/F5L/PF5H/PF5L text labels
Today High Line Color Green Color of today's high line
Today Low Line Color Red Color of today's low line
Yesterday High Line Color Fuchsia Color of yesterday's high line
Yesterday Low Line Color Purple Color of yesterday's low line
Line Width 2 Line thickness (1–4)
Line Style Solid Solid / Dashed / Dotted
Line Extension
Input Default Description
Continue Yesterday's Lines to Current Candle false When off, yesterday's lines stop (seal) at the previous session's close bar, as in the original design. When on, yesterday's lines keep extending forward to the live bar, same as today's lines already do.
Labels
Input Default Description
Label Position Left Left anchors the label at the line's starting bar (the open bar). Right makes the label follow the live end of the line — walking forward each bar with today's line, and with yesterday's line too if line extension is enabled above.
Label Size Small Tiny / Small / Normal / Large / Huge
Label Vertical Position On Line On Line keeps the label exactly at the price level. Above / Below offsets the label's visual position away from the line for readability, without changing the line itself or the price printed in the label text.
Vertical Offset (% of price) 0.05 How far Above/Below to offset the label, expressed as a percentage of the label's own price — so it scales sensibly across instruments (e.g. ~$32 offset on BTC around $64,000, proportionally smaller on lower-priced instruments) rather than a fixed tick count that could be imperceptible on high-priced symbols.
Time Zone
Input Default Description
Session Timezone (defines the 9:30 open) America/New_York The timezone used to determine when "9:30 AM" actually occurs. This is what defines the capture window — leave as NY time unless tracking a different exchange's open.
Display Timezone (shown in label tooltip) America/Chicago Purely cosmetic — attached as a hover tooltip on each label as a reminder of your local time relative to the session timezone. Does not affect any calculated values.
3. How the Capture Window Works

The core problem this solves: a chart's own bar that happens to land on 9:30 covers a different-width window depending on the chart's timeframe — a 5-minute chart's 9:30 bar spans 9:30:00–9:35:00, while a 3-minute chart's 9:30 bar spans only 9:30:00–9:33:00. That mismatch produced different F5H/F5L values on different chart resolutions.

To fix this, the range is computed from a dedicated 1-minute data feed:

f_first5(tz) =>
var float h = na
var float l = na
newDay = dayofweek(time, tz) != dayofweek(time[1], tz)
isOpenMin = hour(time, tz) == 9 and minute(time, tz) == 30
inWindow = hour(time, tz) == 9 and minute(time, tz) >= 30 and minute(time, tz) < 35
if newDay
h := na
l := na
if inWindow
h := isOpenMin ? high : math.max(h, high)
l := isOpenMin ? low : math.min(l, low)
[h, l]

[secHigh, secLow] = request.security(syminfo.tickerid, "1", f_first5(sessionTZ), gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)

This accumulates the true high/low across the five individual 1-minute bars from 9:30–9:34 (inclusive), resetting at the start of each new day (per sessionTZ). The result — secHigh/secLow — is identical no matter what timeframe the chart itself is displaying.

4. State Variables
Variable Purpose
todayHigh / todayLow Today's captured jrhFirst5 range (mirrors secHigh/secLow once available)
todayOpenBar Bar index where today's range first appeared — used as the "Left" label anchor
todayHighLine / todayLowLine Line objects for today's high/low
todayHighLabel / todayLowLabel Label objects for today's high/low
prevHigh / prevLow Yesterday's promoted jrhFirst5 range
prevOpenBar / prevCloseBar Bar indices marking yesterday's line span
prevHighLine / prevLowLine Line objects for yesterday's high/low
prevHighLabel / prevLowLabel Label objects for yesterday's high/low
5. Logic Flow
Step 1 — Day Roll (promote today → yesterday)

When a new day starts (per sessionTZ) and today had a captured range, that range is promoted to "yesterday": new fuchsia/purple lines and labels are drawn from prevOpenBar to prevCloseBar (the last bar of the prior day), sealed with extend.none unless "Continue Yesterday's Lines to Current Candle" is enabled. Today's state is then reset to na so a fresh range can be captured.

Step 2 — Capture Today's Range

firstAppearance detects the first bar where secHigh becomes available (i.e., the 9:30 window has begun). At that point, today's line and label objects are created at the current bar (todayOpenBar). On every subsequent bar where secHigh is valid, todayHigh/todayLow are kept in sync with the live-updating window total (the range can still be widening during the first few minutes), and the line/label values are updated to match.

Step 3 — Extend Lines & Labels Live

Every bar, today's lines extend their right edge (x2) to the current bar_index. If Label Position is "Right," today's labels follow along (label.set_x) to stay at the live edge. The same extension logic applies to yesterday's lines/labels only if "Continue Yesterday's Lines to Current Candle" is enabled.

Step 4 — Background Highlight & Alerts

The chart background is lightly shaded yellow during the 9:30–9:35 capture window (isWithinOpenWindow). Three alert conditions are defined:

Inside the NY Open window
Price closes above today's F5H
Price closes below today's F5L
6. Usage Notes
Multi-timeframe consistency: because the range is sourced from 1-minute data, you can freely switch chart timeframes without the jrhFirst5 levels changing.
Label readability: if today's and yesterday's labels tend to overlap (e.g. both set to "Right" position at similar price levels), use Label Vertical Position (Above/Below) on one of the pairs, or differentiate colors further — the default Yesterday High (fuchsia) and Yesterday Low (purple) are visually close and may be worth swapping to more distinct colors.
Central Time users: no change is needed for the capture logic to work correctly in Central Time — set Display Timezone to America/Chicago for a convenient tooltip reminder; the actual 9:30 open is always computed against Session Timezone (NY), which is what defines the real market open.
Weekends/24-7 instruments: the day-roll logic is driven by dayofweek() changes in the session timezone, so on a 24/7 crypto pair a "day" simply rolls over at local midnight in that timezone — there's no explicit weekend-skipping behavior built in.
7. Alerts
Alert Trigger
jrhFirst5 – Inside NY Open window Fires while the current bar falls within the 9:30–9:35 session window
jrhFirst5 – Price broke above F5H Fires when close crosses above today's jrhFirst5 high
jrhFirst5 – Price broke below F5L Fires when close crosses below today's jrhFirst5 low

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.