//@version=6
indicator('Zen Bar Range Projections v2.1', shorttitle='ZBR Proj v2.1', overlay=true, max_lines_count=200)
// ============================================================================
// Zen Bar Range Projections v2.1 · 20260509
// Dual independent HTF projections of 0.5x / 1x / 2x ABR from HTF close.
// Pattern: [close[1], (high-low)[1]] inside request.security with lookahead_on
// gives the closed HTF bar's close and range directly. Snapshot on
// rollover, anchor at bar_index - 1 (last chart bar of closed HTF).
// ============================================================================
int max_sets = 12
// ============================================================================
// HTF 1
// ============================================================================
bool h1_on = input.bool(true, "Enable HTF 1", group="HTF 1")
string h1_tf = input.timeframe("15", "Timeframe", group="HTF 1")
int h1_lookback = input.int(8, "ABR Lookback", minval=1, maxval=50, group="HTF 1")
int h1_bars_back = input.int(10, "Bars Back (0 = last only, 11 = twelve sets)", minval=0, maxval=11, group="HTF 1")
int h1_length = input.int(2, "Line Length (bars)", minval=1, maxval=50, group="HTF 1")
int h1_thickness = input.int(1, "Line Thickness", minval=1, maxval=4, group="HTF 1")
bool h1_show_05 = input.bool(true, "Show 0.5x", group="HTF 1")
bool h1_show_1 = input.bool(true, "Show 1x", group="HTF 1")
bool h1_show_2 = input.bool(false, "Show 2x", group="HTF 1")
color h1_c_05_up = input.color(color.new(#2196F3, 50), "0.5x up", group="HTF 1 Colours")
color h1_c_05_dn = input.color(color.new(#FF0000, 50), "0.5x down", group="HTF 1 Colours")
color h1_c_1_up = input.color(color.new(#2196F3, 0), "1x up", group="HTF 1 Colours")
color h1_c_1_dn = input.color(color.new(#FF0000, 0), "1x down", group="HTF 1 Colours")
color h1_c_2_up = input.color(color.new(#2196F3, 0), "2x up", group="HTF 1 Colours")
color h1_c_2_dn = input.color(color.new(#FF0000, 0), "2x down", group="HTF 1 Colours")
// ============================================================================
// HTF 2 — green up, orange down for visual distinction from HTF 1
// ============================================================================
bool h2_on = input.bool(true, "Enable HTF 2", group="HTF 2")
string h2_tf = input.timeframe("60", "Timeframe", group="HTF 2")
int h2_lookback = input.int(8, "ABR Lookback", minval=1, maxval=50, group="HTF 2")
int h2_bars_back = input.int(5, "Bars Back (0 = last only, 11 = twelve sets)", minval=0, maxval=11, group="HTF 2")
int h2_length = input.int(4, "Line Length (bars)", minval=1, maxval=50, group="HTF 2")
int h2_thickness = input.int(2, "Line Thickness", minval=1, maxval=4, group="HTF 2")
bool h2_show_05 = input.bool(true, "Show 0.5x", group="HTF 2")
bool h2_show_1 = input.bool(true, "Show 1x", group="HTF 2")
bool h2_show_2 = input.bool(false, "Show 2x", group="HTF 2")
color h2_c_05_up = input.color(color.new(#26A69A, 50), "0.5x up", group="HTF 2 Colours")
color h2_c_05_dn = input.color(color.new(#FF9800, 50), "0.5x down", group="HTF 2 Colours")
color h2_c_1_up = input.color(color.new(#26A69A, 0), "1x up", group="HTF 2 Colours")
color h2_c_1_dn = input.color(color.new(#FF9800, 0), "1x down", group="HTF 2 Colours")
color h2_c_2_up = input.color(color.new(#26A69A, 0), "2x up", group="HTF 2 Colours")
color h2_c_2_dn = input.color(color.new(#FF9800, 0), "2x down", group="HTF 2 Colours")
// ============================================================================
// HTF DATA — closed HTF bar's close and range, every chart bar
// ============================================================================
[h1_close, h1_range] = request.security(syminfo.tickerid, h1_tf, [close[1], (high - low)[1]], lookahead=barmerge.lookahead_on)
[h2_close, h2_range] = request.security(syminfo.tickerid, h2_tf, [close[1], (high - low)[1]], lookahead=barmerge.lookahead_on)
// ============================================================================
// HISTORY ARRAYS — snapshot when HTF rolls over
// ============================================================================
var array<int> h1_anchors = array.new_int(0)
var array<float> h1_closes = array.new_float(0)
var array<float> h1_ranges = array.new_float(0)
var array<float> h1_abrs = array.new_float(0)
var array<int> h2_anchors = array.new_int(0)
var array<float> h2_closes = array.new_float(0)
var array<float> h2_ranges = array.new_float(0)
var array<float> h2_abrs = array.new_float(0)
bool h1_roll = ta.change(time(h1_tf)) != 0
bool h2_roll = ta.change(time(h2_tf)) != 0
if h1_roll
array.unshift(h1_anchors, bar_index - 1)
array.unshift(h1_closes, h1_close)
array.unshift(h1_ranges, h1_range)
float abr_now = na
if array.size(h1_ranges) >= h1_lookback
float sum = 0.0
for i = 0 to h1_lookback - 1
sum += array.get(h1_ranges, i)
abr_now := sum / h1_lookback
array.unshift(h1_abrs, abr_now)
if array.size(h1_anchors) > max_sets
array.pop(h1_anchors)
array.pop(h1_closes)
array.pop(h1_ranges)
array.pop(h1_abrs)
if h2_roll
array.unshift(h2_anchors, bar_index - 1)
array.unshift(h2_closes, h2_close)
array.unshift(h2_ranges, h2_range)
float abr_now = na
if array.size(h2_ranges) >= h2_lookback
float sum = 0.0
for i = 0 to h2_lookback - 1
sum += array.get(h2_ranges, i)
abr_now := sum / h2_lookback
array.unshift(h2_abrs, abr_now)
if array.size(h2_anchors) > max_sets
array.pop(h2_anchors)
array.pop(h2_closes)
array.pop(h2_ranges)
array.pop(h2_abrs)
// ============================================================================
// DRAW HELPER
// ============================================================================
draw_set(array<line> store, int slot_base, int x1, int x2, float c, float a, bool s_05, bool s_1, bool s_2, color c_05u, color c_05d, color c_1u, color c_1d, color c_2u, color c_2d, int thick) =>
if s_05
array.set(store, slot_base, line.new(x1, c + 0.5 * a, x2, c + 0.5 * a, xloc=xloc.bar_index, color=c_05u, width=thick, style=line.style_dashed))
array.set(store, slot_base + 1, line.new(x1, c - 0.5 * a, x2, c - 0.5 * a, xloc=xloc.bar_index, color=c_05d, width=thick, style=line.style_dashed))
if s_1
array.set(store, slot_base + 2, line.new(x1, c + 1.0 * a, x2, c + 1.0 * a, xloc=xloc.bar_index, color=c_1u, width=thick, style=line.style_solid))
array.set(store, slot_base + 3, line.new(x1, c - 1.0 * a, x2, c - 1.0 * a, xloc=xloc.bar_index, color=c_1d, width=thick, style=line.style_solid))
if s_2
array.set(store, slot_base + 4, line.new(x1, c + 2.0 * a, x2, c + 2.0 * a, xloc=xloc.bar_index, color=c_2u, width=thick, style=line.style_dotted))
array.set(store, slot_base + 5, line.new(x1, c - 2.0 * a, x2, c - 2.0 * a, xloc=xloc.bar_index, color=c_2d, width=thick, style=line.style_dotted))
// ============================================================================
// DRAW
// ============================================================================
var array<line> h1_lines = array.new_line(max_sets * 6, na)
var array<line> h2_lines = array.new_line(max_sets * 6, na)
if barstate.islast
for i = 0 to array.size(h1_lines) - 1
line.delete(array.get(h1_lines, i))
array.set(h1_lines, i, na)
for i = 0 to array.size(h2_lines) - 1
line.delete(array.get(h2_lines, i))
array.set(h2_lines, i, na)
if h1_on
int sets = h1_bars_back + 1
for s = 0 to sets - 1
if s < array.size(h1_anchors)
int x1 = array.get(h1_anchors, s)
float c = array.get(h1_closes, s)
float abr = array.get(h1_abrs, s)
if not na(x1) and not na(c) and not na(abr)
int x2 = x1 + h1_length
draw_set(h1_lines, s * 6, x1, x2, c, abr, h1_show_05, h1_show_1, h1_show_2, h1_c_05_up, h1_c_05_dn, h1_c_1_up, h1_c_1_dn, h1_c_2_up, h1_c_2_dn, h1_thickness)
if h2_on
int sets = h2_bars_back + 1
for s = 0 to sets - 1
if s < array.size(h2_anchors)
int x1 = array.get(h2_anchors, s)
float c = array.get(h2_closes, s)
float abr = array.get(h2_abrs, s)
if not na(x1) and not na(c) and not na(abr)
int x2 = x1 + h2_length
draw_set(h2_lines, s * 6, x1, x2, c, abr, h2_show_05, h2_show_1, h2_show_2, h2_c_05_up, h2_c_05_dn, h2_c_1_up, h2_c_1_dn, h2_c_2_up, h2_c_2_dn, h2_thickness)
Overview
For each enabled timeframe it measures the average bar range over a chosen lookback, then places horizontal lines at 0.5, 1 and 2 times that range above and below the last closed higher-timeframe close. Users can show or hide each multiple, set line length and thickness, and keep up to twelve historical sets. Colours distinguish up and down projections and the two timeframes. It snapshots closed bars rather than the live bar.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Enable HTF 1
bool
true
h1_on
Timeframe
timeframe
15
h1_tf
ABR Lookback
int
8
h1_lookback
Bars Back (0 = last only, 11 = twelve sets)
int
10
h1_bars_back
Line Length (bars)
int
2
h1_length
Line Thickness
int
1
h1_thickness
Show 0.5x
bool
true
h1_show_05
Show 1x
bool
true
h1_show_1
Show 2x
bool
false
h1_show_2
0.5x up
color
color.new(#2196F3, 50)
h1_c_05_up
0.5x down
color
color.new(#FF0000, 50)
h1_c_05_dn
1x up
color
color.new(#2196F3, 0)
h1_c_1_up
Show all 30 settings
Setting
Type
Default
Variable
1x down
color
color.new(#FF0000, 0)
h1_c_1_dn
2x up
color
color.new(#2196F3, 0)
h1_c_2_up
2x down
color
color.new(#FF0000, 0)
h1_c_2_dn
Enable HTF 2
bool
true
h2_on
Timeframe
timeframe
60
h2_tf
ABR Lookback
int
8
h2_lookback
Bars Back (0 = last only, 11 = twelve sets)
int
5
h2_bars_back
Line Length (bars)
int
4
h2_length
Line Thickness
int
2
h2_thickness
Show 0.5x
bool
true
h2_show_05
Show 1x
bool
true
h2_show_1
Show 2x
bool
false
h2_show_2
0.5x up
color
color.new(#26A69A, 50)
h2_c_05_up
0.5x down
color
color.new(#FF9800, 50)
h2_c_05_dn
1x up
color
color.new(#26A69A, 0)
h2_c_1_up
1x down
color
color.new(#FF9800, 0)
h2_c_1_dn
2x up
color
color.new(#26A69A, 0)
h2_c_2_up
2x down
color
color.new(#FF9800, 0)
h2_c_2_dn
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 ICT liquidity void fills on the price chart and can show long and short signals. It places a Fibonacci level inside a displacement candle, defaulting to the midpoint, and draws lines in a chosen style. Optional filters limit the fi
This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high
This indicator plots a custom Anchored Volume-Weighted Average Price (VWAP) directly on the price chart along with optional standard deviation bands. Users can anchor the VWAP to standard time periods like sessions, weeks, or months, or to corporate events suc
This indicator plots optional candlestick pattern signals on the price chart. It detects engulfing bars, inside bars, HOLP and LOHP, kicker patterns, body-mass extremes, higher highs and lower lows, ATR warnings, and four-bar fractals. Optional pivot marks use
Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin
This indicator overlays trend-following Supertrend bands on the price chart using Average True Range calculations. It plots trailing stop lines, highlights active trend directions, and prints buy or sell shape labels when price closes across band thresholds. I