TradingView Data Export

Export TradingView data for backtesting outside the chart

Traders who chart on TradingView often want the same bars in Python, Excel or NinjaTrader for research and backtesting. TradingView is a popular charting platform and trading community; Pine Script is its scripting language for indicators and strategies. Pine Script cannot request data from external websites or APIs; scripts work with data available on TradingView. FinzData mirrors yfinance with a Python client and REST API so you can load the same symbols into pandas DataFrames and save to CSV for offline work. This guide shows how to pull full history daily and 1-minute bars and move a Pine Script idea into a reproducible pandas backtest.

Get a free API key See pricing Download free samples

Why export TradingView data

Traders who want to export TradingView data for backtesting usually need more history than a chart loads, in a file they control. FinzData provides those bars directly from its own API.

Charts are great for visualization and real-time monitoring. Research needs full history, reproducible calculations and exportable files that can be shared with a team. How much intraday history a chart loads depends on the user's TradingView plan. Exporting gives you control over the window, the interval and the format without being limited by the chart view.

Moving the analysis to a local file lets you run the same logic on decades of bars, combine symbols, and integrate with Excel or NinjaTrader. The workflow is simple: sketch the idea on TradingView, pull the same symbols from FinzData, and test it in Python.

FinzData is a market-data API and Python client. Install with pip install finzdata, import finzdata as yf. The client mirrors yfinance with Ticker, history, download and returns pandas DataFrames. REST API at https://api.finzdata.com returns JSON or CSV; Parquet and bulk files on paid plans.

Pull full history with FinzData

FinzData covers 16,000+ US stocks since January 2000 including delisted names, 231 ETFs, daily, hourly, 30-, 15-, 5- and 1-minute bars. Intraday bars are stamped at the start of each interval in US Eastern time; minutes without trades are omitted, never forward-filled. Futures: 139 markets, 17,605 individual contracts since 2007, daily to 1-minute bars, back-adjusted and raw continuous series with the roll calendar. Futures files also come in a NinjaTrader 8 import format.

Point-in-time universe means the stocks that actually traded on each date. This is useful when you move a TradingView idea into historical simulation and want a survivorship-free view. The Python client supports yf.Ticker, yf.download and yf.Client().c.prices for bulk access.

Because Pine Script cannot request data from external websites or APIs, the export step is done in Python. Once exported, you can resample, join, and compute indicators exactly as you would in Pine Script, but on a much longer history.

Export daily and 1-minute bars to CSV

import finzdata as yf
import pandas as pd

# Daily full history for a ticker
t = yf.Ticker("AAPL")
daily = t.history(start="2000-01-01", interval="1d")
daily.to_csv("AAPL_daily.csv")

# 1-minute intraday history
one_min = t.history(start="2024-01-02", interval="1m")
one_min.to_csv("AAPL_1m.csv")

# Multiple symbols at once
df = yf.download(["SPY","QQQ"], start="2020-01-01", interval="1d")
df.to_csv("spy_qqq_daily.csv")

Move a Pine Script idea to pandas

A common workflow is to sketch an idea on TradingView and then test it on decades of data. Because Pine Script cannot request data from external websites or APIs, the next step is to load FinzData bars and run the logic in Python.

Example: a gap-fill rule. Compute overnight gap from previous close to open, then check if price fills the gap within the first hour. With FinzData you can run this on 1-minute bars since 2000 for US stocks and ETFs, and since 2007 for futures. The same rule can be applied to futures continuous contracts with back-adjusted prices.

Saving the bars to CSV makes it easy to share with analysts who do not use Python. The REST API can return JSON or CSV directly, and Parquet and bulk files are available on paid plans for large downloads.

Pandas backtest example for a gap-fill rule

import finzdata as yf
import pandas as pd

t = yf.Ticker("SPY")
bars = t.history(start="2000-01-01", interval="1m")
bars = bars.dropna(subset=["Open","Close"])

# Daily open and previous close
daily_open = bars["Open"].resample("D").first()
prev_close = bars["Close"].resample("D").last().shift(1)
gap = (daily_open - prev_close) / prev_close

# First hour fill
first_hour = bars.groupby(bars.index.date).head(60)
filled = first_hour.groupby(first_hour.index.date).apply(lambda x: ((x["High"] >= daily_open.loc[x.name]) | (x["Low"] <= prev_close.loc[x.name])).any())

result = pd.DataFrame({"gap":gap,"filled":filled})
result.to_csv("spy_gap_fill.csv")

Start free

Start with the free tier: last 12 months of every dataset, 1,000 API calls a day, no card. Full history is a one-time purchase that is yours to keep. Every subscriber gets access to the FinzData strategies page and research, including the AI Trading Tournament.

Explore samples and pricing if you want to export TradingView data ideas into a backtest on full history. The Python client mirrors yfinance so adoption is fast for teams already using pandas.

Frequently asked questions

Can I export TradingView data directly from Pine Script?

No. Pine Script cannot request data from external websites or APIs; scripts work with data available on TradingView. Export the bars with FinzData and run the logic in Python.

What formats can I export to?

The Python client returns pandas DataFrames. Save to CSV with to_csv, or use the REST API for JSON or CSV. Parquet and bulk files are available on paid plans. Futures files also come in NinjaTrader 8 import format.

How far back does intraday history go?

FinzData gives 1-minute bars for US stocks and ETFs since January 2000 and for futures since 2007. This lets you test ideas over decades.

Is the data survivorship-free?

Yes. 16,000+ US stocks since January 2000 including delisted names. Point-in-time universe is provided for each date.

Do minutes without trades get filled?

No. Intraday bars are stamped at the start of each interval in US Eastern time; minutes without trades are omitted, never forward-filled.