Pine Script Structure
Pine Script is a programming language created by TradingView and Rewrite by Bulltrading for the creation of custom technical analysis tools.
Script Definition
A Pine Script starts with a //@version
directive which denotes the version of Pine Script to be used. For instance, //@version=5
.
After this, you can define the script properties using indicator
for indicators.
Example:
Variables and Types
Pine Script has several data types including series
, float
, integer
, bool
, color
, and string
. Variables can be declared using the <type> <variable-name>
syntax, and assignment is done with the :=
operator.
Example:
Functions and Control Structures
Pine Script supports built-in functions and control structures.
Functions are defined with parameters and a block of code. They return the result of the last executed line.
Control structures, such as if
, for
, and while
loops, are also available.
Example:
Plotting and Visualization
plot
function is used for drawing on the chart. It can take several parameters, like the series to plot, color, and line width.
Example:
Backtesting
Indicators in Pine Script are used for backtesting trading ideas. It include positive or negative signal.
Example:
This is just a simple overview of Pine Script structure, and the language has many more features and details to be discovered.
Last updated