Indicator · Pine Script v6 · On the chart

ADR label

by etnt· code credited to kruskakli

This indicator calculates and displays the Average Daily Range percentage alongside a Mark Minervini Trend Template score in an on-screen table.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code125
Settings6inputs
LicenceMPL-2.0
Last update1 year ago3 Aug 2025

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

125 lines of Pine Script v6 from PineScript/adr-label.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

adr-label.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kruskakli
//
// To quote @qullamaggie: " High ADR is Gold, low ADR is shit..."
// Hence we display the ADR (Average Daily Range) in percent.
//
// We also calculates the Trend Template as described by Mark Minervini in his book: "Trade like a stock market wizard"
// For a stock to be considered all the rules has to be fullfilled.
// The only rule this indicator doesn't implement is the IBD Relative Strength ranking.
//
// Rules:
//  close > MA-50 > MA-150 > MA-200 , each condition that is true gets one point.
//  The current stock price is at least 30 percent above its 52-week low, gets one point
//  The current stock price is within at least 25 percent of its 52-week high, gets one point.
//  The 200-day moving average line is trending up for at least 1 month (preferably 4–5 months), gets one point.
//
// When we get 6 points, all the rules are fullfilled and we display an OK;
// else we show the number of points (X).
//
// We also display the percentage change of two selected Indices.
//
//@version=6
indicator("ADR label", overlay=true)

// Change in percent
cpt(_x, _x1) =>
    _cpt = ((_x / _x1) - 1)
    _cpt


ix = input.symbol(defval="OMXSPI", title="Index")
ix_open = request.security(syminfo.tickerid, timeframe.period, open)
ix_close = request.security(syminfo.tickerid, "5M", close)
ix_change = math.round(cpt(ix_close, ix_open), 2)


// User selectable colors.
text_col = input(defval=color.yellow, title="Table Color" )
value_col = input(defval=color.white, title="Value Color" )
bad_col = input(defval=color.red, title="Bad Value Color")

text_sz = size.small

src = close


//
// TREND TEMPLATE calculation
//
ma50 = ta.sma(src, 50)
ma150 = ta.sma(src, 150)
ma200 = ta.sma(src, 200)

week = request.security(syminfo.tickerid, "W", close)
week52low = ta.lowest(week, 52)
week52high = ta.highest(week, 52)

float monotonic = na
monotonic := (ma200[0] > ma200[1]) ? 1 :0

int tq = 0
tq_gt(_s1, _s2, _tq) =>
    if (_s1 > _s2)
        _tq + 1
    else
        _tq - 1

// Rule 1,2,4,5
tq := tq_gt(src, ma50,  tq)
tq := tq_gt(ma50,  ma150, tq)
tq := tq_gt(ma150, ma200, tq)
// Rule 3 (using 50 days, i.e 10 weeks or 2.5 months)
tq := (math.sum(monotonic, 50) == 50) ? tq + 1 : tq
// Rule 6
tq := (src * 1.3) > week52low ? tq + 1 : tq
// Rule 7
tq := src > (week52high * 0.75) ? tq + 1 : tq

// Construct the TrendTemplate string
//TTstr = tq == 6 ? "TT:OK" : "TT(" + tostring(tq, "#") + ")"
TTstr = tq == 6 ? "OK" : str.tostring(tq, "#")
TTstrColor = tq == 6 ? value_col : bad_col

// 
// ADR% calculation
//
// Original: alpine_trader
// Amended 08/12/20 by TheScrutiniser, MikeC on advise from GlinckEastwoot
Length = input(20, title="ADR length")
dhigh = request.security(syminfo.tickerid, 'D', high)
dlow  = request.security(syminfo.tickerid, 'D', low)
// formula amended, thanks to GlinckEastwoot
ADR = 100 * (ta.sma(dhigh/dlow, Length) - 1)
ADRstr = str.tostring(math.round(ADR,2)) + "%"


//
// Construct the Table
//
tabLoc = input.string(title="Table Location", defval="Upper Right", options=["Upper Right","Middle Right","Lower Right"])
tabPos = (tabLoc == "Upper Right") ? position.top_right : (tabLoc == "Middle Right") ? position.middle_right : position.bottom_right

table t = table.new(tabPos, 4, 4)
if barstate.islast and timeframe.period != "W" and timeframe.period != "M"
    table.cell(t, 0, 0, "", text_halign=text.align_right, text_size=text_sz, text_color=text_col)
    table.cell(t, 1, 0, "", text_halign=text.align_left, text_size=text_sz, text_color=value_col)
    table.cell(t, 2, 0, "", text_halign=text.align_left, text_size=text_sz, text_color=text_col)
    table.cell(t, 3, 0, "", text_halign=text.align_left, text_size=text_sz, text_color=TTstrColor)

    table.cell(t, 0, 1, ix, text_halign=text.align_right, text_size=text_sz, text_color=color.green)
    table.cell(t, 1, 1, "", text_halign=text.align_left, text_size=text_sz, text_color=value_col)
    table.cell(t, 2, 1, "", text_halign=text.align_left, text_size=text_sz, text_color=text_col)
    table.cell(t, 3, 1, str.tostring(ix_change) + "%", text_halign=text.align_left, text_size=text_sz, text_color=text_col)
    table.merge_cells(t, 0, 1, 2, 1)

    table.cell(t, 0, 2, "ADR%:", text_halign=text.align_right, text_size=text_sz, text_color=text_col)
    table.cell(t, 1, 2, ADRstr, text_halign=text.align_left, text_size=text_sz, text_color=value_col)
    table.cell(t, 2, 2, "TT:", text_halign=text.align_right, text_size=text_sz, text_color=text_col)
    table.cell(t, 3, 2, TTstr, text_halign=text.align_left, text_size=text_sz, text_color=TTstrColor)

    table.cell(t, 0, 3, syminfo.sector, text_halign=text.align_right, text_size=text_sz, text_color=color.green)
    table.cell(t, 1, 3, "", text_halign=text.align_left, text_size=text_sz, text_color=value_col)
    table.cell(t, 2, 3, "", text_halign=text.align_left, text_size=text_sz, text_color=text_col)
    table.cell(t, 3, 3, "", text_halign=text.align_left, text_size=text_sz, text_color=TTstrColor)
    table.merge_cells(t, 0, 3, 3, 3)

Overview

ADR label evaluates moving average alignments, 52-week price extremes, and moving average slope criteria to generate a Trend Template rank. Additionally, it displays percentage changes for selected indices. The metrics and overall status are drawn directly in an overlay table on the main price chart.

Details

Published by

etnt on GitHub

Code credit

kruskakli, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Screeners & dashboards, Trend, Volatility & bands

Markets

Stocks

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
IndexsymbolOMXSPIix
Table Colorcolorcolor.yellowtext_col
Value Colorcolorcolor.whitevalue_col
Bad Value Colorcolorcolor.redbad_col
ADR lengthint20Length
Table LocationstringUpper RighttabLoc
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

92 stars

This indicator classifies the market into gamma regime types (negative gamma trend, positive gamma mean-reversion, or transition) by calculating a composite score based on daily ATR ratios, session VWAP crossover frequencies, and opening range displacement. It

Indicator v5 Volatility & bandsTrend
Updated 8 weeks ago · Custom licence GitHub repository of Moon Dev GEX Regime & Trap
46 stars

This indicator uses a Hidden Markov Model (HMM) framework combined with an adaptive dual moving average engine and Directional Movement Index (DMI) features to identify market regimes (bullish, bearish, or ranging/chop). It calculates regime probabilities on e

Indicator v5 AI / machine learningTrend
Updated 7 weeks ago · None stated GitHub repository of HMM Enhanced: Regime Probability
43 stars

This indicator calculates standardized trend strength and historical volatility to estimate position sizes. It computes the differences between three user-defined EMAs standardized by price using MACD logic, while historical volatility is derived from the stan

Indicator v5 TrendVolatility & bands
Updated 1 year ago · None stated GitHub repository of Trend Strength & Volatility v2

This overlay indicator plots a SuperTrend-style band on the price chart using ATR length, a selectable source, and a base factor. Optional settings enable an adaptive factor driven by rate of change, a volatility filter, K-means clustering, and an LSTM layer w

Indicator v6 TrendVolatility & bands
Updated 4 months ago · MIT GitHub repository of ML SuperTrend (Ultimate) - Auto-Optimized AI with LSTM

Adaptive Fair Value Cloud calculates a volatility-adaptive fair value channel around a selectable centerline, such as KAMA, EMA, linear regression, or VWMA. It blends ATR and mean deviation with volatility percentiles and trend sensors, including ADX, Efficien

Indicator v6 Volatility & bandsTrend
Updated yesterday · MIT GitHub repository of Adaptive Fair Value Cloud [WavesUnchained]

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