Skip to content
Algo Trade Analytics Docs

const - Pine Script Type

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.

  • To learn more, see our User Manual’s section on type qualifiers.
//@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)