const - Pine Script Type
Overview
Section titled “Overview”The const keyword explicitly assigns the “const” type qualifier to variables and the parameters of non-exported functions. Variables and parameters with the “const” qualifier reference values established at compile time that never change in the script’s execution.
Remarks
Section titled “Remarks”- To learn more, see our User Manual’s section on type qualifiers.
Example
Section titled “Example”//@version=6indicator("can't assign input to const")//@variable A variable declared as "const float" that attempts to assign the result of `input.float()` as its value.// This declaration causes an error. The "input float" qualified type is stronger than "const float".const float myVar = input.float(2.0)plot(myVar)