Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

int() - Pine Script Function

int() casts a value to an integer. Floating-point numbers are truncated toward zero, booleans map to 1/0, and strings must represent numeric values.

int(x) → const int
NameTypeDescription
xconst int/float/bool/stringValue to convert.

const int — result of the cast (na if conversion fails).

  • int(1.9)1; int(-1.9)-1.
  • true1, false0.
  • Non-numeric strings return na.
//@version=6
indicator("int() example", overlay=false)
floatInput = input.float(12.75, "Float value")
boolInput = input.bool(false, "Bool value")
strInput = input.string("42", "String value")
intFloat = int(floatInput)
intBool = int(boolInput)
intStr = int(strInput)
plot(intFloat, "From float", color=color.blue)
plot(intBool, "From bool", color=color.orange)
plot(intStr, "From string", color=color.green)