OPEN-SOURCE SCRIPT
60-Minute Range Highlighter - Color Coded (All Dates)

//version=5
indicator("60-Minute Range Highlighter - Color Coded (All Dates)", overlay=true)
// === INPUTS ===
show_all_ranges = input.bool(true, "Highlight All 60-Minute Ranges")
show_specific_range = input.bool(true, "Show Specific 60-Minute Range")
target_hour = input.int(9, "Target Hour (24h format)", minval=0, maxval=23)
// === COLOR PICKERS ===
color1 = input.color(color.new(color.teal, 85), "Box Color 1")
color2 = input.color(color.new(color.orange, 85), "Box Color 2")
color3 = input.color(color.new(color.purple, 85), "Box Color 3")
color4 = input.color(color.new(color.green, 85), "Box Color 4")
label_color = input.color(color.yellow, "Label Color")
// === TIME CONDITIONS ===
range_period = 60
range_index = math.floor(time / (range_period * 60 * 1000)) // continuous 60-min index
is_new_range = ta.change(range_index)
range_color = switch range_index % 4
0 => color1
1 => color2
2 => color3
=> color4
// === VARS FOR STORING RANGE ===
var float h_start = na
var float l_start = na
var label range_label = na
var box b = na
if is_new_range
h_start := high
l_start := low
if show_all_ranges
b := box.new(left=bar_index, right=bar_index,
top=h_start, bottom=l_start,
border_color=color.new(range_color, 40),
bgcolor=range_color)
else
h_start := math.max(high, h_start)
l_start := math.min(low, l_start)
if show_all_ranges and not na(b)
box.set_right(b, bar_index)
box.set_top(b, h_start)
box.set_bottom(b, l_start)
// === SHOW SPECIFIC RANGE ===
hour_now = hour(time)
next_hour = (target_hour + 1) % 24
in_target_range = (hour_now == target_hour) or (hour_now == next_hour and minute(time) < 30)
if show_specific_range and is_new_range and in_target_range
range_val = h_start - l_start
label.delete(range_label)
mid_price = (h_start + l_start) / 2
range_label := label.new(bar_index, mid_price, text="Range: " + str.tostring(range_val, "#.##"), style=label.style_label_left, color=label_color, textcolor=color.black, size=size.small)
indicator("60-Minute Range Highlighter - Color Coded (All Dates)", overlay=true)
// === INPUTS ===
show_all_ranges = input.bool(true, "Highlight All 60-Minute Ranges")
show_specific_range = input.bool(true, "Show Specific 60-Minute Range")
target_hour = input.int(9, "Target Hour (24h format)", minval=0, maxval=23)
// === COLOR PICKERS ===
color1 = input.color(color.new(color.teal, 85), "Box Color 1")
color2 = input.color(color.new(color.orange, 85), "Box Color 2")
color3 = input.color(color.new(color.purple, 85), "Box Color 3")
color4 = input.color(color.new(color.green, 85), "Box Color 4")
label_color = input.color(color.yellow, "Label Color")
// === TIME CONDITIONS ===
range_period = 60
range_index = math.floor(time / (range_period * 60 * 1000)) // continuous 60-min index
is_new_range = ta.change(range_index)
range_color = switch range_index % 4
0 => color1
1 => color2
2 => color3
=> color4
// === VARS FOR STORING RANGE ===
var float h_start = na
var float l_start = na
var label range_label = na
var box b = na
if is_new_range
h_start := high
l_start := low
if show_all_ranges
b := box.new(left=bar_index, right=bar_index,
top=h_start, bottom=l_start,
border_color=color.new(range_color, 40),
bgcolor=range_color)
else
h_start := math.max(high, h_start)
l_start := math.min(low, l_start)
if show_all_ranges and not na(b)
box.set_right(b, bar_index)
box.set_top(b, h_start)
box.set_bottom(b, l_start)
// === SHOW SPECIFIC RANGE ===
hour_now = hour(time)
next_hour = (target_hour + 1) % 24
in_target_range = (hour_now == target_hour) or (hour_now == next_hour and minute(time) < 30)
if show_specific_range and is_new_range and in_target_range
range_val = h_start - l_start
label.delete(range_label)
mid_price = (h_start + l_start) / 2
range_label := label.new(bar_index, mid_price, text="Range: " + str.tostring(range_val, "#.##"), style=label.style_label_left, color=label_color, textcolor=color.black, size=size.small)
Skrypt open-source
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Wyłączenie odpowiedzialności
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 TradingView. Read more in the Terms of Use.
Skrypt open-source
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Wyłączenie odpowiedzialności
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 TradingView. Read more in the Terms of Use.