In the previous article, we discussed the types of variables used in pine script. In this article, we will discuss the forms of different types of variables.
Let me make it simple for you. In the first step, we discussed what is variables in the pine script. Then, I elaborated on the types of variables. Now I will discuss the forms of types of variables.
This is a difficult and important phase of pine script language and you must learn it. Here at this level, you just must remember and learn the different terms. When we will make different indicators and strategies at the end, then you will understand everything.
Variable forms are categorized into 5 forms
Open reference manual
To check the type and form of variable, open the reference manual in pine editor and then further click on built-in variables. This will open a large number of built-in variables which can be used in the program easily. Tradingview has made it easy for pine programmers by providing a library full of built-in stuff.
Look at the image below, in the currency variable “Const” is form
As the name suggests, constant form does not change during the execution of a program but during compiling, it can be calculated. For example
//@version=4 study("My Script") a=1 // a= const int b=a+2 plot(b) // during compiling, b (const int) calculated
The above code will simply plot a line at value 3.
Literal form simply means a fixed value and it can be any.
1.23223 // Literal float (currency price) 5 // Literal int "Hello world" // Literal string true // Literal bool
The series form contains a series variable. It contains series of data associated with the candlestick chart like open, high, low, close. The  operator is used to access series of data. Basically, data is stored in arrays. Series form changes during program execution.
Input form simply refers to the input variables which can be changed in the indicator’s settings pop up. It does not change during program execution, but it can be changed later in the settings.
The simple form represents the value coming from the chart like tick value. A tick is the shortest move in the price of a currency pair in forex. It does not change during program execution.
- Simple string
- Simplee int
- Simple bool
- Simple float
- Simple color
The series form is important and remember this form type.