Indicator · Pine Script v6 · On the chart

Zen Bar Range Projections

by Zen-Tim

Zen Bar Range Projections calculates the Average Bar Range (ABR) over a user-defined lookback period and projects 0.5x and 1x measured move levels above and below the prior bar close.

View on GitHub

GitHub stars29on the repository
Pine versionv6current
Lines of code76
Settings9inputs
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

76 lines of Pine Script v6 from indicators/Zen-Bar-Range-Projections/zen-bar-range-projections-v1.5.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

zen-bar-range-projections-v1.5.txt
//@version=6
indicator('Zen Bar Range Projections v1.5', shorttitle='ZBR Proj v1.5', overlay=true)
// ============================================================================
//  Zen Bar Range Projections v1.5
//
//  Projects 0.5x and 1x ABR levels above and below the close of the prior
//  bar - either on the chart timeframe or on a higher timeframe - so you can
//  see where a measured move from the last completed bar lands relative to
//  current price.
//
//  - Mode "Chart TF":  uses prior bar close + chart-timeframe ABR.
//  - Mode "Higher TF": uses last-closed HTF bar close + HTF ABR. HTF values
//    are sourced via [1] inside request.security() so they don't drift while
//    the live HTF bar is forming.
//
//  Bars Back lets you fan out up to 12 historical projection sets so you can
//  visually audit how price has interacted with prior projections.
// ============================================================================
string  mode       = input.string("Chart TF", "Mode", options=["Chart TF", "Higher TF"], group="Settings")
string  htf        = input.timeframe("60", "Higher Timeframe", group="Settings")
int     lookback   = input.int(8, "ABR Lookback (bars)", minval=1, maxval=50, group="Settings")
int     bars_back  = input.int(0, "Bars Back (0 = last bar only)", minval=0, maxval=11, group="Settings",
                     tooltip="0 = one set of lines from last close. 11 = twelve sets.")
int     line_width = input.int(2, "Line Width (bars)", minval=1, maxval=20, group="Settings")
color   col_1x_up  = input.color(color.new(#2196F3, 0),  "1x ABR up colour",   group="Colours")
color   col_05x_up = input.color(color.new(#2196F3, 50), "0.5x ABR up colour", group="Colours")
color   col_1x_dn  = input.color(color.new(#FF0000, 0),  "1x ABR down colour",   group="Colours")
color   col_05x_dn = input.color(color.new(#FF0000, 50), "0.5x ABR down colour", group="Colours")
int max_sets = 12
// === CHART TF ABR (runs on every bar) ===
float abr_series = ta.sma(high - low, lookback)
// === HTF DATA ===
// Use [1] inside the security call so we get values from the LAST CLOSED HTF bar,
// not the currently-forming one. This stops drift while the HTF bar is in progress.
float htf_close = request.security(syminfo.tickerid, htf, close[1],                        lookahead=barmerge.lookahead_off)
float htf_abr   = request.security(syminfo.tickerid, htf, ta.sma(high - low, lookback)[1], lookahead=barmerge.lookahead_off)
// === HTF HISTORY ===
bool htf_new_bar = ta.change(time(htf)) != 0
var array<int>   htf_anchor_bars   = array.new_int(0)
var array<float> htf_close_history = array.new_float(0)
var array<float> htf_abr_history   = array.new_float(0)
if htf_new_bar
    array.unshift(htf_anchor_bars,   bar_index - 1)
    array.unshift(htf_close_history, htf_close)
    array.unshift(htf_abr_history,   htf_abr)
    if array.size(htf_anchor_bars) > max_sets
        array.pop(htf_anchor_bars)
        array.pop(htf_close_history)
        array.pop(htf_abr_history)
// === DRAW ON LAST BAR ===
var array<line> lines = array.new_line(max_sets * 4, na)
if barstate.islast
    for i = 0 to array.size(lines) - 1
        line.delete(array.get(lines, i))
        array.set(lines, i, na)
    int sets = bars_back + 1
    for s = 0 to sets - 1
        float src_close = na
        float src_abr   = na
        int   x1        = na
        if mode == "Higher TF"
            if s < array.size(htf_close_history)
                src_close := array.get(htf_close_history, s)
                src_abr   := array.get(htf_abr_history,   s)
                x1        := array.get(htf_anchor_bars,   s)
        else
            src_close := close[s + 1]
            src_abr   := abr_series[s + 1]
            x1        := bar_index - s - 1
        if not na(src_close) and not na(src_abr) and not na(x1)
            int x2   = x1 + line_width
            int base = s * 4
            array.set(lines, base,     line.new(x1, src_close + 1.0 * src_abr, x2, src_close + 1.0 * src_abr, xloc=xloc.bar_index, color=col_1x_up,  width=1, style=line.style_solid))
            array.set(lines, base + 1, line.new(x1, src_close + 0.5 * src_abr, x2, src_close + 0.5 * src_abr, xloc=xloc.bar_index, color=col_05x_up, width=1, style=line.style_dashed))
            array.set(lines, base + 2, line.new(x1, src_close - 0.5 * src_abr, x2, src_close - 0.5 * src_abr, xloc=xloc.bar_index, color=col_05x_dn, width=1, style=line.style_dashed))
            array.set(lines, base + 3, line.new(x1, src_close - 1.0 * src_abr, x2, src_close - 1.0 * src_abr, xloc=xloc.bar_index, color=col_1x_dn,  width=1, style=line.style_solid))

Overview

Users can choose between the current chart timeframe or a higher timeframe mode using closed HTF bar data to avoid repainting. The indicator draws horizontal projection lines directly on the main price chart, with an option to display historical projection sets for visual auditing.

Details

Published by

Zen-Tim on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volatility & bands, Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

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
ModestringChart TFmode
Higher Timeframetimeframe60htf
ABR Lookback (bars)int8lookback
Bars Back (0 = last bar only)int0bars_back
Line Width (bars)int2line_width
1x ABR up colourcolorcolor.new(#2196F3, 0)col_1x_up
0.5x ABR up colourcolorcolor.new(#2196F3, 50)col_05x_up
1x ABR down colourcolorcolor.new(#FF0000, 0)col_1x_dn
0.5x ABR down colourcolorcolor.new(#FF0000, 50)col_05x_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.

Similar Pine Scripts

ICT Liquidity Void Fill

by ArunKBhaskar
575 stars

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

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Liquidity Void Fill

[RS]Donchian Fans

by ricardosantos79
261 stars

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

Indicator v4 Support & resistanceTrend
Updated 4 years ago · None stated GitHub repository of [RS]Donchian Fans

Snag - VWAP

by dearvn
257 stars

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

Indicator v5 Moving averagesVolatility & bands Repaints
Updated 6 weeks ago · None stated GitHub repository of Snag - VWAP

Candlestick Patterns

by harryguiacorn
219 stars

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

Indicator v5 Candlestick patternsVolatility & bands
Updated 1 year ago · None stated GitHub repository of Candlestick Patterns

Dynamic Linear Regression

by TradersPost
218 stars

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

Indicator v6 TrendSupport & resistance
Updated 3 months ago · None stated GitHub repository of Dynamic Linear Regression

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