Fundamental data in Pine Script

TradingView financial data: periods, gaps and timing

TradingView financial data is available to Pine Script through request.financial(). Specify the company, financial field ID and fiscal period, then check missing values before calculating a ratio. Its historical mapping follows fiscal periods, so a plotted update is not proof that the number was public on that bar. The example below compares annual net margin with a dated company disclosure.

See the decision guide

Choose field IDs and fiscal periods explicitly

Use an exchange-qualified symbol such as NASDAQ:AAPL. TOTAL_REVENUE and NET_INCOME both support FQ, FH, FY and TTM in the official field catalog, subject to company coverage. These are fiscal reporting periods, not chart intervals. Changing the chart from daily to hourly does not create hourly financial statements.

  • For annual net margin, divide FY net income by FY revenue. Mixing FQ income with FY revenue changes the question.
  • For a balance-sheet ratio, use balances measured at compatible dates. Do not sum four quarterly balance-sheet snapshots to construct a yearly balance.
SettingMeaningAudit question
FQFiscal quarterDoes this issuer publish quarterly statements?
FHFiscal half-yearIs the reported amount for six months?
FYFiscal yearWhat is the actual fiscal year-end date?
TTMTrailing twelve monthsAre both inputs using the same rolling period?
TOTAL_REVENUE / NET_INCOMERevenue / net incomeDo the provider definitions match the disclosure rows?

Plot net margin and keep the inputs visible

This Pine v6 indicator calculates 100 × net income ÷ revenue. It requests USD for both inputs and exposes their amounts in millions in the Data Window. Enable the update-bar option to inspect gaps; those bars identify financial-series updates, not verified announcement times.

  • The default gaps_off carries the previous available value forward. gaps_on leaves na between updates; plot.style_linebr avoids connecting those gaps.
  • ignore_invalid_symbol = true returns na for an invalid or unavailable request instead of stopping the script. Check the symbol and supported period when the pane is blank.
  • The formula requires positive revenue and present inputs. A loss produces a negative margin; zero or negative revenue is deliberately left unplotted.
A diagnostic financial plot, not an entry strategy. Pineify syntax validation passed on October 17, 2026; that check does not verify provider values or historical availability.pine
//@version=6
indicator("Financial net margin audit", overlay = false, precision = 2)
string symbol = input.symbol("NASDAQ:AAPL", "Company")
string period = input.string("FY", "Fiscal period", options = ["FQ", "FH", "FY", "TTM"])
bool showGaps = input.bool(false, "Show only financial-series update bars")
float revenue = request.financial(symbol, "TOTAL_REVENUE", period, gaps = showGaps ? barmerge.gaps_on : barmerge.gaps_off, ignore_invalid_symbol = true, currency = currency.USD)
float netIncome = request.financial(symbol, "NET_INCOME", period, gaps = showGaps ? barmerge.gaps_on : barmerge.gaps_off, ignore_invalid_symbol = true, currency = currency.USD)
bool valid = not na(revenue) and not na(netIncome) and revenue > 0
float netMargin = valid ? 100.0 * netIncome / revenue : na
plot(netMargin, "Net margin (%)", color = color.blue, linewidth = 2, style = plot.style_linebr)
plot(revenue / 1000000.0, "Revenue (USD millions)", display = display.data_window)
plot(netIncome / 1000000.0, "Net income (USD millions)", display = display.data_window)

Reconcile Apple FY2024 against the disclosure

Apple published its fiscal 2024 results on October 31, 2024, for the year ended September 28, 2024. Page 1 of the accompanying statements reports the following GAAP amounts in USD millions. This is a reproducible disclosure benchmark, not a claim that a live TradingView chart was observed to match it.

  • Add the script to a NASDAQ:AAPL chart and select FY. Find the financial-series segment representing fiscal 2024, then inspect Revenue and Net income in the Data Window. A current last-bar value may represent a later year.
  • Compare each input with the disclosure before comparing the percentage. Dividing raw USD amounts or USD millions gives the same ratio when both use the same unit.
  • If the chart differs, record its two input values, the selected period and the observation date. Check standardization and GAAP versus adjusted figures before calling the difference an error.
  • Apple also provides a non-GAAP reconciliation. Do not substitute an adjusted numerator into this GAAP benchmark without relabeling the calculation.
Disclosure row or calculationFY2024 benchmark
Total net sales391,035 USD million
Net income93,736 USD million
Net margin: 100 × 93,736 ÷ 391,03523.9713%, rounded to 23.97%
FY2024 end / results publicationSeptember 28, 2024 / October 31, 2024

Keep four dates separate

TradingView documents that request.financial() maps new values to the next fiscal period, whereas request.earnings() provides earnings data on report bars. A fiscal-series update can therefore precede the public release. Neither gaps_on nor waiting for a price bar to close repairs that mismatch.

  • For an announcement-based test, obtain the actual release timestamp, timezone and relevant session. A calendar date alone cannot establish availability at the open.
  • The financial request returns a numeric series without a version-history or as-of-date selector. Treat revision timing as unknown unless a separate source documents it.
  • Archive original releases and subsequent amendments with retrieval timestamps. Do not backfill the latest revised figure into earlier decisions or assume a fixed 30-day lag proves point-in-time accuracy.
  • The Apple example separates the September period end from the October publication date. It does not identify the exact first tradable bar or the provider ingestion time.
Date or timestampWhat it establishes
Fiscal period endWhich business activity the number measures
Public release timeWhen the particular disclosure became public
Provider observation timeWhen you retrieved the displayed value
Revision or restatement timeWhen a later version became available, if documented

Resolve mismatches before using the ratio

TradingView explains that its provider standardizes financial statements, so a field can differ from the issuer presentation. Keep a reconciliation note with the source row, field ID, period, units, retrieved value and explanation. A matching percentage alone can hide two mismatched inputs.

Observed problemNext check
All values are naCompany coverage, exchange prefix and supported fiscal period
A flat line persistsCarry-forward setting and last available financial update
Annual and quarterly values disagreePeriod selection; do not compare unlike durations
The past changes after a reloadSaved observation versus current provider data; investigate a revision rather than assuming one
Numbers match but a backtest looks earlyPublication timing and the actual version available at the decision time

Carry the audit into Pineify

Use AI Finance Agent to retrieve income-statement fields and compare them with the linked issuer disclosure. Keep fiscal year, currency, filing date and accepted date in the research note; filing timestamps need not equal the earlier press-release time. Then give Pine Script AI Coding Agent the exact field IDs, period and missing-value rule for the chart.

  • Research request: retrieve AAPL annual revenue and net income for FY2024, retain available filing metadata, and reconcile them with the October 31 release from Apple.
  • Coding request: plot FY NET_INCOME divided by FY TOTAL_REVENUE as a percentage, preserve na, and expose the raw inputs for inspection.
  • Review both outputs. Finance Agent and TradingView can use different providers, and generated code cannot supply an undocumented historical data version.
Where Pineify fits

AI Finance Agent

Retrieve income-statement data and review period, currency and filing metadata alongside the original disclosure.

Also useful: Pine Script AI Coding Agent. Turn an explicit field, period and missing-value specification into Pine code you can inspect and validate.

Review financial data with AI Finance Agent

Frequently asked questions

Educational information, not investment advice. The Apple benchmark uses published historical figures. A syntax check does not verify financial data, release timing or trading performance.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.