How to Backtest on Tradingview

In this post I’ll provide an overview of ALL the Tradingview backtesting options.

Tradingview offers either manual backtesting using a bar replay feature OR the built-in automated strategy tester program.

The Tradingview automated backtesting strategy tester program lets traders either use pre-built strategies or build there own using the Tradingview programming language – Pine Script.

Traders should be always backtesting there trading strategies. It’s the best method to determine whether a strategy is likely to be profitable or a waste of time and money.

If your wanting to use Tradingview for running backtesting. Then seriously consider upgrading to the Tradingview PREMIUM plan. The PREMIUM subscription is tailored towards backtesting users – It offers ALL available historical data plus the most precise price action simulation.

Signup for a Essential, Plus+ or Premium TradingView subscription using the link. *New users get $15 towards a new plan.

What is Backtesting?

Backtesting is a manual or systematic method of determining whether or not your trading strategy has been profitable in the past.

The process of backtesting uses historical market data with specific strategy parameters or a specific trading setup.

Backtesting is also a great way to fine tune an already profitable strategy to work out how to make it even more profitable.

All traders should be performing some sort of backtest analysis on their existing or any new strategy.

Backtesting can be performed manually using bar (market) replay features or automated by programming strategy parameters, Tradingview offers each of these features and I’ll be discussing each of these in the following sections.

Does Tradingview support backtesting?

YES, Tradingview supports backtesting for all markets and instruments. There are several ways that tradingview allows uses to backtest strategies. The Bar replay feature allows traders to manually backtest strategies and the Tradingview strategy tester is prefect for automating your own strategy that can be built using Pine script or simply use one of the built-in strategies that Tradingview provides.

How do I backtest with Tradingview?

Tradingview offers several methods for backtesting trading strategies. The following is a brief overview of each of these methods. In the sections to follow I’ll go into more detail about using each of these.

Bar Replay function

The Tradingview bar replay function is a brilliant feature of the platform. Bar replay allows users to playback historical data at various speeds or one bar at a time. Bar replay is perfect if you prefer to manually backtest your strategy using historical data.

Using the BAR replay feature is perfect if you don’t have the expertise or resources to build an automated trading strategy.

I’ll discuss the bar replay feature in more detail below.

Strategy tester

If you prefer to automate your backtesting. Then the Tradingview ‘Strategy tester’ allows users to run and test coded Trading strategies.

Uses can either:

1. Use one of the ‘Built-In’ strategies available within the Tradingview library.

2. Uses can run their own trading strategy that can be built using the Tradingview programming language ‘Pine Script’.

I’ll discuss each of these in more detail below.

Can I backtest on TradingView for free?

YES, it’s possible to backtest for FREE using Tradingview. Both the Bar replay and strategy tester features are available with the free BASIC subscription.

However there’s a handful of limitations that make having an upgraded Tradingview subscription important if you’ve serious about getting reliable results from your backtesting.

Whilst the BASIC Tradingview subscription offers the use of the Bar Replay function. It can only be used on the D W M timeframes. To get full access to intraday and custom time intervals you’ll need at least a Tradingview Essential subscription.

What Tradingview plan is best for Backtesting

For the most reliable backtesting results you really want to test over the largest range of historical market data. The BASIC plan only offers 5K bars of historical data for your selected timeframe. Whilst the Essential and Plus offer double that with 10K and the Premium with the ‘Deep Backtesting (BETA)’ feature makes it possible for all available historical data for the instrument to be backtested.

Tradiingview has recently introduced a new feature called ‘Backtesting Precision’. Normally tradingview backtesting only uses 4 data points for each bar: OLHC. All other bar data that occurs between these points is ignored. Backtesting precision traces all bar data throughout the life of the active bar. For the most accurate backtesting results be sure to use this feature. Backtesting precision is however only available with a PREMIUM subscription.

The PREMIUM plan is tailored for backtesting users. If you are interested in using Tradingview for backtesting then consider upgrading ideally to the PREMIUM plan.

Signup for a Essential, Plus+ or Premium TradingView subscription using the link. *New users get $15 towards a new plan.

Manual Tradingview Backtesting using the Bar Replay function

The Bar replay feature is a really nice feature that allows users to simulate a real market environment using historical data. Bar Replay is perfect manually backtesting your trading strategy.

Advantages of manual backtesting

Some traders prefer to manually backtest their strategy. Manually backtesting offers several advantages:

  1. Allows traders to get to know their strategy better, understand better how it performs in specific situations and easier to identify where improvements can be made
  2. Develops more confidence in your strategy
  3. No programming skills required

How to Use Tradingview bar replay for backtesting

If you are interested in using the Tradingview bar replay feature for your backtesting, then in this section I’ll explain step by step how to use the Tradingview bar replay for backtesting.

If you’re interested in using the bar replay feature then consider upgrading to at least Essential subscription. Basic plan uses only have access to the bar replay feature using the D W M timeframes. For all timeframes and more historical bars upgrade to either Essential, Plus or Premium.

Signup for a Essential, Plus+ or Premium TradingView subscription using the link. *New users get $15 towards a new plan.

To access the bar replay function follow these steps:

  1. In the top menu bar of any Tradingview chart. Select the ‘Replay’ icon.
Tradingview bar replay
  1. Along the bottom of the chart beneath the date / time axis the ‘bar replay’ tool bar will appear.
Bar replay function menu

In this tool bar there are all the functions to operate the bar replay function. To use the bar replay feature the first thing that you’ll want to do is set the start date and time that you want the replay to start from.

  1. To nominate the start date and time to begin the bar replay, select the ‘Jump to…’ icon in the bar replay tool bar.
  1. Select the date and time to begin the bar replay using the blue vertical line indicator. If you want to utitilize the maximum amount of data available. Scroll as far back in time that your subscription bar data allowance allows. To get ALL the data available for any instrument. Upgrade to the Tradingview PREMIUM plan.
  1. Bar playback: There are 2 methods for controlling how bars replay: Either by 1. using the ‘Play’ function and setting the ‘Replay speed’. Or 2. using the ‘Forward’ function that steps forward a single bar each time you click the forward icon.
Play function -Plays bars continuously at the speed set in ‘replay speed’
Tradingview Bar replay speed settings
Setting ‘Replay speed’
Forward function – Steps forward a single bar per click
  1. Begin Backtesting: Start the bar replay function by either of the methods mentioned above.

Progress through the bars till your strategies trade setup entry parameters are satisfied.

Note: Unfortunately Tradingview doesn’t offer Paper Trading with the Bar Replay function. Hopefully this will be introduced at some stage in the future. Using Bar Replay you’ll need to log trades manually. If you’d like some ideas for creating a Trading Journal to log trades check out my ‘Best free Trading Journal’ post.

  1. Setting up a trade: When a trade setup appears use the ‘Long or Short Position tool‘ to setup your trade.

  1. Playout the trade and record the result in your Trading journal.

  1. Repeat the process for as much data as possible to get the most reliable Backtest results.
  1. Recording and processing data: Record the key out comes of each trade. Win, Loss, Risk to reward etc. A spread sheet format like excel or google sheets in my experience is the most effective method for recording and processing the results of a manual backtest. If you’d like to find out more about setting up a trading journal using either excel or google sheets check out this post for more information.

As you can see manually backtesting can be a laborious process. As I mentioned earlier this method of backtest has its own set of advantages.

Automated Tradingview backtesting using the Strategy Tester

If you have some basic programming skills or willing to learn, then using the automated Tradingview strategy tester is a more time efficient backtesting method.

In this section I’ll introduce the strategy tester and pine script.

The Strategy tester is a built-in feature within Tradingview. It allows users to run a programmed strategy to automate trades for backtesting.

Pine script is Tradingviews program language (similar to Java script, C++ etc) that allows uses to create automated strategies for either backtesting or live trading. This topic is quite technically heavy. In a future post I’ll discuss in more detail how exactly to build your own strategy using pine script. This section aims to introduce the topic.

Advantages of Automated backtesting

Some traders prefer to Automate backtesting of their strategy. Automation via programmable software offers several advantages:

  1. More time efficient – Once the program has been written it can be run over a huge range of data and different markets.
  2. Easier and quicker to make small strategy changes and observe the performance difference over a large amount of data.

How to Use Strategy Tester for Tradingview backtesting

In this section I’ll explain step by step how to use the Tradingview strategy for backtesting. I’ll also introduce Tradingviews Pine script (programmable language) for building your own strategy.

The Strategy tester and pine script functions are available for use with all Tradingview subscriptions. However if you want to export and process the results of the test outside Tradingview you’ll need to have either a Plus or PREMIUM subscription. Also consider upgrading to have access to the most amount of historical data to run your strategy.

Signup for a Essential, Plus+ or Premium TradingView subscription using the link. *New users get $15 towards a new plan.

Tradingview strategy testerThe Strategy tester is a built-in feature that runs automated trading strategies. These strategies can be either pre-built strategies found within the Tradingview library or create your own strategy using Pine Script.

In this section I’ll explain step by step how to use the Strategy tester. To access the strategy tester follow these steps:

  1. In the bottom chart menu select the ‘Strategy Tester’ tab.
Tradingview strategy tester

  1. Select ‘Load your strategy’ within the tab window at the bottom below the chart.

Accessing built-in strategies from Tradingview library

  1. Within the ‘Indicators, Metrics and Strategies popup menu select ‘Technicals’ from the menu on the left hand side. Then select ‘Strategies’. Here you will find a list of built-in strategies for either backtesting or live trading.
Tradingview built in strategies
List of pre-built trading strategies
  1. Select a strategy – from the list to load on your chart. For this example I’ll use the ‘MovingAvg Cross’ strategy.
Tradingview strategy tester using built in strategies

In the chart window you will see all the executed trades for the strategy.

In the menu window at the bottom of the chart you will see a series of tabs that summarize the performance and settings. These include a general overview, Performance summary, List of trades and Properties.

In the menu window you will find a P and L chart that graphically illustrates the cumulative profitability of the strategy over an increasing number of trades.

  1. Strategy settings – To change any of the parameters of strategy go to the ‘Gear Icon’ next to the strategy name at the top of the bottom window menu. You will find all the parameters that can be adjusted for that particular strategy.

By chance you may find a strategy the same as one you are interested in using from the Tradingview library. By adjusting the available settings you can optimize this existing strategy for various markets, timeframes or time of day. There are loads of options available using these ‘Built-in’ strategies.

If however you have your own unique strategy and what to backtest its performance using the strategy tester. Then building your own Strategy using Pine Script is the way to go!

Pine Script | Build your own strategy

Pine script is Tradingviews programming language for building trading strategies for use with the Tradingview Strategy tester.

You can build your own strategy script using the Pine Editor,

The Pine editor can be found in the bottom tab menu of any chart. Here your script can be written of pasted in.

Build your own strategy using Pine Script
Tradingview pine editor for building your own trading strategy

Learning Pine script is a huge topic and far to large to cover in this post. If you’re interested in building your own strategy using Pine script then tradingview have a Pine script user manual here. A really great course is the Basic FREE Pine Script course that’s perfect for beginners with no previous programming skills and for more detail then there is also a paid Pine Script Mastery course – this is the level of detail you’ll need if you want to learn to build your own strategy.

If learning to code is not an option it’s likely you could hire a programmer to build a strategy based on your specifications. This is something I have no experience but it’s an option worth being aware of.

Once you’ve built your own strategy using Pine script you’ll be able to run it using the strategy tester. Result and performance will display the same as the built in strategies.

How to export Tradingview backtesting data

If you want to export your Tradingview backtesting data you will need either a Tradingview Plus or Premium Plan. To upgrade your current plan click the link.

The following steps explain how to export tradingview strategy backtesing data:

Step 1. In any Tradingview chart go to the bottom menu and select the “Strategy Tester’ tab.

Step 2. If you haven’t already done so. Load and run the strategy you want to export the data.

Step 3. Go to ‘Performance Summary’ tab

Step 4. To the right of the Strategy name select the ‘Export data’ icon. The strategy data will export to a .csv file. Select the location of your computer to save the file. The .csv file can be imported into excel or google sheets for analysis.Then go to ‘Performance Summary’. Here is a list of all your

Signup for a Essential, Plus+ or Premium TradingView subscription using the link. *New users get $15 towards a new plan.

Benjamin Crichton
Benjamin Crichton

I'm Ben, I graduated with a degree in Engineering and Science from the University of Adelaide, Australia. I've been actively trading the Futures and Forex markets since 2014.

In 2018 I started Tradamaker a site that specializes in trading resource tutorials. I use my professional background in probability, statistics, risk analysis, uncertainty, pattern recognition, coding and charting to help fellow traders get the most out of online trading software and tools.

I make regular updates to this site. To receive notification of my latest posts and join the community please subscribe to our newsletter below.

Newsletter Updates

Enter your email address below and subscribe to our newsletter