PROTECTED SOURCE SCRIPT

Financial Growth

Overview
The script named "Financial Growth" is written in Pine Script v5.
It is designed to display various financial metrics and ratios in a tabular format on TradingView charts.
The code pulls financial data like revenue, net income, EPS, etc., and presents these metrics along with ratios such as P/E, D/E, and others.
The table can display these values for different time periods such as quarterly, yearly, or trailing twelve months (TTM).
Additionally, it can show QoQ (Quarter-over-Quarter), YoY (Year-over-Year), and CAGR (Compound Annual Growth Rate) changes for selected financial items.
The code includes plotting options for visual representation of financial data and labels.
Explanation of Code Sections
Revision Notes

The revision notes indicate changes made in different versions of the code.
Each version update introduces new financial metrics and code restructuring.
Indicator Definition

indicator("Financial Growth", overlay=false, format=format.volume): Defines a standalone indicator with the name "Financial Growth". The overlay=false parameter ensures it is not overlaid on the chart but shown in a separate panel.
Text Sizes and Table Positions

Different text sizes and table positions are defined using variables such as text_size_SMALL, tb_pos_POS01, etc.
These variables help in formatting the visual display of the table and labels.
Financial Items

The script defines several financial items like revenue, net income, EPS, EBITDA, debt, and ratios such as ROE, ROA, and D/E.
Each financial item is assigned a corresponding unique identifier, e.g., _revenue_id = 'TOTAL_REVENUE'.
Calculated Financial Ratios

Ratios such as P/E, P/BV, P/S, and P/FCF are calculated using:
price_to_earning
price_to_book_value
price_to_sales
price_to_free_cash_flow
These calculations are done using request.financial function calls.
User Inputs

The code uses input functions to allow users to select financial items and time periods:
financial_item_selection_01 and financial_item_selection_02 enable the selection of financial metrics.
period_selection allows users to choose between periods like FQ (Fiscal Quarter), FY (Fiscal Year), and TTM (Trailing Twelve Months).
Users can control the table's visibility and the display of QoQ, YoY, and CAGR changes using input.bool() settings.
Financial Data Retrieval

The function retreive_financial_data(_financial_item, _period) retrieves financial data based on the selected financial item and period.
It uses the request.financial function to get data for a specific ticker.
Table Creation and Formatting

The script uses table.new() to create a table for displaying financial data.
The table’s headers and values are populated using custom functions like header_column, date_column, and value_column.
QoQ, YoY, and CAGR columns are conditionally displayed based on the user’s input settings.
Plotting Data

The script can also plot the selected financial metrics using the plot() function.
Labels for plotted data are created using the label.new() function.
Handling of Bar States

The barstate.islast condition ensures that the table and plots are only updated at the last bar state, which optimizes performance and prevents unnecessary calculations.
Code Formatting and Optimization

Proper use of variables, functions, and conditional statements adheres to TradingView’s guidelines for efficient Pine Script development.
The use of ignore_invalid_symbol=true in request.financial calls ensures the script handles non-existent financial data gracefully.
Key Functions
is_calculated_data(_financial_item)

Determines whether a given financial item is a calculated metric (e.g., P/E, P/BV) instead of being directly available from TradingView’s data.
get_financial_id(_financial_item)

Returns the financial identifier based on the selected item (e.g., TOTAL_REVENUE for revenue).
get_value_formating(_financial_item)

Returns the appropriate value divider, suffix, and formatting style based on the selected financial item.
create_array(arrayId, val)

Adds a new value to a specified array, used for storing historical financial data for table display.
get_cagr(_data_array, _id, _idmax)

Calculates the compound annual growth rate (CAGR) based on the given data array and index.
financialstatistics

受保護腳本

該腳本是閉源發佈的,您可以自由使用。您可以把它加入到常用以在圖表上使用它。您無法查看或修改其原始碼。

想在圖表上使用此腳本?

免責聲明