Literals
Fixed values assigned with immediate values (e.g., 10
, 3.14
,
"value"
), which may not be altered by the script, are called literals.
Literals can only be a type of integer, float, bool and string.
In Pine there are no literals which represent values of a series type.
Instead, there are built-in variables of a series type (such as open
,
high
, low
, close
, volume
, time
, hl2
, hlc3
, ohlc4
). These
variables are not literals.
Integer literals
Integral-valued literals can be presented only in the decimal system. For example:
Floating-point literals
Real literals in comparison with integral-valued literals contain a
delimiter (the symbol .
) and/or the symbol e
(which means “multiply
by 10 to the power of X”, where X is the number after the symbol e
)
or both. Examples:
The first number is the rounded number Pi (π), the second number is very
large, while the third is very small. The fourth number is simply the
number 3
as a floating point number.
Boolean literals
There are only two literals for representing logical values:
String literals
String literals may be enclosed by single or double quotation marks, for example:
Single or double quotation marks are completely the same --- you may use what you prefer. The line that was written with double quotation marks may contain a single quotation mark, just as a line that is written with single quotation marks may contain double quotation marks:
If a user needs to put either double quotation marks in a line that is enclosed by double quotation marks (or put single quotation marks in a line that is enclosed by single quotation marks,) then they must be preceded with backslash. For example:
Color literals
Color literals have the following format: #
followed by 6 or 8
hexadecimal digits matching RGB or RGBA value. The first two digits
determine the value for the red color component, the second two
--- for green, and the third pair --- the value for the blue
component. Each component value is a hexadecimal number between 00
and
FF
(0 and 255 in decimal).
Fourth pair of digits is optional. When set, it specifies the alpha
(opacity) component which value is also between 00
(fully transparent)
and FF
(fully opaque). Examples:
It is possible to change transparency of the color using built-in
function
color.
Here is an example of color
usage:
You can control transparency in properties of a study on Style tab: