Indicator · Pine Script v5 · On the chart

Quick Stats

by etnt· code credited to kruskakli

Quick Stats displays key trading metrics directly on the price chart overlay.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code135
Settings5inputs
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

135 lines of Pine Script v5 from PineScript/quick-stats.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

quick-stats.pine
//@version=5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kruskakli
//
// Quick Stats - shows some important info at the top right corner
//
// 1. We display the percentage change of two selected Indices.
//
// 2. ADR% - Average Daily Range in percent
// To quote @qullamaggie: " High ADR is Gold, low ADR is shit..."
//
// 3. Trend Template - indicate if the stock is in a good Up Trend
// We 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).
//
indicator("Quick Stats", overlay=true)

// Use Green/Red that works for a color blind!
green1 = color.new(#00ff00, 0)
green2 = color.new(#00ee00, 0)
green3 = color.new(#00cd00, 0)

orangered1 = color.new(#ff4500, 0)
orangered2 = color.new(#ee4000, 0)
orangered3 = color.new(#cd3700, 0)

// User selectable colors.
text_col = input(title="Text Color",     defval=color.white)
bad_col = input(title="Bad Value Color", defval=orangered1)

text_sz = size.small

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

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

sma50 = request.security(syminfo.tickerid,  "1D", ma50,  gaps=barmerge.gaps_on)
sma150 = request.security(syminfo.tickerid, "1D", ma150, gaps=barmerge.gaps_on)
sma200 = request.security(syminfo.tickerid, "1D", ma200, gaps=barmerge.gaps_on)

w52low = ta.lowest(src, 52)
w52high = ta.highest(src, 52)
week52low = request.security(syminfo.tickerid, "W", w52low)
week52high = request.security(syminfo.tickerid, "W", w52high)

float monotonic = na
monotonic := (sma200[0] > sma200[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, sma50,  tq)
tq := tq_gt(sma50,  sma150, tq)
tq := tq_gt(sma150, sma200, 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, "#")
tt_col= tq == 6 ? text_col : bad_col

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



//
// Get info for 2 selected Indices
//
indexId1 = input.symbol(defval="OMXSPI", title="Symbol 1")
indexId2 = input.symbol(defval="SPX", title="Symbol 2")
indexSerie1 = request.security(indexId1, "D", close)
indexSerie1prev = indexSerie1[1]
indexSerie2 = request.security(indexId2, "D", close)
indexSerie2prev = request.security(indexId2, "D", close[1])
indexChangePercent1 = cpt(indexSerie1, indexSerie1prev)
indexChangePercent2 = cpt(indexSerie2, indexSerie2prev)
xcpStr1 = str.tostring(math.round(indexChangePercent1, 2))
xcpStr2 = str.tostring(math.round(indexChangePercent2, 2))
xcpStr = indexId1 + ": " + xcpStr1 + "% , " + indexId2 + ": " + xcpStr2 + "%"
ix1_col = indexChangePercent1 < 0 ? bad_col : text_col
ix2_col = indexChangePercent2 < 0 ? bad_col : text_col



//
// Construct the Table
//
tabPos = position.top_right

table t = table.new(tabPos, 4, 1, frame_color=color.gray, frame_width=1, border_color=color.gray, border_width=1)
if barstate.islast
    //   
    table.cell(t, 0, 0, indexId1 + ": " + xcpStr1 + "%", text_halign=text.align_center, text_size=text_sz, text_color=ix1_col)
    table.cell(t, 1, 0, indexId2 + ": " + xcpStr2 + "%", text_halign=text.align_center, text_size=text_sz, text_color=ix2_col)
    table.cell(t, 2, 0, "ADR%: " + ADRstr, text_halign=text.align_center, text_size=text_sz, text_color=text_col)
    table.cell(t, 3, 0, "TT: " + TTstr, text_halign=text.align_center, text_size=text_sz, text_color=tt_col)

Overview

Quick Stats calculates Mark Minervini's Trend Template rules by scoring moving average alignments (50, 150, and 200 SMAs), 200 SMA slope, and 52-week high/low proximities. Additionally, it computes the Average Daily Range percentage (ADR%) over a configurable period and tracks the price performance of two user-selected benchmark indices. Results are rendered as visual stats in the chart corner.

Details

Published by

etnt on GitHub

Code credit

kruskakli, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Volatility & bands, Moving averages, Screeners & dashboards

Markets

Stocks, Indices

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
Text Colorcolorcolor.whitetext_col
Bad Value Colorinputorangered1bad_col
ADR lengthint20Length
Symbol 1symbolOMXSPIindexId1
Symbol 2symbolSPXindexId2
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

43 stars

This indicator evaluates market momentum and risk by calculating trend metrics and volatility stats, displaying them in an on-chart table pane. It measures short-term and long-term trend strength via two MACD configurations built on three customizable EMA leng

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

This indicator plots a zero-lag EMA center line with ATR bands on the price chart. It marks bullish or bearish mode after closes stay beyond a band for a set number of bars and the center line slopes that way. Confirmed buy and sell labels appear only after th

Indicator v6 TrendMoving averages Repaints
Updated 3 months ago · None stated GitHub repository of GK Trend Ribbon SWING + PREPARE HUD

Calculates market volatility, velocity, dynamic VIX thresholds, and multi-timeframe directional bias to assess risk regimes for Nifty index options trading. It computes a danger score based on ATR, VIX rate of change, Bollinger Band width, and price velocity t

Indicator v5 Volatility & bandsScreeners & dashboards
Updated 13 days ago · None stated GitHub repository of NIFTY SpreadGuard V2024 - Mega-Sidebar Sniper

Calculates a Zero Lag Exponential Moving Average (ZLEMA) combined with Average True Range volatility bands to determine market trends. It plots the ZLEMA basis line, volatility bands, trend reversal labels, and entry signals directly on the price chart. Additi

Indicator v5 TrendMoving averages Repaints
Updated 5 weeks ago · None stated GitHub repository of Zero Lag Trend Signals (MTF) [AlgoAlpha]

This indicator draws a SPY scalping panel in a separate pane. It calculates a Supertrend side from ATR smoothed by a selectable average, defaulting to HMA, and uses three moving averages of selectable type, defaulting to EMA lengths 13, 50, and 75. Colors mark

Indicator v5 TrendMoving averages
Updated 5 months ago · None stated GitHub repository of J8 30 123 Spy Scalping Lower Pro 2 Jerry

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