PineScript Tutorial
PineScript from TradingView is a simple programming language that is specially designed for traders. Pine can be used for building indicators or fully-automated trading strategies. This tutorial exclusively focuses on coding indicators.
The Basics of Creating Scripts
A script can refer to simple research (Study) or an automated system (Strategy). Both elements (Studies and Strategies) include functions and variables. At the beginning of each script there is a statement declaring the version of PineScript, the name of the script, and whether if it is a Study or a Strategy:
//@version=4
study(title, shorttitle, overlay, format, precision)
This is a short explanation of the above parameters:
- If used, ‘overlay’ defines where the calculation will be shown on the main chart or below the main chart
- If used, ‘format’ defines the type of formatting in indicator values. The available values are: format.inherit, format.price and format.volume
- If used, ‘precision’ states the number of digits after the floating point. It must be a non-negative integer and not greater than 16
At the end of each script there are the instructions to plot the results inside the chart window (overlay=true) or below the chart window:
- If nothing is stated, scripts are designed to plot calculations below the chart window
- If you add at the beginning the instruction (overlay=true), calculations will be plotted inside the chart window