July 31, 2020
Best Description of Study VS Strategy on TradingView
Many wonder what study and strategy are in TradingView and how to use them. Below is the basic concept of what to study and strategy and the difference between them!
A script written in Pine must contain a study or strategy annotation which defines the script’s name and other properties. The script’s body contains the functions and variables necessary to calculate results which will be rendered on a chart with a plot function or some other function that plots the script’s output.
What is Study?
A study contains calculations and may plot information on charts. A lot of users will use a study script to share their ideas on TradingView. Since the purpose of the script is not the backtesting result but the new way of thinking, these users will choose to use study script instead of strategy script.
A Simple Study Example
The above is an example of how the study works. As you can see on the graph, we plot three different SMA (Simple Moving Average) lines on the graph. I can observe the movement of these lines to get a better understanding of the index. However, since this is a study script, it will not provide me the result of backtesting.
You can set properties in the study() function according to your preference. The following arguments can be added:
What is Strategy?
A strategy is a Pine script that can send, modify, and cancel buy/sell orders. Strategies allow you to perform backtesting (emulation of a strategy trading on historical data) according to your algorithms.
Strategies may plot data, but they can also place, modify, and cancel orders. They also have access to essential strategy performance information through specific keywords. The same information is available externally in the Strategy Tester tab. Once a strategy is calculated on historical data, you can see hypothetical order fills.
A Simple Strategy Example
Above is an example of how the strategy works. With strategy, not only have I plotted the SMA lines on the graph, but I have also built the buy/sell orders that will execute when certain conditions are reached. Also, I can get a detailed backtesting report to let me know how my strategy performs with the historical data.
You can also set properties in strategy() function according to your preference. Some arguments are just the same as those in the study(), so we will only go through the arguments that are not seen before. The following arguments can be added:
What’s the difference?
Before the update in June, the difference between study and strategy is that users can create alerts under a study and can perform backtesting under a strategy. However, after the update, now users can receive alerts from both study and strategy. So, now the only main difference between study and strategy is that strategy script provides backtesting while study script does not.