Pine, our proprietary scripting language, is used by traders around the world to build automated strategies based on price action, technical indicators, and more. Today, we’re making Pine even more robust by adding financial functions and metrics that include things like Market Cap, Revenue, and Total Liabilities or Debt.
If you are unfamiliar with Pine and all that it offers, then check out this guide. If you are already a Pine user, you can get started by using our new financial function. This function will return the requested financial data and their values. It looks something like this:
financial(symbol, financial_id, period, gaps)
Here is a breakdown of the simple script above:
symbol — the name of the prefix character that the metric is being requested for. For example: “NASDAQ: MSFT”
financial_id — id of the requested fundamental feature. You can view the list of available ids via our Help Center.
period — shows how often the data is available. FQ – once a quarter, FY — once per financial year, TTM — the last 12 months.
gaps — an optional parameter, similar to the parameter in the security function.
For example, if you want data for Microsoft (NASDAQ: MSFT) and its Accounts Payable for the period, your script will look something like this:
//@version=4 study("My Script") f = financial("NASDAQ:MSFT", "ACCOUNTS_PAYABLE", "FQ") plot(f)
Note: If the parameter value is barmerge.gaps_on, the requested data is then merged with any possible gaps (na values). If the parameter value is barmerge.gaps_off, the requested data is continuously merged without gaps, and all gaps are then filled with the previous, nearest existing value. Please be aware that the default parameter value is barmerge.gaps_off.
When you are finished, your Pine script will appear as it always does – as a pane beneath your chart. In this case, as shown below, the Pine Script matches perfectly with the fundamental indicator, Accounts Payable. Remember, this script is just an example and was designed to do as such:
Moving forward, you can access built-in fundamental indicators by going to Financials located at the top of your chart:
We think this new update will unlock new and unique ways for both traders and investors to create unique strategies based on fundamental data. We look forward to working with you and seeing what you build.