Skip to main content

How to Download Historical Data from TradingView

· 13 min read

TradingView is an incredibly powerful tool for anyone interested in markets, offering top-notch charts and real-time data. If you've ever wanted to save historical data from TradingView for backtesting a strategy, doing your own analysis, or using it in another program, you've come to the right place. This guide will walk you through how to do it, step-by-step. Getting a handle on this process can give you a much clearer picture of market trends and how prices have moved over time.

How to Download Historical Data from TradingView

Why Would You Want to Download This Historical Data?

Think of historical data as your personal time machine for the markets. It lets you look back at past price action to test out trading ideas and refine your approach, all without putting any real money on the line. While TradingView is great for looking at data on their platform, downloading it allows you to work with it in tools you might already use, like Excel, Python, or other analysis software.

Here's a closer look at why it's so useful:

  • Test Your Strategies: See how a trading idea would have performed in the past before you use it today. Once you have your data, you can test your strategy on TradingView to validate your approach.
  • Spot Hidden Patterns: You can identify recurring patterns, like key support/resistance levels or periods of high volatility, that are easy to miss when just watching a live chart.
  • Fuel Your Models: If you're into quantitative analysis or building machine learning models, you need large sets of reliable data to train and test them.
  • Benchmark Performance: Having historical records helps you compare current market conditions to the past, which can lead to better-informed decisions.

Downloading from TradingView also saves you the hassle of pulling data from many different places, as it brings together information from trusted exchanges. It's good to know that there are some limits depending on your account type, so picking the right method for your needs is key.

The table below summarizes the core purposes for grabbing this data:

PurposeWhat It's For
BacktestingTesting a trading strategy against old data to see if it would have been profitable.
Custom AnalysisDoing your own, deeper analysis in spreadsheets or coding environments.
External SoftwareUsing the data in other platforms or tools that aren't connected to TradingView.

Built-In Ways to Get Your Historical Data Out of TradingView

Want to save the price history from a TradingView chart? Their own built-in tools make it pretty simple. The best part is, you're probably already looking at the main tool: the chart itself. Just log into your account and pull up the chart you're interested in.

Your Go-To Method: Exporting Directly from the Chart

Here's how to grab the data you're seeing right on your screen.

  1. Set Up Your Chart: Open the chart for the stock, forex pair, or crypto you need. Make sure the timeframe at the top (like "1D" for daily or "1H" for hourly) is set correctly. To get more history, just keep zooming out on the chart. If you have a paid plan, you can load up to 20,000 data points ("bars").

  2. Find the Export Button: Look at the top toolbar for a button with three dots or a gear icon (it's the "More" menu). Click it and choose "Export chart data...". You can do this on both the website and the desktop app.

  3. Choose Your Format and Check the Data: A window will pop up showing you the data that's about to be exported. Here, you can pick your file format:

    • CSV: This is the best choice if you plan to open the data in Excel, Google Sheets, or other spreadsheet programs.
    • JSON: Pick this if you're going to use the data in your own code or software.

    Take a quick look to confirm it has all the columns you need—usually the date, open, high, low, and close prices, plus the trading volume.

  4. Download the File: Click "Export" and save it to your computer. Remember, this will only save the data that is currently visible on your chart. If you need older data, just scroll further to the left on the chart to load it before you export.

FormatBest For...
CSVSpreadsheet apps like Excel or Google Sheets
JSONProgramming, custom software, and databases

This method is perfect for quick exports, but it does have a limit based on your account type and how much data is loaded on the chart. Free accounts often cap at around 5,000 bars. If you see a "Load more history" prompt, you can usually click it or drag the chart to the left to load more data before exporting.

Other Places to Find Exportable Data

Charts aren't the only spot. You can also pull data from a couple of other places:

  • The Stock Screener: If you've used the Screener to filter for stocks (say, all tech companies above a certain size), you can export that entire list. Go to the Screener, apply your filters, and use the export function. This gives you a snapshot of those symbols and their current metrics, which is a great starting point for building a list to research further.

  • Your Broker Connection: If you trade through a broker connected to TradingView, you can export your personal trading history. Look for an "Export data..." option in your account menu. This file will include your past trades, open positions, and performance—all linked to the historical prices at the time of your trades.

Advanced Techniques Using Third-Party Tools

Sometimes, the built-in export options just don't give you enough data. That's where a few clever external tools come in handy, helping you grab larger chunks of historical data without having to manually click through endless charts.

Using Python with the tvdatafeed Library

If you're comfortable with a little bit of code, Python is a fantastic way to automate downloading large datasets. You can start by installing a helpful library called tvdatafeed using pip:

pip install tvdatafeed

Once it's installed, this library lets you pull up to 5,000 data points (or "bars") in a single request. You can get data from different timeframes, whether you need every minute or just the daily closing price.

Here's a simple script to get you started. This example downloads daily historical data for Apple stock:

from tvDatafeed import TvDatafeed, Interval
tv = TvDatafeed()
data = tv.get_hist(symbol='AAPL', exchange='NASDAQ', interval=Interval.in_daily, n_bars=5000)
data.to_csv('aapl_historical.csv')

After running this, you'll have a CSV file with Apple's price history. You can tweak the script for other uses. For example, if you're looking at futures data, you'd add fut_contract=1. For data that includes pre-market or after-hours trading, you can set extended_session=True.

A quick but important heads-up: be mindful of how often you request data. Making too many calls too quickly can get you temporarily blocked. It's always a good practice to be respectful of TradingView's terms of service.

Browser Extensions and Plugins

For those who prefer not to write code, browser extensions can be a lifesaver. One popular option is a Chrome extension like Autoview. After you install it, it can help automate the process of pulling data from your backtests and charts, including specific strategy details like where your entry and exit points would have been.

Pineify Website

Speaking of enhancing your TradingView workflow, if you're looking to create custom indicators and strategies without coding, Pineify offers a powerful visual editor that lets you build exactly what you need. While these data extraction tools help you gather historical information, Pineify helps you create the trading tools to analyze that data effectively - all without needing to learn Pine Script programming.

A neat trick that often pops up in online communities is combining these tools with Google Sheets. You can set things up so that your spreadsheet automatically updates with the latest prices, using scripts to pull in the data. While you can find more complex setups for ultra-fast (think one-second) data, starting with a TradingView export is a solid and straightforward first step.

Getting the Most Out of TradingView Historical Data

Think of downloading historical data from TradingView like having a membership at a gym—different tiers give you different levels of access. The free plan lets you grab a solid 5,000 bars of data, which is great for getting started. If you upgrade to a Pro+ plan, that limit doubles to 10,000 bars. For the most extensive historical research, the Premium plan offers up to 20,000 bars.

It's also important to remember that the quality of the data depends on the exchange it comes from. Sometimes, for symbols that trade less frequently or during market holidays, you might find small gaps in the data. It's not an error; it's just a reflection of real-world trading.

Here's how you can work smartly with these parameters:

  • Consider an Upgrade: If you consistently find yourself needing more historical depth or faster export speeds, the Premium plan is designed for that.

  • Mix and Match Your Sources: TradingView is fantastic for its charts and interface. For downloading very large datasets without limits, you can pair it with other free sources like Yahoo Finance or the Alpha Vantage API.

  • Clean Your Data: Once you've downloaded your data, a quick clean-up is a good habit. You might find a few missing numbers. In a spreadsheet like Excel, or using a Python script, you can easily fill those gaps to make sure your analysis is based on a complete picture. In Python, it's as simple as using a method like fillna() in the pandas library.

    # Example: Filling missing values in a pandas DataFrame
    filled_data = your_dataframe.fillna(method='ffill')
  • Be Mindful of Licensing: The data you export is intended for your own personal analysis. If you're planning to use it for a commercial product or redistribute it, you'll need to get the proper permissions from the data providers.

Quick Troubleshooting Tips

Running into a snag? If your export fails to start, try clearing your browser's cache or using the TradingView desktop app instead, which can sometimes be more stable. And if you're dealing with a particularly large file, compressing it into a ZIP folder will save you a ton of storage space.

Making Your Downloaded Trading Data Work for You

So you've downloaded a bunch of historical data from TradingView... now what? This is where the real fun begins, turning that raw data into something you can actually use.

Think of it like this: you've gathered all the ingredients, and now it's time to start cooking. Here's how you can bring that data into your favorite tools.

For the Hands-On Analyst:

  • Pop that data into MetaTrader to see how your trading strategy would have performed in the past (this is called backtesting).
  • If you love stats, import the CSV into R or Python to run your own deep statistical analysis.
  • In Excel, you can use a feature called Power Query to easily clean and organize the data. From there, you can pivot those Open, High, Low, Close (OHLC) numbers into charts and graphs that make sense at a glance.

For the Algorithmic Trader: If you like to code, you can feed the CSV file directly into libraries like backtrader or Zipline. Here's a simple idea of what that looks like: you load the data and then simulate trades against decades of market history to see if your strategy actually holds up.

This whole process is about finding the story in the numbers. By integrating the data, you can start calculating things like moving averages or RSI indicators on your own terms, offline. It transforms a simple spreadsheet into genuine insights you can trade on.

Q&A Section

Q: Can I download intraday historical data from TradingView? A: You can! Just head to your chart settings and choose a short time frame like 1-minute or 5-minute before you hit the export button. One thing to remember: how far back you can download this data depends on your subscription plan.

Q: Is the exported data adjusted for splits and dividends? A: For stocks, the exported data usually includes an "adjusted close" price, which does account for those events. It's a good habit to quickly check the columns in your downloaded CSV file. If you're doing very precise backtesting, you might still need to make some manual tweaks.

Q: How do I download data for multiple symbols at once? A: It depends on your method. If you're working directly on the TradingView website, the Screener tool is your best bet for getting a list of symbols at once. If you're comfortable with a bit of coding, you can use a Python library like tvdatafeed to write a simple script that loops through a list of symbols for you. For just one or two symbols, loading them on a chart and exporting manually is still the way to go.

Q: What if the export button is missing? A: Don't worry, this is a common hiccup. Usually, it means you need to be on a paid plan to access data exports. It's also a good idea to make sure your browser is up to date. If you're using the TradingView mobile app, you'll find the export options are more limited, so switching to a desktop browser is your best move.

Q: Are there free alternatives to download TradingView-like data? A: Absolutely. There are other free sources, like the yfinance library for Python, that can pull similar types of historical market data. The catch is that the quality and completeness of the data can differ from one free source to another, so it's something to keep in mind.

Next Steps

So, you've got a handle on the basics. What now? Here are a few practical, down-to-earth ways to build on what you've learned.

  • Start Simple: Don't overcomplicate it. Go into your TradingView chart right now and try a manual export. Get comfortable with the process and the data format. This hands-on step is the best teacher.
  • Level Up with Automation: If you find yourself repeatedly exporting the same data, it's time to explore automation. A simple Python script can save you hours of manual work. Start with one script that pulls data for a single asset.
  • Join the Conversation: This is where the real learning happens. When you hit a snag or discover something cool, talk about it. Places like the r/algotrading subreddit on Reddit are full of people on the same journey. Sharing what worked (and what didn't) helps everyone improve.
  • Stay in the Loop: For new features and pro-tips directly from the source, consider subscribing to TradingView's own announcements or blog.

What has your experience been? What was the biggest challenge you faced when gathering data? Let us know in the comments—your insights could be the key that helps another trader improve their approach. If you're looking to take your TradingView skills further, check out our guide on how to overlay charts on TradingView for advanced visualization techniques.