Indicator · Pine Script v6 · On the chart

Zen ABR Range Bands

by Zen-Tim

Calculates an Exponential Moving Average baseline surrounded by Average Bar Range bands based on an 8-period bar range calculation.

View on GitHub

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

91 lines of Pine Script v6 from indicators/Zen-ABR-Range-Bands/zen-abr-range-bands-v1.1.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

zen-abr-range-bands-v1.1.txt
// © Zen_Tim_Trades

//@version=6
indicator("Zen ABR Range Bands v1.1", overlay=true)

// ============================================================
// INPUTS
// ============================================================

// --- Moving Average ---
showEMA  = input.bool(true, "Show EMA", group="Moving Average")
emaLen   = input.int(20, "EMA Length", minval=1, group="Moving Average")
emaColor = input.color(color.new(#1A1A1A, 50), "EMA Color", group="Moving Average")

// --- ABR Bands (8-bar ABR, multiplied 1x / 2x / 3x / 4x) ---
show1x = input.bool(true,  "Show 1x ABR Band", group="ABR Bands")
col1x  = input.color(color.new(#2B2B2B, 50), "1x ABR Color", group="ABR Bands")

show2x = input.bool(false, "Show 2x ABR Band", group="ABR Bands")
col2x  = input.color(color.new(#404040, 50), "2x ABR Color", group="ABR Bands")

show3x = input.bool(false, "Show 3x ABR Band", group="ABR Bands")
col3x  = input.color(color.new(#595959, 50), "3x ABR Color", group="ABR Bands")

show4x = input.bool(false, "Show 4x ABR Band", group="ABR Bands")
col4x  = input.color(color.new(#737373, 50), "4x ABR Color", group="ABR Bands")

lineWidth = input.int(1, "Band Line Width", minval=1, maxval=4, group="ABR Bands")

// --- Bar Highlight: wick-touch hits on each ABR level, each side toggled independently ---
// Above the EMA = SHORT side = red. Below the EMA = LONG side = blue.
// Levels are cumulative (a 4x hit also satisfies 2x/3x), same as the performance-grid study —
// each checkbox fires independently off its own threshold, not off the others.
hl1xAbove = input.bool(false, "Highlight 1x Above EMA (Red)",  group="Bar Highlight")
hl2xAbove = input.bool(false, "Highlight 2x Above EMA (Red)",  group="Bar Highlight")
hl3xAbove = input.bool(false, "Highlight 3x Above EMA (Red)",  group="Bar Highlight")
hl4xAbove = input.bool(false, "Highlight 4x Above EMA (Red)",  group="Bar Highlight")

hl1xBelow = input.bool(false, "Highlight 1x Below EMA (Blue)", group="Bar Highlight")
hl2xBelow = input.bool(false, "Highlight 2x Below EMA (Blue)", group="Bar Highlight")
hl3xBelow = input.bool(false, "Highlight 3x Below EMA (Blue)", group="Bar Highlight")
hl4xBelow = input.bool(false, "Highlight 4x Below EMA (Blue)", group="Bar Highlight")

highlightColorAbove = input.color(color.red,  "Above EMA Highlight Color", group="Bar Highlight")
highlightColorBelow = input.color(color.blue, "Below EMA Highlight Color", group="Bar Highlight")

// ============================================================
// CALCULATIONS
// ============================================================

emaVal = ta.ema(close, emaLen)

barRange = high - low
abr8 = ta.sma(barRange, 8)   // ABR lookback fixed at 8 — sacrosanct, never change

// Wick-touch hit tests, one per level per side — matches the study's entry rule exactly
hit1xAbove = high >= emaVal + abr8 * 1
hit2xAbove = high >= emaVal + abr8 * 2
hit3xAbove = high >= emaVal + abr8 * 3
hit4xAbove = high >= emaVal + abr8 * 4

hit1xBelow = low <= emaVal - abr8 * 1
hit2xBelow = low <= emaVal - abr8 * 2
hit3xBelow = low <= emaVal - abr8 * 3
hit4xBelow = low <= emaVal - abr8 * 4

aboveHit = (hl1xAbove and hit1xAbove) or (hl2xAbove and hit2xAbove) or (hl3xAbove and hit3xAbove) or (hl4xAbove and hit4xAbove)
belowHit = (hl1xBelow and hit1xBelow) or (hl2xBelow and hit2xBelow) or (hl3xBelow and hit3xBelow) or (hl4xBelow and hit4xBelow)

// On the rare bar that hits both sides (a huge-range day spanning above and below EMA), above wins the tie.
highlightColor = aboveHit ? highlightColorAbove : belowHit ? highlightColorBelow : na

barcolor(highlightColor, title="ABR Level Highlight")

// ============================================================
// PLOTS
// ============================================================

plot(showEMA ? emaVal : na, title="EMA", color=emaColor, linewidth=2)

plot(show1x ? emaVal + abr8 * 1 : na, title="1x ABR Upper", color=col1x, linewidth=lineWidth)
plot(show1x ? emaVal - abr8 * 1 : na, title="1x ABR Lower", color=col1x, linewidth=lineWidth)

plot(show2x ? emaVal + abr8 * 2 : na, title="2x ABR Upper", color=col2x, linewidth=lineWidth)
plot(show2x ? emaVal - abr8 * 2 : na, title="2x ABR Lower", color=col2x, linewidth=lineWidth)

plot(show3x ? emaVal + abr8 * 3 : na, title="3x ABR Upper", color=col3x, linewidth=lineWidth)
plot(show3x ? emaVal - abr8 * 3 : na, title="3x ABR Lower", color=col3x, linewidth=lineWidth)

plot(show4x ? emaVal + abr8 * 4 : na, title="4x ABR Upper", color=col4x, linewidth=lineWidth)
plot(show4x ? emaVal - abr8 * 4 : na, title="4x ABR Lower", color=col4x, linewidth=lineWidth)

Overview

Plots upper and lower channels at 1x, 2x, 3x, and 4x ABR multiples directly on the main price chart. Includes configurable bar highlighting options that trigger when high or low wicks touch or penetrate specific band thresholds relative to the central moving average line.

Details

Published by

Zen-Tim on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Trend, Volatility & bands, Moving averages

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
Show EMAbooltrueshowEMA
EMA Lengthint20emaLen
EMA Colorcolorcolor.new(#1A1A1A, 50)emaColor
Show 1x ABR Bandbooltrueshow1x
1x ABR Colorcolorcolor.new(#2B2B2B, 50)col1x
Show 2x ABR Bandboolfalseshow2x
2x ABR Colorcolorcolor.new(#404040, 50)col2x
Show 3x ABR Bandboolfalseshow3x
3x ABR Colorcolorcolor.new(#595959, 50)col3x
Show 4x ABR Bandboolfalseshow4x
4x ABR Colorcolorcolor.new(#737373, 50)col4x
Band Line Widthint1lineWidth
Show all 22 settings
SettingTypeDefaultVariable
Highlight 1x Above EMA (Red)boolfalsehl1xAbove
Highlight 2x Above EMA (Red)boolfalsehl2xAbove
Highlight 3x Above EMA (Red)boolfalsehl3xAbove
Highlight 4x Above EMA (Red)boolfalsehl4xAbove
Highlight 1x Below EMA (Blue)boolfalsehl1xBelow
Highlight 2x Below EMA (Blue)boolfalsehl2xBelow
Highlight 3x Below EMA (Blue)boolfalsehl3xBelow
Highlight 4x Below EMA (Blue)boolfalsehl4xBelow
Above EMA Highlight Colorcolorcolor.redhighlightColorAbove
Below EMA Highlight Colorcolorcolor.bluehighlightColorBelow
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

318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

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

Bollinger Bands Force

by harryguiacorn
219 stars

This indicator modifies standard Bollinger Bands to measure directional trend force based on line alignment. It calculates a simple moving average basis along with upper and lower volatility bands. When all three lines move upward or downward simultaneously, i

Indicator v5 Volatility & bandsTrend
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Force

Adaptive MA Slope

by capissimo
114 stars

This indicator calculates Kaufman's Adaptive Moving Average (KAMA) on a chosen price source and determines trend direction based on the slope across a configurable lookback window. Signals can be filtered by short-term volatility expansion using ATR comparison

Indicator v4 Moving averagesTrend
Updated 1 year ago · None stated GitHub repository of Adaptive MA Slope

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