Indicator · Pine Script v5 · On the chart

Zen ATH Bands

by Zen-Tim

Zen ATH Bands calculates the all-time high or current price of an asset and projects horizontal reference lines representing percentage pullback levels.

View on GitHub

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

82 lines of Pine Script v5 from indicators/Zen-ATH-Bands/Zen_ATH_Bands_v2.0_20260424.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

Zen_ATH_Bands_v2.0_20260424.txt
//@version=5
indicator("Zen ATH Bands v2.0", overlay=true)

// ============================================================================
//  Zen ATH Bands v2.0 · 20260424
//  Plots the all-time high (ATH) and a configurable ladder of percentage
//  pullback levels below it. Seven independently-toggleable levels with
//  customisable % offsets and colours. Useful for cash indices and other
//  instruments where ATH and its higher-timeframe pullback zones matter.
//
//  Reference write-up:
//  https://zentradingtech.com/2025/12/19/cash-indices-and-higher-time-frame-pullbacks/
// ============================================================================

// -------- Inputs --------
refMode    = input.int(1, "Reference (0=Last price, 1=ATH)", minval=0, maxval=1)
offsetBars = input.int(30, "Right offset (bars)", minval=5, maxval=200)

// --- Level Percentages ---
showATH = input.bool(true, "Show ATH line", group="Level 0")
clrATH  = input.color(color.teal, "ATH Color", group="Level 0")

show1   = input.bool(true, "Show Level 1", group="Level 1")
p1      = input.float(2.5, "Level 1 % Down", minval=0, step=0.5, group="Level 1")
clr1    = input.color(color.green, "Color 1", group="Level 1")

show2   = input.bool(true, "Show Level 2", group="Level 2")
p2      = input.float(5.0, "Level 2 % Down", minval=0, step=0.5, group="Level 2")
clr2    = input.color(color.lime, "Color 2", group="Level 2")

show3   = input.bool(true, "Show Level 3", group="Level 3")
p3      = input.float(10.0, "Level 3 % Down", minval=0, step=0.5, group="Level 3")
clr3    = input.color(color.orange, "Color 3", group="Level 3")

show4   = input.bool(true, "Show Level 4", group="Level 4")
p4      = input.float(15.0, "Level 4 % Down", minval=0, step=0.5, group="Level 4")
clr4    = input.color(color.red, "Color 4", group="Level 4")

show5   = input.bool(true, "Show Level 5", group="Level 5")
p5      = input.float(20.0, "Level 5 % Down", minval=0, step=0.5, group="Level 5")
clr5    = input.color(color.maroon, "Color 5", group="Level 5")

show6   = input.bool(true, "Show Level 6", group="Level 6")
p6      = input.float(25.0, "Level 6 % Down", minval=0, step=0.5, group="Level 6")
clr6    = input.color(color.purple, "Color 6", group="Level 6")

show7   = input.bool(true, "Show Level 7", group="Level 7")
p7      = input.float(30.0, "Level 7 % Down", minval=0, step=0.5, group="Level 7")
clr7    = input.color(color.gray, "Color 7", group="Level 7")

// -------- Exact ATH Calculation --------
var float ath = na
ath := na(ath[1]) ? high : math.max(ath[1], high)

// Reference Selection
ref = refMode == 0 ? close : ath

// -------- Helper Function --------
f_line_and_label(_cond, _perc, _clr) =>
    if _cond
        float _lvl = ref * (1 - (_perc / 100))
        string _txt = str.tostring(_perc) + "%"
        line.new(bar_index, _lvl, bar_index + 1, _lvl, extend=extend.right, color=_clr, width=2)
        label.new(bar_index + offsetBars, _lvl, _txt + " (" + str.tostring(_lvl, format.mintick) + ")",
             textcolor=color.white, style=label.style_label_right, color=_clr)

// -------- Execution (Draw once on the last bar) --------
if barstate.islastconfirmedhistory
    // Handle ATH separately as it's 0% offset
    if showATH
        line.new(bar_index, ref, bar_index + 1, ref, extend=extend.right, color=clrATH, width=2)
        label.new(bar_index + offsetBars, ref, "ATH (" + str.tostring(ref, format.mintick) + ")",
             textcolor=color.white, style=label.style_label_right, color=clrATH)

    // Handle Custom Levels
    f_line_and_label(show1, p1, clr1)
    f_line_and_label(show2, p2, clr2)
    f_line_and_label(show3, p3, clr3)
    f_line_and_label(show4, p4, clr4)
    f_line_and_label(show5, p5, clr5)
    f_line_and_label(show6, p6, clr6)
    f_line_and_label(show7, p7, clr7)

Overview

Zen ATH Bands draws up to seven user-defined drawdown thresholds below the baseline, complete with custom price and percentage labels offset into the chart margin. Displayed directly on the price chart, it allows traders to identify key higher-timeframe correction zones. Settings let users select the reference anchor and customize line visibility, percentage offsets, and colors.

Details

Published by

Zen-Tim on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Support & resistance

Markets

Indices, Stocks, Crypto

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
Reference (0=Last price, 1=ATH)int1refMode
Right offset (bars)int30offsetBars
Show ATH linebooltrueshowATH
ATH Colorcolorcolor.tealclrATH
Show Level 1booltrueshow1
Level 1 % Downfloat2.5p1
Color 1colorcolor.greenclr1
Show Level 2booltrueshow2
Level 2 % Downfloat5.0p2
Color 2colorcolor.limeclr2
Show Level 3booltrueshow3
Level 3 % Downfloat10.0p3
Show all 25 settings
SettingTypeDefaultVariable
Color 3colorcolor.orangeclr3
Show Level 4booltrueshow4
Level 4 % Downfloat15.0p4
Color 4colorcolor.redclr4
Show Level 5booltrueshow5
Level 5 % Downfloat20.0p5
Color 5colorcolor.maroonclr5
Show Level 6booltrueshow6
Level 6 % Downfloat25.0p6
Color 6colorcolor.purpleclr6
Show Level 7booltrueshow7
Level 7 % Downfloat30.0p7
Color 7colorcolor.grayclr7
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

948 stars

Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us

Indicator v4 Moving averagesSupport & resistance
Updated 10 days ago · GPL-3.0 GitHub repository of Moving Average Channel

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows
330 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 2 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur

Indicator v5 VolumeSupport & resistance
Updated 2 months ago · MIT GitHub repository of Volume Profile and Indicator by DGT

BZ-tracker

by Allen1212
303 stars

The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on

Indicator v4 Support & resistanceScreeners & dashboards
Updated 2 years ago · None stated GitHub repository of BZ-tracker

Function - Linear Regression

by ricardosantos79
261 stars

This indicator fits a linear regression through stored pivot highs and lows and draws the resulting channel on the price chart. A function returns predicted values, maximum and minimum deviations, and the average absolute deviation. Confirmed two-bar pivots up

Indicator v5 TrendSupport & resistance
Updated 4 years ago · None stated GitHub repository of Function - 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