Indicator · Pine Script v5 · On the chart

All-Time High/Low

by regalouisei· code credited to QuantNomad

This indicator tracks the all-time high and all-time low of the current symbol from daily data.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code83
Settings3inputs
LicenceNone statedfile: MPL-2.0
Last update8 months ago25 Feb 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

83 lines of Pine Script v5 from pinescript/editors_picks/all-time-highlow-widget.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

all-time-highlow-widget.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © QuantNomad

//@version=5
indicator('All-Time High/Low', shorttitle='ATH/ATL', overlay=true)

////////////
// INPUTS //

show_ath   = input(true,  "Show All Time High?")
show_atl   = input(false, "Show All Time Low?")
show_table = input(true,  "Show table with stats?")

///////////////
// FUNCTIONS //

// all-time high function
get_all_time_high() =>
    h  = 0.0
    t  = 0
    h := bar_index == 0 ? high : high > h[1] ? high : h[1]
    t := bar_index == 0 ? time : high > h[1] ? time : t[1]
    [h, t]

// all-time low function   
get_all_time_low() =>
    l = 0.0
    t = 0
    l := bar_index == 0 ? low  : low < l[1] ? low  : l[1]
    t := bar_index == 0 ? time : low < l[1] ? time : t[1]
    [l, t]

// getting all-time high/low    
[ath, ath_dt] = request.security(syminfo.tickerid, 'D', get_all_time_high())
[atl, atl_dt] = request.security(syminfo.tickerid, 'D', get_all_time_low())

ath_days = math.round((timenow - ath_dt) / 86400000)
atl_days = math.round((timenow - atl_dt) / 86400000)

// plotting
if show_ath
    lATH=line.new(bar_index - 1, ath, bar_index, ath, extend = extend.both, color = color.green)
    line.delete(lATH[1])
    
if show_atl
    lATL=line.new(bar_index - 1, atl, bar_index, atl, extend = extend.both, color = color.red)
    line.delete(lATL[1])

if show_table
    var table ATHtable = table.new(position.bottom_right, 6, 3, frame_color = color.gray, bgcolor = color.gray, border_width = 1, frame_width = 1, border_color = color.white)

    ath_time = str.tostring(year(ath_dt)) + "-" + str.tostring(month(ath_dt)) + "-" + str.tostring(dayofmonth(ath_dt))
    atl_time = str.tostring(year(atl_dt)) + "-" + str.tostring(month(atl_dt)) + "-" + str.tostring(dayofmonth(atl_dt))

    // Header
    table.cell(ATHtable, 0, 0, "",         bgcolor = #cccccc)
    table.cell(ATHtable, 1, 0, "When?",    bgcolor = #cccccc)
    table.cell(ATHtable, 2, 0, "Days ago", bgcolor = #cccccc)
    table.cell(ATHtable, 3, 0, "Price",    bgcolor = #cccccc)
    table.cell(ATHtable, 4, 0, "% away",   bgcolor = #cccccc)
    table.cell(ATHtable, 5, 0, "$ away",   bgcolor = #cccccc)
    
    if (show_ath)
        // ATH
        table.cell(ATHtable, 0, 1, "ATH",                                                  bgcolor = #cccccc)
        table.cell(ATHtable, 1, 1, ath_time,                                               bgcolor = color.new(color.green, transp = 50))
        table.cell(ATHtable, 2, 1, str.tostring(ath_days),                                 bgcolor = color.new(color.green, transp = 50))
        table.cell(ATHtable, 3, 1, str.tostring(ath, format.mintick),                      bgcolor = color.new(color.green, transp = 50))
        table.cell(ATHtable, 4, 1, str.tostring(((ath / close) - 1) * 100 , "#.##") + "%", bgcolor = color.new(color.green, transp = 50))
        table.cell(ATHtable, 5, 1, str.tostring(ath - close , format.mintick),             bgcolor = color.new(color.green, transp = 50))
    
    if (show_atl)
        // ATL
        table.cell(ATHtable, 0, 2, "ATL",                                                  bgcolor = #cccccc)
        table.cell(ATHtable, 1, 2, atl_time,                                               bgcolor = color.new(color.red, transp = 50))
        table.cell(ATHtable, 2, 2, str.tostring(atl_days),                                 bgcolor = color.new(color.red, transp = 50))
        table.cell(ATHtable, 3, 2, str.tostring(atl, format.mintick),                      bgcolor = color.new(color.red, transp = 50))
        table.cell(ATHtable, 4, 2, str.tostring(((atl / close) - 1) * 100 , "#.##") + "%", bgcolor = color.new(color.red, transp = 50))
        table.cell(ATHtable, 5, 2, str.tostring(atl - close, format.mintick),              bgcolor = color.new(color.red, transp = 50))

// alerts
alertcondition(ta.crossover(high, ath), 'All-time High!', 'All-time High!')
alertcondition(ta.crossunder(low, atl), 'All-time Low!',  'All-time Low!')

Overview

All-Time High/Low draws optional green and red horizontal lines across the price chart and can show a table with each extreme’s date, days elapsed, price, percent distance from the close, and absolute price distance. Inputs switch the high line, low line, and table on or off. The low line is off by default. It does not generate trade signals or exits.

Details

Published by

regalouisei on GitHub

Code credit

QuantNomad, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Support & resistance, Screeners & dashboards

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 All Time High?booltrueshow_ath
Show All Time Low?boolfalseshow_atl
Show table with stats?booltrueshow_table
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

575 stars

This overlay indicator scans a pasted list of symbols for ICT liquidity sweep patterns using prior swing sweeps. The screening method looks back one, two, or three swings and can list long and short signals in a results table with adjustable rows, position, an

Indicator v5 SMC / ICT / price actionScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Liquidity Sweep Pattern Scanner
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]

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
257 stars

This indicator overlays an intraday SPX and ES chart with a midnight session range, regular-trading-hours opening levels, and a VWAP projection box. It draws the midnight high, mid, and low, flags edge rejections within an absolute tolerance, and plots optiona

Indicator v6 TrendSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of SPX Midnight Box + Snag Logic

Golden Bullet Strategy

by TradersPost
218 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

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