Skip to main content

Import Chart Data in TradingView: Quandl, CSV, and API Methods

· 10 min read
Pineify Team
Pine Script and AI trading workflow research team

Importing chart data in TradingView is the process of bringing external datasets into your charts for custom analysis. TradingView comes with a lot of built-in market data, but you can also pull in specific external datasets. You can't just upload any random CSV file directly into the main chart or Pine Script, but there are clever ways to get custom data in there.

How to Import Chart Data in TradingView: A Step-by-Step Guide

How to Use Quandl for External Data

Quandl is one of the simplest routes for bringing external information into TradingView. Type QUANDL: in the symbol search bar, followed by the dataset code. I've used QUANDL:CHRIS/CME_CSC1 for corn futures data and it pulls right up. The reason this works: TradingView has a direct data partnership with Quandl, so no extra configuration is needed.

What can go wrong? Only Quandl's free public datasets are available through this integration. If you need premium data, you'll need a separate Quandl subscription.

In Pine Script, you can grab that data using the security function:

data = security("QUANDL:CHRIS/CME_CSC1", "D", close)

This lets you incorporate third-party time series data into your own custom indicators or trading strategies without manual copy-pasting.

Working with Your Own Data in Pine Script

Sometimes you need data that isn't available through standard sources like Quandl. In January 2025, I had a project that needed S&P 500 divisor values — data that simply wasn't on any free feed. For small datasets that don't change often, you can directly embed your own numbers in Pine Script using time-based conditions. If you're new to Pine Script, What Language is Pine Script? A Complete Guide for Traders covers the basics before you get into data integration.

Here's a practical example using quarterly S&P divisor values:

//@version=4
study("3rd-party data - S&P Market Cap")
data = float(na)
data := time >= timestamp(2019, 03, 30, 00, 00) ? 8332.84 : data
data := time >= timestamp(2019, 06, 30, 00, 00) ? 8302.34 : data
// …additional assignments…
plot(data * close / pow(10, 6), title="S&P Market Cap")

The why behind this approach: you have total control over every data point and no external dependencies. What can go wrong — for large datasets, typing hundreds of timestamp lines is tedious and error-prone. I've found it works best with under 50 data points. For anything larger, you can use a Python or R script to auto-generate those assignment lines.

Pineify Website

If you work with Pine Script regularly, Pineify removes the manual typing. Its visual editor and AI generator produce custom indicators and strategies from your description instead of raw code. I've used it for data-heavy scripts and found it cuts down on debugging time, though you still need to understand your data structure to get good results.

Using the Charting Library Datafeed API

For putting TradingView charts on your own site, the Datafeed API is the way to connect your own market data. Think of it as a bridge that lets your custom data — from your own databases, a REST API, or a WebSocket feed — power the chart while keeping TradingView's interface and drawing tools.

The library needs you to provide a JavaScript object with a few key methods:

  • onReady: Tells the chart what timeframes (1 minute, 1 hour, 1 day) and exchanges your data supports.
  • resolveSymbol: When the chart needs details about a specific symbol (like "AAPL" or "BTCUSD"), this method provides tick size, minimum movement, and full name.
  • getBars: Fetches historical price bars (open, high, low, close) when the chart loads or when you scroll back.
  • subscribeBars / unsubscribeBars: Manage real-time updates by subscribing to a live data stream and unsubscribing when done.

I prefer the Datafeed API when I need live data that changes frequently. That said, I haven't tested it with high-frequency crypto tick data, so I can't vouch for its performance at that level. The trade-off: you get complete control over your data source with the familiar TradingView charting experience, but it requires JavaScript development and a hosted server.

A Practical Example for Importing CSV Data into Your Charts

Ever wanted to plot custom data from a spreadsheet right on your trading chart? A community member named allanster created "How To Import And Offset CSV Data," which shows the exact process.

It reads your data into an array and aligns each value with the correct bar on the chart. This works well for smaller datasets — a few hundred rows at most. Why this works: arrays let you manipulate data before plotting, so you can offset, scale, or filter values. What can go wrong — if your CSV is large, the chart can slow down noticeably. When writing conditional logic for data processing, If Else in Pine Script can help.


What to Keep in Mind & How to Make It Work

Here's a straightforward look at the different paths and what each involves.

ApproachBest ForThings to Consider
Manual Encoding in Pine ScriptSmall, static datasets (a few hundred data points).Simple for a one-off, but time-consuming for anything larger.
Using the Charting LibraryDynamic, large-scale, or frequently updated data.Offers the most flexibility and power, but requires web development knowledge and hosting.
Quandl IntegrationQuickly using free public datasets.Works instantly but only with their free data. Premium sets need a separate subscription.

A quick note on Pine Script: it's not designed to read files from your computer. All data has to be typed directly into your code or pulled from a supported online source.

For small, fixed datasets, manual typing works fine. For larger or changing data, the Charting Library route requires more setup but saves you from endless manual coding and keeps data up to date automatically.

Common Questions & Answers

Can I import a CSV file directly into TradingView charts? No, the standard TradingView platform doesn't let you upload a CSV directly onto a chart or into a Pine Script. Here are the workarounds:

  • Use Quandl codes for supported datasets.
  • Manually type your data values into Pine Script code.
  • Use the Charting Library's Datafeed API on your own website.

How do I visualize my own custom data series? It depends on your dataset size and how often it changes.

  • For small, fixed datasets (key price levels or dates), embed values directly in Pine Script using timestamp checks.
  • For larger or frequently updated data, use TradingView's Charting Library on your own website with the Datafeed API to stream custom data.

Is there a built-in method to import trade transactions? Yes. On your chart, open the "Transactions" tab, click "Import", and upload a CSV formatted with the required columns: Symbol, Side (buy/sell), Quantity, Price, and Commission.

Can I automate custom data updates? Not really from within Pine Script itself. For infrequent changes, manual updates or an external script to regenerate the code works. For real-time automation, use the Charting Library API — your server pushes live updates to the chart. If you're building advanced systems, Understanding the ta.linreg() Function in Pine Script v6 can help with statistical analysis on imported data.

What's the difference between Quandl and the Charting Library for custom data? Quandl is instant — type a QUANDL: symbol code and add a security() call — but it's limited to Quandl's free datasets. The Charting Library gives you full control over any data source (your own database, REST API, WebSocket), but requires JavaScript development and server hosting.

Can I import a CSV file directly into TradingView charts?

No, the standard TradingView platform does not allow uploading a CSV file directly onto a chart or into Pine Script. Workarounds include using Quandl codes for specific datasets, manually embedding data values into Pine Script code using timestamp conditions, or using the Charting Library Datafeed API for a fully integrated solution.

How do I visualize my own custom data series in TradingView?

For small, fixed datasets, embed the values directly into Pine Script using timestamp checks. For larger or frequently updated data, use the Charting Library with the Datafeed API to stream custom data into the charts.

Is there a built-in method to import trade transactions into TradingView?

Yes. Open the Transactions tab on your chart, click Import, and upload a CSV with the required columns: Symbol, Side (buy/sell), Quantity, Price, and Commission.

Can I automate custom data updates in TradingView?

Automation within Pine Script itself is very limited. For rare changes, manual updates or external scripts to regenerate code work fine. For real-time automation, use the Charting Library API so your server pushes live updates directly to the chart.

What is the difference between Quandl and the Charting Library Datafeed API for importing data?

Quandl is instant — type a QUANDL: symbol in the search bar and add a security() call — but limited to Quandl's free public datasets. The Charting Library gives you full control over any data source including your own databases and live feeds, but requires JavaScript development and server hosting.