How Pine Optimizer Extends TradingView
Transcript
Hello traders,
My name is Tim, and I’d like to welcome you back to this video tutorial series on trading strategy optimization, using Pine Optimizer.
In previous sessions, we explored some of the general principles of trading strategy optimization and saw how TradingView strategy tester can play an important role in this.
In this session, we’ll look, in detail, at the relationship between TradingView and Pine Optimizer, so that we gain a clear understanding of the roles these two essential tools play in our optimization workflow.
As a starting point, let’s take a look at the way TradingView organizes its data when executing a strategy test.
At the top of the data hierarchy is a strategy. Whenever you add a Pine Script strategy to your chart, TradingView tracks it as a self-contained data entity that includes a complete set of backtest results.
Within each strategy exists a version, which reflects the actual script code that you used to define the strategy. When you create and save a new strategy script, TradingView’s Pine Editor automatically assigns the first version …
… and each time you modify your Pine Script and save your changes, TradingView assigns a new version to reflect those changes, which means that a strategy can accumulate an unlimited number of versions.
TradingView stores a permanent copy of all your strategy versions in the cloud, which makes them available on any device logged into your TradingView account. You can also go back to a previous saved state in your Pine Script edit history, simply by switching the version within the Pine Editor.
When you click the “Add to Chart” button to add a strategy to your chart, TradingView fires up its strategy tester to execute that strategy. This results in a backtest being run against the candle data on the current chart, including all the historic price data that may not necessarily be visible on your chart view.
If you modify any setting that influences backtest execution, such as changing the chart symbol or timeframe, or adjusting one of the strategy parameters, the backtest will be automatically re-run. And this results in a completely new set of backtest results. In this way, a single strategy version can be responsible for generating a significant number of individual backtests.
As we saw in the last video, executing a backtest results in a number of trades being generated. Depending on the nature of the strategy and the amount of candle data available on the chart, a backtest could include just a handful of trades or many hundreds.
As you can see, a backtest, together with its contained trades, represents a wealth of numerical data that can be very valuable in optimizing a strategy. Unfortunately, TradingView does not store backtest results. The strategy tester does a great job of presenting these results for immediate human consumption, but as soon as you change any setting that causes execution of a new backtest, the results of the previous backtest are discarded.
This means that it’s quite a challenge to compare the results of multiple backtests, which is a key requirement in strategy optimization.
In fairness, it’s worth noting that the TradingView strategy tester does allow us to export backtest results to a CSV file, but the scope of the output is limited and it requires a cumbersome procedure to re-combine this exported data in a format that is usable for strategy optimization.
Many traders have built their own optimization workflows around TradingView’s exported CSV data, but the process is very inefficient and error-prone, as well as imposing severe limitations on the level of optimization achievable.
We believe that Pine Optimizer solves this problem and supports the highest standards of strategy optimization in a comparatively effortless manner.
To understand how Pine Optimizer delivers the additional capabilities needed for efficient strategy optimization, it’s helpful to start with an understanding of how it integrates with TradingView.
The only formal preparation step is to install the Pine Optimizer web browser extension, which remains idle, in the background, until it is called upon to take part in strategy optimization.
As a reminder, Pine Optimizer is compatible with any Chromium-based web browser, which includes Google Chrome, Microsoft Edge and several other popular browsers.
With the browser extension installed, the TradingView chart page may be opened, in the browser, and used in the normal manner.
Pine Optimizer may also be opened in another browser tab, and used to perform operations such as querying or analysing the results of prior strategy optimization sessions. In this configuration, there is no interaction between any of these components.
However, if Pine Optimizer is used to perform a new strategy optimization, it will establish a connection with TradingView, via the browser extension, and invoke TradingView to execute the necessary backtest runs on its behalf, returning the results as each run completes.
Pine Optimizer fully automates the execution of complex sequences of backtest runs and permanently stores the complete set of results returned by TradingView. This means that we can put behind us the inconvenience of working manually with backtest data in CSV files.
Pine Optimizer also includes an extensive built-in feature set for comparing and analysing backtest results, so as to make informed decisions that will lead to significantly better trading strategies.
Let’s now take a look at the at the way Pine Optimizer organizes its data when executing a strategy optimization.
Just like the TradingView strategy tester, Pine Optimizer has a strategy as the top-level element in its conceptual model.
And, like TradingView, Pine Optimizer supports multiple versions of each strategy, with a new version being created each time a strategy script is modified.
You won’t be surprised to learn that, just like TradingView, Pine Optimizer also permanently stores all of its strategy and version data, enabling you to re-open strategies that you created previously and continue working on them, for example by creating a new version.
The first key area in which Pine Optimizer deviates from TradingView is in its use of campaigns.
A campaign is an experiment, whose goal is to discover some useful insights about the performance of a strategy, enabling us to makes changes that will improve it.
A strategy can have as many campaigns as you choose, with each one conducting a new experiment that builds on the insights gained from the earlier campaigns.
Within each campaign, Pine Optimizer obtains its experimental data by invoking TradingView to execute backtests, using the strategy tester that we saw in the previous video.
But, unlike TradingView, Pine Optimizer executes multiple backtests, as a single operation, in order to gather enough data to make meaningful assumptions about how best to optimize the strategy,
We generally continue adding new campaigns and applying their resulting optimizations until we see no further improvement in performance. That’s when we’ve reached peak performance and we consider the strategy to be fully optimized.
In this sense, strategy optimization is like a journey of evolution, with each campaign being equivalent to a generation. Within a campaign, the backtests compete, just like animals in nature, and subject to survival of the fittest. The winning backtest in a campaign becomes the starting point for the next campaign, like the seed for a new plant.
As you probably guessed, because Pine Optimizer’s backtest data comes directly from TradingView, it includes all of the detail that TradingView offers natively, including the complete set of trades that make up each backtest sequence.
But, unlike TradingView, Pine Optimizer permanently stores its entire strategy data graph, including all the fine detail of its campaigns and their backtests, as well as their contained trades.
This enables almost limitless flexibility in analysing and comparing the performance of campaigns and strategies, which is a crucial part of identifying opportunities for strategy optimization.
As we’ll explore in a future video, Pine Optimizer includes a comprehensive set of features for analyzing backtest data and extracting useful insights.
So, lets wrap us this session, by identifying some key principles that are central to strategy optimization, using Pine Optimizer.
The foundation principle is that we should store the entire result set of every backtest … forever. This enables us to track improvements in performance, as a strategy evolves towards its optimum, and even allows us to return to old strategies and see how their optimized performance has degraded, over time.
With all this backtest data available to us, we can compare and analyse backtest results, extracting insights that support strategy tuning. This is critical in making informed decisions that yield the highest level of optimization.
And, with the right tools at our disposal, the process of optimization becomes effortless. Pine Optimizer helps us to identify the low hanging fruit for any optimization campaign. And then, with a single click, it will execute all the backtests in that campaign.
So, you should now have a good understanding of how Pine Optimizer extends the capabilities of TradingView to support easy and effective strategy optimization.
In the next video, we’ll look at how to install and launch Pine Optimizer, in preparation for the remaining sessions in this series, where we’ll put Pine Optimizer to work with some real-world strategy optimization exercises.
In the meantime, thanks again for watching.