Indicator · Pine Script v5 · On the chart

Average Bar Range Stats

by Zen-Tim

This indicator calculates the current bar's high-minus-low range in points, excluding overnight gaps.

View on GitHub

GitHub stars29on the repository
Pine versionv5runs as is
Lines of code36
Settings1inputs
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

36 lines of Pine Script v5 from indicators/Zen-Average-Bar-Range-Stats/Average_Bar_Range_Stats_v1_1_20260512.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

Average_Bar_Range_Stats_v1_1_20260512.txt
//@version=5
// =============================================================================
// Average Bar Range Stats v1.1 · 20260512
// =============================================================================
// Purpose: Computes three values for a Daily Range Distribution study and
// exposes them in the Data Window only. Nothing is rendered on the chart.
// Values are picked up by TradingView's "Export chart data" feature.
//
// Output columns (CSV export):
//   - Range              today's daily range (high - low), in points
//   - Average Bar Range  N-bar simple moving average of Range
//   - Range / ABR        Range divided by Average Bar Range
//
// Apply on the DAILY timeframe of any instrument.
//
// Notes:
//   - Range = high - low (intraday range only). Gaps are NOT included.
//   - The first N-1 bars have a blank Average Bar Range from the SMA warm-up.
//     Drop these rows before analysis.
// =============================================================================

indicator("Average Bar Range Stats", overlay = true)

// --- Inputs ---
abr_length = input.int(8, title = "Average Bar Range Length", minval = 1, maxval = 200,
     tooltip = "Number of bars in the simple moving average of daily range. Default 8.")

// --- Computations ---
rng          = high - low
abr          = ta.sma(rng, abr_length)
rng_over_abr = abr > 0 ? rng / abr : na

// --- Data-window-only output (invisible on chart, included in CSV export) ---
plot(rng,          title = "Range",             display = display.data_window)
plot(abr,          title = "Average Bar Range", display = display.data_window)
plot(rng_over_abr, title = "Range / ABR",       display = display.data_window)

Overview

Average Bar Range Stats then computes a simple moving average of that range over a user-set length and the ratio of the current range to that average. The length input defaults to eight bars and can run from one to two hundred. All three series are plotted only in the data window for chart-data export, so nothing is drawn on the price chart. It is intended for the daily timeframe of any instrument. The first bars stay blank while the average warms up.

Details

Published by

Zen-Tim on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Volatility & bands

Markets

Any symbol

Timeframes

H4 and above

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
Average Bar Range Lengthint8abr_length
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

Chandelier Exit

by everget
948 stars

This indicator plots an ATR-based Chandelier Exit trailing stop on the price chart. It tracks a long stop under recent highs and a short stop above recent lows, then switches direction when price crosses the opposite stop. Buy and sell labels mark those flips.

Indicator v6 Volatility & bandsTrend Repaints
Updated 10 days ago · GPL-3.0 GitHub repository of Chandelier Exit

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

This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]
318 stars

This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon

Algo AVT

by ricardosantos79
261 stars

This indicator calculates an outlier-filtered moving average based on statistical filtering concepts. It stores close prices in a rolling array over a user-defined length, calculates the mean and standard deviation, and excludes values falling within a specifi

Indicator v4 Moving averagesVolatility & bands
Updated 4 years ago · None stated GitHub repository of Algo AVT

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