Home > Blog > Pine Script Tutorial > Variable Forms in Pine Script

Variable Forms in Pine Script

Published by Ali Muhammad
Updated on

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

  • Series
  • Input
  • Const
  • Literal
  • Simple

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.

pine script reference manual

Look at the image below, in the currency variable “Const” is form

variable form constant

Const 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

study("My Script")
a=1 // a= const int
plot(b) // during compiling, b (const int) calculated

The above code will simply plot a line at value 3.

Literal form

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

Series form

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.

series form pine script

Input form

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.

input form pine script

Simple form

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
simple form pine script

The series form is important and remember this form type.

I hope you will like this Article. For any Questions Comment below, also share by below links.

Note: All the viewpoints here are according to the rules of technical analysis. we are not responsible for any type of loss in forex trading.

Do you want to get success in Trading?

Here's the Roadmap:

1. Learn supply and demand from the cheat sheet here
2. Get access the Supply & Demand Indicator here
3. Understand the fair value gap here
4. Use the set and forget strategy here
5. Follow the risk management plan here

Leave a Comment