An intraday indicator designed for gold that takes the high and low of one chosen hourly candle, set by an hour input, and extends them across the rest of the day as reference lines.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
73 lines of Pine Script v5 from src/indicators/custom/hourRange.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
hourRange.pine
//@version=5
indicator("XAUUSD 19h - 1H Closed Ref", overlay=true, max_lines_count=500)
// --- Condition d'unité de temps (Inférieur au Daily) ---
isAllowed = timeframe.isintraday
// --- Paramètres ---
targetHour = input.int(18, "Heure de la bougie (ex: 18 pour 18h-19h)", minval=0, maxval=23)
candleColor = input.color(color.new(#ff6803, 50), "Couleur Bougie cible")
// --- Paramètres de Style ---
highColorSetting = input.color(color.green, "Couleur High", group="Style High")
highStyleSetting = input.string("Solid", "Style High", options=["Solid", "Dashed", "Dotted"], group="Style High")
lowColorSetting = input.color(color.red, "Couleur Low", group="Style Low")
lowStyleSetting = input.string("Solid", "Style Low", options=["Solid", "Dashed", "Dotted"], group="Style Low")
lineWidth = input.int(2, "Épaisseur", minval=1)
// --- Récupération des données 1H ---
[h1h, l1h] = request.security(syminfo.tickerid, "60", [high[1], low[1]], lookahead=barmerge.lookahead_on)
// --- Logique de détection ---
var float refHigh = na
var float refLow = na
var line lineH = na
var line lineL = na
var int bias = 0
isNewDay = ta.change(time("D"))
// On utilise l'heure du graphique (hour)
isClotureTarget = hour[1] == targetHour and hour != targetHour
// On n'exécute la logique de création que si on est en Intraday
if isAllowed and isClotureTarget
refHigh := h1h
refLow := l1h
bias := 0
// Dessin des segments
lineH := line.new(bar_index, refHigh, bar_index, refHigh, color=highColorSetting, width=lineWidth, style=(highStyleSetting == "Solid" ? line.style_solid : highStyleSetting == "Dashed" ? line.style_dashed : line.style_dotted))
lineL := line.new(bar_index, refLow, bar_index, refLow, color=lowColorSetting, width=lineWidth, style=(lowStyleSetting == "Solid" ? line.style_solid : lowStyleSetting == "Dashed" ? line.style_dashed : line.style_dotted))
// Extension des lignes (uniquement si autorisé)
if isAllowed and not na(refHigh) and not isNewDay
line.set_x2(lineH, bar_index)
line.set_x2(lineL, bar_index)
// Définition du Biais
if isAllowed and not na(refHigh)
if close > refHigh
bias := 1
else if close < refLow
bias := -1
// Reset pour le lendemain
if isNewDay
refHigh := na
refLow := na
bias := 0
// --- Affichage ---
// Background (seulement si isAllowed)
bgcolor(isAllowed and bias == 1 ? color.new(highColorSetting, 90) : isAllowed and bias == -1 ? color.new(lowColorSetting, 90) : na)
// Coloration des bougies (seulement si isAllowed)
isInsideTarget = hour == targetHour
barcolor(isAllowed and isInsideTarget ? candleColor : na)
// Signaux (seulement si isAllowed)
biasChanged = ta.change(bias)
plotshape(isAllowed and biasChanged and bias == 1, "Breakout Haut", shape.triangleup, location.belowbar, color.green, size=size.small)
plotshape(isAllowed and biasChanged and bias == -1, "Breakout Bas", shape.triangledown, location.abovebar, color.red, size=size.small)
Overview
A background tint and triangle markers show when price closes above the high or below the low, setting a bullish or bearish bias that resets each day. The chosen hour candle is coloured on the chart. It works only on intraday timeframes and draws on the price chart.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Heure de la bougie (ex: 18 pour 18h-19h)
int
18
targetHour
Couleur Bougie cible
color
color.new(#ff6803, 50)
candleColor
Couleur High
color
color.green
highColorSetting
Style High
string
Solid
highStyleSetting
Couleur Low
color
color.red
lowColorSetting
Style Low
string
Solid
lowStyleSetting
Épaisseur
int
2
lineWidth
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.
This overlay indicator marks the New York initial balance and a configurable opening range on the price chart and reports live range statistics in two tables. It builds an IB box for a default 09:30–10:30 ET window, an ORB box from 09:30 for a set number of mi
This indicator calculates and plots session ranges and key breakout levels for DAX futures directly on the price chart. It defines the overnight Globex session, the Frankfurt pre-market range, and the regular trading hours open using European timezone settings
The ORB Pro indicator calculates and plots Opening Range Breakout levels, stop-loss and take-profit zones, signal labels, and an status dashboard on the price chart. Built on academic research, it evaluates trades using an opening-candle direction filter, open
This indicator plots opening range breakout levels across multiple timeframes, including five, fifteen, thirty, and sixty minutes, directly on the price chart. It also displays the session open and overnight high and low levels. The script calculates an openin
FX Market Sessions highlights distinct trading sessions, such as London, New York, and Tokyo, directly on the main price chart. It draws background boxes for each active session and optionally plots opening ranges, Fibonacci retracement levels, and session ext
Plots timed breakout ranges directly on the price chart, designed for gold trading using dollar-based spacing. At scheduled trigger times or recurring two-hour intervals, it creates a central reference box flanked by upper and lower breakout stop lines, follow