OPEN-SOURCE SCRIPT

IDX Financials v2

Atualizado
This indicator adds financial data, ratios, and valuations to your chart. The main objective is to present financial overview that can be glanced quickly to add to your considerations.

The visualization of the indicator consists of two parts:

A. Plots (lines alongside the candlestick)
B. Financial table on the right. Drag your candlestick to the left to provide blank area for the table.

Programatically, the financial data is obtained by using these Pine API:

  • request.earnings(...) API for the EPS values that are used by the price at average PER line, and
  • request.financial(..) API for the rest of financial data required by the indicator.


See What financial data is available in Pine for more info on getting financial data in Pine.

A. THE PLOTS

The plots produces two lines, price at average PER in blue and price at average PBV line in pink, calculated over some adjustable time period (the default is one year). By default, only price at average PER line is shown.

Note that PER stands for Price to Earning Ratio.

The price at average PER line shows the price level at the average PER. It is calculated using formula as follows:

line = AVGPER * EPSTTM

where AVGPER is the average PER over some time period (default is one year, adjustable) and EPSTTM is the standardized EPS TTM.

Note that the EPS is updated at the actual time of earning report publication, and not at standard quarter dates such as March 31st, Dec 31st, etc.. This approach is chosen to represent the actual PE at the time.

The price at average PBV line (PBV stands for Price to Book Value), which can be enabled in settings, shows the price at average PBV. It is calculated using formula as follows:

line = AVGPBV * BVPS

where AVGPBV is the average PBV over some period of time (default is one year, adjustable) and BVPS is the book value per share. Note that the PBV is clipped to [0, 20] range to avoid values that are too small/large.

Also note that unlike PER, the BVPS is updated at each quarterly date (such as March 31st, Dec 31st, etc.).

Apart from those lines, some values are written to the status line (i.e. the numbers next to indicator name), which represent the corresponding value at the currently hovered bar:

  • PER TTM
  • Average PER
  • Std value (zvalue) of PER TTM (equal to = (PERTTM - AVGPER)/STDPER)
  • PBV


The meaning for these abbreviations should be straightforward.

Using the price at average PER line

There are several ways to use the price at average PER line.

You can quickly get the sense of current valuation by seeing the price relative to the price at average PER line. If the price is above the line, the valuation is higher than the average valuation, and vice versa if the price is lower.

The distance between the price and the average is measured in unit of standard deviation. This is represented by the third number in the status line. Value zero indicates the price is exactly at the average PER line. Positive value indicates price is higher than average, and negative if price is lower than average. Usually people use value +2 and -2 to indicate extreme positions.

The second way to use the line is to see how the line jumps up or down at the earning report date. If the line jumps up, this indicates the increase of EPSTTM. And vice versa when the line jumps down.

When EPSTTM is trending up over several quarters, or if EPSTTM is expected to go up, usually the price is also trending up and the valuation is over the average. And vice versa when EPSTTM is trending down or expected to go down. Deviation from this pattern may present some buying or selling opportunity.


B. THE FINANCIAL TABLE

The second visual part is the financial table. The financial table contains financial information at the last bar. It has four sections:

1. Revenue
2. Income
3. Valuations
4. Ratios

Let's discuss them in detail.

1. Revenue and income sections

The revenue and income table are organized into rows and columns.

Each row shows the data at the specified time frame, as follows:

  • The first four rows shows quarterly revenue/income of the last four quarters.
  • Then followed by TTM data.
  • Then followed by forecast of next quarter revenue/income, if such forecast exists. Note the "(F)" notation next to the quarter name.
  • Then followed by forecast of TTM data of next quarter (only for income), if such forecast exists. Note the "(F)" notation next to the TTM name.


The columns of revenue and income sections show the following:

  1. The time frame information (such as quarter name, TTM, etc.)
  2. The revenue/income value, in billions or millions (configurable).
  3. YoY (year on year) growth, i.e. comparing the value with the value one year earlier, if any.
  4. QoQ (quarter on quarter) growth, i.e. comparing the value with previous quarter value, if any.
  5. GPM/NPM (gross profit margin or net profit margin), i.e. the margin on the specified time period.


Using the Revenue and Income table

The table provides quick way to see the revenue and income trend. You can see the YoY growth as well as QoQ, if that is applicable (non seasonal stocks). You can also see how the margins change over the periods.

The values are also presented with relevant background color. Green indicates "good" value and red indicates "bad" value. The intensity represents how good/bad the value is. The limits of the good and bad values are currently hardcoded in the script.

2. Valuations section

The valuation shows current stock valuation. The section is organized in rows and columns. Each row contains one type of valuation criteria, as follows:

  • PER (Price Earning Ratio)
  • Next quarter PER forecast (marked by "(F)" notation) when available
  • PBV (Price to Book value)


For each valuation criteria, several values are presented as columns:

  • The current value of the criteria. By current, it means the value at the last bar.
  • The one year standard deviation position
  • The three years standard deviation position



3. Ratios Section

The ratios section contains the following useful financial ratios:

  • ROA (Return on Asset), equal to: NET_INCOME_TTM / TOTAL_ASSETS
  • ROE (Return on Equity), equal to: NET_INCOME_TTM / BOOK_VALUE_PER_SHARE
  • PEG (PER to Growth Ratio), equal to PER_TTM / (INCOME_TTM_GROWTH*100)
  • DER (Debt to Equity Ratio), taken from request.financial(syminfo.tickerid, "DEBT_TO_EQUITY", "FQ")
  • DPR (Dividend Payout Ratio), taken from request.financial(syminfo.tickerid, "DIVIDEND_PAYOUT_RATIO", "FY")
  • Dividend yield, equal to (DPR * (NET_INCOME_TTM / TOTAL_SHARES_OUTSTANDING)) / close


KNOWN BUGS

  1. Currently does not handle when the financial quarter contains gap, i.e. there is missing quarter. This usually happens on newly IPO stocks.

Notas de Lançamento
Release notes:
1. Handle missing quarterly report.
2. Fix bug in GPM (gross profit margin) calculation
Notas de Lançamento
Add up/down arrow in PE line to make it even easier to spot if EPS TTM is up or down during earning report.
Notas de Lançamento
Add the actual EPSTTM QoQ growth percentage change during earning release in PE line.

Tip: hover the mouse on the percentage to see the tooltip
Fundamental Analysis

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?

Aviso legal