Indicator · Pine Script v5 · On the chart

Earnings & Fundamentals Dashboard

by ankurksoni· code credited to finallynitin & © EquityCraze

A table overlay on the price chart, short title Fundamentals, that shows company financial data pulled with TradingView's financial data requests.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code192
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update2 days ago27 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

192 lines of Pine Script v5 from trading view/financials.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

financials.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © finallynitin & © EquityCraze
// Modified to include comprehensive header (MCap, ROE, ROCE, Listed, 10:20 EMA), QoQ metrics, OPM%, and P/E

//@version=5
indicator('Earnings & Fundamentals Dashboard', shorttitle='Fundamentals', overlay=true)

//════════ Table Options ═════════
string GRP1 = "════════ Modes ═════════"
toggleMiniMode = input(title="Mini Mode", defval=false, group = GRP1, tooltip = 'Select this to get the Mini mode where the values are replaced by traffic lights for a quick visual')
datasize = input.int(4, 'Long Mode ?', minval = 4, inline='line 3', group=GRP1, tooltip = 'Input the number of previous quarters to be displayed in the table') + 5

string GRP2 = "════════ Table Options ═════════"
string tablesize = input.string("normal", "Size", inline = "21", group = GRP2, options = ["tiny", "small", "normal", "large", "huge", "auto"])
string tableposY = input.string("bottom", "↕", inline = "21", group = GRP2, options = ["top", "middle", "bottom"])
string tableposX = input.string("right", "↔", inline = "21", group = GRP2, options = ["left", "center", "right"])
float bottomGap = input.float(8.0, "Bottom Gap (% of chart height)", minval = 0.0, maxval = 40.0, step = 1.0, group = GRP2, tooltip = 'Empty space under the table when it is placed at the bottom, so it clears the chart\'s earnings/volume markers')

string GRP3 = "════════ Inputs ═════════"
emaLookback = input.int(252, 'EMA Support Lookback Bars', minval=10, maxval=2000, group=GRP3)
per = input.string('FQ', 'Period', options=['FQ', 'FY'], inline='line 3', group=GRP3, tooltip = 'Option to change the data from Quarterly (FQ) to Yearly (FY)')

//════════ Colors (dark theme) ═════════
FrameCol = color.rgb(54, 58, 69)         // outer frame
BorderCol = color.rgb(42, 46, 57)        // subtle cell dividers
TextColor = color.white
BGColor = color.rgb(19, 23, 34)          // panel background
HeadColor = color.rgb(30, 34, 45)        // header rows
BodyColor = color.rgb(19, 23, 34)        // data rows
UpColor = color.rgb(144, 224, 160)       // light green
DownColor = color.rgb(255, 138, 138)     // light red
UnchangedColor = color.rgb(178, 181, 190) // neutral grey

//════════ Financial IDs ═════════
financial01id = 'EARNINGS_PER_SHARE_DILUTED'
financial02id = 'TOTAL_REVENUE'
financial03id = 'OPERATING_MARGIN'

//════════ Functions ═════════
getFinFQ(_id, _per) => 
    _financials = request.financial(syminfo.tickerid, _id, _per, barmerge.gaps_on, ignore_invalid_symbol = true)
    if _id == financial02id 
        _financials := math.round(_financials / 10.0, 2)
    _financials

f_array(arrayId, val) => 
    array.unshift(arrayId, val)
    array.pop(arrayId)

// Data fetching
rev = request.financial(syminfo.tickerid, 'TOTAL_REVENUE', per, barmerge.gaps_on, ignore_invalid_symbol=true)

finData1 = getFinFQ(financial01id, per)
finData2 = getFinFQ(financial02id, per)
finData3 = getFinFQ(financial03id, per)
// P/E = price at result date / TTM diluted EPS (the built-in PRICE_EARNINGS_RATIO is often unavailable)
epsTtmPE = request.financial(syminfo.tickerid, financial01id, 'TTM', barmerge.gaps_on, ignore_invalid_symbol = true)
finData4 = na(epsTtmPE) or epsTtmPE <= 0 ? na : close / epsTtmPE

var date = array.new_int(datasize)
var arrayFinData1 = array.new_float(datasize) // EPS
var arrayFinData2 = array.new_float(datasize) // Sales
var arrayFinData3 = array.new_float(datasize) // OPM
var arrayFinData4 = array.new_float(datasize) // PE

if rev
    f_array(date, time)
    f_array(arrayFinData1, finData1)
    f_array(arrayFinData2, finData2)
    f_array(arrayFinData3, finData3)
    f_array(arrayFinData4, finData4)

// Standard cell drawing
ftdate(_table, _column, _row, _value) => 
    _new_value = str.contains(_value, "70") ? "" : _value
    table.cell(table_id = _table, column = _column, row = _row, text = _new_value, bgcolor = BodyColor, text_color = TextColor, text_size = tablesize, text_halign = text.align_left)

fcell(isEps, _table, _column, _row, _value, _i, _isPct=false, _isFloat=false) =>  
    val = array.get(_value, _i)
    if not isEps and not _isPct and not _isFloat
        val := val / 1000000 // Convert Sales to Millions
    
    strFormat = isEps ? '#.#' : _isPct ? '#.##' : _isFloat ? '#.#' : '#,###.#'
    suffix = _isPct ? '%' : ''
    
    // For OPM%, it returns as a decimal, multiply by 100
    if _isPct and not na(val)
        val := val * 100
        
    table.cell(table_id = _table, column = _column, row = _row, text = na(val) ? "" : str.tostring(val, strFormat) + suffix, text_color = TextColor, text_size = tablesize, bgcolor = BodyColor, text_halign = text.align_right)

// YoY/QoQ Calculation and Cell drawing
fchange(_table, _column, _row, _value, _i, _cmpr) =>  
    sym = ""  
    dif = 0.0 
    if na(_value)
        na
    else
        val1 = array.get(_value, _i)
        val2 = array.get(_value, _i + _cmpr)
        val1 := val1 == 0 ? 1 : val1
        val2 := math.round(val2, 1) == 0 or math.round(val2, 1) == -0 ? 0.1 : val2
        dif := math.round(((val1 - val2) / math.abs(val2)) * 100)
        sym := na(dif) ? "" : dif > 0 ? '+' + str.tostring(dif) + '%' : str.tostring(dif) + '%'

    cell_color = na(dif) ? FrameCol : dif > 0 ? UpColor : dif < 0 ? DownColor : UnchangedColor
    table.cell(table_id = _table, column = _column, row = _row, text = na(dif) ? "●" : toggleMiniMode ? "●" : sym, text_halign = text.align_right, text_color = cell_color, text_size = tablesize, bgcolor = BodyColor)

//════════ Meta Header Calculations ═════════
outstanding = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")
mc = outstanding * close / 10000000
validated_mc = na(mc) or nz(mc) == 0 ? 'N/A' : str.tostring(math.round(mc, 0)) + ' Cr'

// ROE = Net Income (TTM) / Total Equity (latest quarter)
niTtm = request.financial(syminfo.tickerid, "NET_INCOME", "TTM", ignore_invalid_symbol=true)
totEquity = request.financial(syminfo.tickerid, "TOTAL_EQUITY", "FQ", ignore_invalid_symbol=true)
roe = na(niTtm) or na(totEquity) or totEquity == 0 ? na : niTtm / totEquity * 100
validated_roe = na(roe) ? 'N/A' : str.tostring(math.round(roe, 1)) + '%'

// ROCE = EBIT (TTM) / Capital Employed (Total Assets - Current Liabilities, latest quarter)
ebitTtm = request.financial(syminfo.tickerid, "PRETAX_INCOME", "TTM", ignore_invalid_symbol=true)
totAssets = request.financial(syminfo.tickerid, "TOTAL_ASSETS", "FQ", ignore_invalid_symbol=true)
curLiab = request.financial(syminfo.tickerid, "TOTAL_CURRENT_LIABILITIES", "FQ", ignore_invalid_symbol=true)
capEmployed = na(totAssets) or na(curLiab) ? na : totAssets - curLiab
roce = na(ebitTtm) or na(capEmployed) or capEmployed == 0 ? na : ebitTtm / capEmployed * 100
validated_roce = na(roce) ? 'N/A' : str.tostring(math.round(roce, 1)) + '%'

// Listed year, taken from the first available bar
var int firstYear = na
if na(firstYear)
    firstYear := year(time)
validated_listed = na(firstYear) ? 'N/A' : str.tostring(firstYear)

// 10:20 EMA = EMA10 support touches / EMA20 support touches over the lookback
ema10 = ta.ema(close, 10)
ema20 = ta.ema(close, 20)
ema10Touches = math.sum(low < ema10 and close > ema10 ? 1.0 : 0.0, emaLookback)
ema20Touches = math.sum(low < ema20 and close > ema20 ? 1.0 : 0.0, emaLookback)
validated_ema = na(ema20Touches) or ema20Touches == 0 ? 'N/A' : str.tostring(math.round(ema10Touches / ema20Touches * 100)) + '%'

string header1 = "MCap " + validated_mc + " | ROE " + validated_roe + " | ROCE " + validated_roce + " | Listed " + validated_listed + " | 10:20 " + validated_ema
string header2 = syminfo.sector + " | " + syminfo.industry

//════════ Table Creation ═════════
var table t = table.new(tableposY + "_" + tableposX, columns = 9, rows = datasize + 3, bgcolor = BGColor)

if barstate.islast

    // Spacer row: lifts a bottom-anchored table above the chart's earnings / volume markers
    if tableposY == "bottom" and bottomGap > 0
        table.cell(t, 0, datasize + 2, "", height = bottomGap, bgcolor = color.new(BGColor, 100))

    // Top Header Rows
    table.merge_cells(t, 0, 0, 8, 0)
    table.cell(t, 0, 0, header1, text_color = TextColor, text_size = tablesize, bgcolor = HeadColor, text_halign = text.align_center)
    
    table.merge_cells(t, 0, 1, 8, 1)
    table.cell(t, 0, 1, header2, text_color = TextColor, text_size = tablesize, bgcolor = HeadColor, text_halign = text.align_center)

    // Column Headers
    table.cell(t, 0, 2, per, text_color=TextColor, bgcolor=HeadColor, text_size=tablesize)
    table.cell(t, 1, 2, "EPS", text_color=TextColor, bgcolor=HeadColor, text_size=tablesize, text_halign=text.align_right)
    table.cell(t, 2, 2, per == 'FY' ? 'YoY' : 'YoY', text_color=TextColor, bgcolor=HeadColor, text_size=tablesize, text_halign=text.align_right)
    table.cell(t, 3, 2, "QoQ", text_color=TextColor, bgcolor=HeadColor, text_size=tablesize, text_halign=text.align_right)
    table.cell(t, 4, 2, "Sales", text_color=TextColor, bgcolor=HeadColor, text_size=tablesize, text_halign=text.align_right)
    table.cell(t, 5, 2, per == 'FY' ? 'YoY' : 'YoY', text_color=TextColor, bgcolor=HeadColor, text_size=tablesize, text_halign=text.align_right)
    table.cell(t, 6, 2, "QoQ", text_color=TextColor, bgcolor=HeadColor, text_size=tablesize, text_halign=text.align_right)
    table.cell(t, 7, 2, "OPM%", text_color=TextColor, bgcolor=HeadColor, text_size=tablesize, text_halign=text.align_right)
    table.cell(t, 8, 2, "P/E", text_color=TextColor, bgcolor=HeadColor, text_size=tablesize, text_halign=text.align_right)

    if not toggleMiniMode
        for i = 0 to datasize-5
            int r = i + 3
            ftdate(t, 0, r, str.format('{0, date, MMM-yy}', array.get(date, i))) // Date
            fcell(true, t, 1, r, arrayFinData1, i)                               // EPS
            fchange(t, 2, r, arrayFinData1, i, per == 'FY' ? 1 : 4)              // EPS YoY
            fchange(t, 3, r, arrayFinData1, i, 1)                                // EPS QoQ
            fcell(false, t, 4, r, arrayFinData2, i)                              // Sales
            fchange(t, 5, r, arrayFinData2, i, per == 'FY' ? 1 : 4)              // Sales YoY
            fchange(t, 6, r, arrayFinData2, i, 1)                                // Sales QoQ
            fchange(t, 7, r, arrayFinData3, i, per == 'FY' ? 1 : 4)              // OPM% Change formatted like image
            fcell(false, t, 8, r, arrayFinData4, i, false, true)                 // P/E Ratio

    else if toggleMiniMode
        for i = 0 to datasize-5
            int r = i + 3
            ftdate(t, 0, r, str.format('{0, date, MMM-yy}', array.get(date, i)))
            fchange(t, 2, r, arrayFinData1, i, per == 'FY' ? 1 : 4)
            fchange(t, 3, r, arrayFinData1, i, 1)
            fchange(t, 5, r, arrayFinData2, i, per == 'FY' ? 1 : 4)
            fchange(t, 6, r, arrayFinData2, i, 1)
            fchange(t, 7, r, arrayFinData3, i, per == 'FY' ? 1 : 4)

Overview

Earnings & Fundamentals Dashboard lists diluted earnings per share, total revenue and operating margin for recent quarters or years, with quarter-on-quarter changes coloured up, down or unchanged. A trailing earnings-based price to earnings figure and an EMA support measure are included. Mini mode swaps values for traffic-light colours. Settings choose quarterly or yearly data, how many periods to show and the table size and position. It suits stocks and shows nothing for symbols without financial data.

Details

Published by

ankurksoni on GitHub

Code credit

finallynitin & © EquityCraze, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Screeners & dashboards

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
Mini ModeboolfalsetoggleMiniMode
Long Mode ?int4datasize
Sizestringnormaltablesize
↕stringbottomtableposY
↔stringrighttableposX
Bottom Gap (% of chart height)float8.0bottomGap
EMA Support Lookback Barsint252emaLookback
PeriodstringFQper
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

Symbol Info Helper

by everget
948 stars

Symbol Info Helper is an informational utility script that displays metadata about the currently selected instrument directly on the main price chart. It gathers built-in symbol properties including ticker identifier, description, instrument type, point value,

Indicator v4 Screeners & dashboards
Updated 11 days ago · GPL-3.0 GitHub repository of Symbol Info Helper
575 stars

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator
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]

Pricing Table

by namuan
318 stars

This indicator calculates theoretical options contract values and in-the-money probabilities using historical realized volatility across multiple standard deviations. It displays these metrics in a table overlay directly on the price chart. Users can adjust th

Indicator v4 Volatility & bandsScreeners & dashboards
Updated 2 months ago · MIT GitHub repository of Pricing Table

3938 Tracker

by Allen1212
303 stars

3938 Tracker visualizes historical buying and selling activity from ARK Invest funds directly on the main price chart. It plots labels at specific timestamps corresponding to trade dates, indicating buy or sell actions along with the count of participating ETF

Indicator v4 Screeners & dashboards
Updated 2 years ago · None stated GitHub repository of 3938 Tracker

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